This manual is quite technical. Don’t worry, it will guide you in all the ins and outs of the PDF generator.
Before we start
You need a basic set of HTML and CSS knowledge
A basic programming language skill set is not required but helps
You need a basic understanding of akeneo product data
In this guide you will learn :
How to create a template, assets and translations from scratch
How the render engine works with dynamic content
How to create and control your own content dynamically
How to generate a PDF an its' storage options
...
When we have our templates set up, we can now start linking our products and product models onto the template.
In order to link a product:
Go to the product grid
find the product you wish to link
In the product details page select the templates tab
Select the template(s) you wish to link
Press save to Confirm
If you have multiple products selected, each product will export as a separate PDF.
If you wish to include products into 1 PDF you will need to setup a Source for this.
The PDF generator uses templates as a set of essential parts to generate a PDF.
The template consists of the following properties.
The XML configuration specifies what information of the product data that you wish to feed as data.
It also specifies what dynamic blocks should be rendered in combination with its' configuration.
You can find more information about these blocks here.
Here is a basic example, we don’t specify much, just the title of the page that will be placed inside the header.
We also specify a link to the assets collection
<body link='template.html.twig'>
<title>My Title</title>
</body>
Let’s continue the configuration file and add a dynamic block.
We are adding a paragraph block with a label and some content.
<body link='template.html.twig'>
<title>My Title</title>
<blocks>
<paragraph label="{{ trans('advantages') }}">
{{ normalize('advantages') }}
</paragraph>
</blocks>
</body>
Let’s add some more blocks to the blocks node.
Here we added a table to render, we render the SKU, color and size as columns.
And in order for our table to render successfully, we provide a source that is coming from our product associations called pack.
Find more about product sources here.
<body link='template.html.twig'>
<title>My Title</title>
<sources>
<source code='associations:pack'>
<family code='smartphones' />
</source>
</sources>
<blocks>
<paragraph label="{{ trans('advantages') }}">
{{ normalize('advantages') }}
</paragraph>
<table
label="{{ trans('table.variants') }}"
source="associations:pack"
column="sku,color,size">
</table>
</blocks>
</body>
Every template needs an asset collection. An asset collection allows you to determine the layout of your pdf. For more info check the ‘assets’ tab.
The template will have to provide some context to the render engine in order to render the correct Data Set.
You can overrule these values if needed.
More information about context overruling inside functions can be found here
{
"locale": "en_US",
"scope": "ecommerce"
...
}
So rendering static content should not be that hard, you can use most of HTML / CSS tricks in your sleeve to create the perfect design.
In order to make dynamic content possible we need a dynamic language called twig.
Twig is an easy syntax to learn but hard to master, so we limit our usage of twig syntax only to places where it counts.
We separate our dynamic in two distinct ways.
Dynamic Functions and Dynamic Blocks:
Dynamic functions: Functions that will render the correct value based on it’s context.
Dynamic blocks: Blocks that will render values into a reusable structure like a table, section based on its' input data.
Your assets are a set of HTML structured files that are novice to any web developer.
Any type of file that can be used to create a website can be used inside this template.
Most often an asset directory should consist of the following:
template.html.(twig): Our main html file, you can call it what you want, but you have to provide the correct filename in the XML body link.
fonts: fonts you wish to use.
media images: png or jpg files are supported
css: you can use inline css or standard css files
blocks: dynamic blocks for dynamic content
...
In this section you will learn:
how to generate a PDF
how the PDF generator works on cron
how to store you PDF onto an attribute.
Once your template is final for rendering into a PDF you can try rendering your template.
The generate PDF button will create a queued task to render a PDF based on your template settings.
Check the activity tracker to see if your render was exported successfully.
Select that latest job and download the PDF file.
It’s possible that some products will not render based on the validations, check for more info here.
Based on your input we will generate PDF on a daily basis.
The command will only render updated products since the last 24 hours.
The command will only render products that pass validation.
0 1 * * * php $APP_DIR/bin/console induxx:pdf:export-delta --daysAgo=1 --user='admin' -vvv
The PDF you generate is stored in the attribute you define in the settings of the app.
...
added mass edit for assets
added attribute to save to
made service overridable
remove empty values in characterise table
BUGFIX: get raw values, associations table data
added associations table
Removed products normalization inside Rawvalues
Added Metric Value formatter
Added translations on boolean
made filter product caching localizable BUGFIX: removed thousands separator
added translations option into link function, fixed issue with attribute label translations and added attribute option translation
Update OnPdfDocumentWasCreatedSubscriber.php
corrected aws resize URL Corrected AWS filter added option display metric-display-unit boolean parameter
Remove unneeded value conversion
Change Project dependent normalizer and show result bug Added Project RawValuesNormalizer Added multi-sort
added sort filter and page-limit
PdfDocumentWasCreatedEvent Cleanup
added European number format
Added S3 image support to imageValidator
added better validations
Update DateSheetDocumentWriter.php
added local catalog_storage filesystem
added support for characteristics
Added recursive pm filter and association support Ability the modify your working path per job added refeerence support to the Task setup default scope code complate refactor of the PdfEngine and twig extensions initial support for tables
Bugfix: fixed issue with product model normalizer
Made bundle compatible with Akeneo 3.x
Added multi-select support
Update OnPdfDocumentWasCreatedSubscriber.php
Added PdfWasCreatedSubscriber renamed the default attribute_code moved to locale filename for correct placement added filter support on LinkedEntities Update OnPdfDocumentWasCreatedSubscriber.php
Fix for Pruduct Selector
GetName Locale issue fix
PDF : label fix
Update PdfController.php
filename sanitize update
bugfixes and better validation
spit up the filename locale for easier handlingfix : allow files to be writen in sub directoryfix for File_exists issue vs is_filereverse timestamps for nowadded surrounding div on reusable blocksadded Timestamp that doesnt update fixdont throw exception when attribute label is nullchanged to CurrentLocale instead of UI localeadded basFile exceptionadded refeerence support to the Task
fix: when requiredcodes is null dont validateadded Required attributes validation
json-response output attribute async fix
init project