Important
You are browsing upcoming documentation for version 7.0 of OroCommerce, scheduled for release in 2026. Read the documentation for version 6.1 (the latest LTS version) to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
Create a PDF File
The overall chain of generating a PDF file
is as follows:
``Start`` -> ``PDF builder factory`` -> Create ``PDF builder`` -> ``PDF builder`` -> Create ``PDF file`` -> ``PDF engine`` -> Create ``PDF file`` -> ``PDF file`` -> ``End``
Example:
$pdfBuilder = $this->pdfBuilderFactory->createPdfBuilder(PdfOptionsPreset::DEFAULT_PRESET);
$pdfTemplate = $this->pdfTemplateFactory->createPdfTemplate(
'@AcmeDemo/PdfDocument/template.html.twig',
['param1' => 'value1', 'param2' => 'value2']
);
$pdfBuilder->content($pdfTemplate);
// Set the page size to A4 format width and height.
$pdfBuilder->setPageWidth('8.27in');
$pdfBuilder->setPageHeight('11.7in');
/* @var $pdfFile \Oro\Bundle\PdfGeneratorBundle\Model\PdfFileInterface */
$pdfFile = $pdfBuilder->createPdfFile();