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 Document
The overall chain of generating a PDF document
is as follows:
``Start`` -> ``PDF document operator registry`` -> Get operator -> Create PDF document demand -> ``PDF document operator`` -> Create PDF document -> ``PDF document factory`` -> ``PDF document`` -> ``PDF document resolver`` -> Resolve ``PDF document`` -> ``PDF document generator`` -> Generate ``PDF file`` -> ``PDF builder factory`` -> Create ``PDF builder`` -> ``PDF builder`` -> Create ``PDF file`` -> ``PDF engine`` -> Create ``PDF file`` -> ``PDF file`` -> Update ``PDF document`` with ``PDF file`` -> ``End``
Example of PDF document
generation of the us_standard_invoice PDF document type
in the instant PDF document generation mode
:
$pdfDocumentDemand = new GenericPdfDocumentDemand(
sourceEntity: $order,
pdfDocumentName: 'order-0101',
pdfDocumentType: 'us_standard_invoice',
pdfOptionsPreset: PdfOptionsPreset::DEFAULT_PRESET,
pdfDocumentPayload: ['customer_notes' => 'Some notes']
);
/* @var $pdfDocument \Oro\Bundle\PdfGeneratorBundle\Entity\PdfDocument */
$pdfDocument = $this->pdfDocumentOperatorRegistry
->getOperator(Order::class, PdfDocumentGenerationMode::INSTANT)
->createPdfDocument($pdfDocumentDemand);
/* @var $pdfDocumentFile \Oro\Bundle\AttachmentBundle\Entity\File */
$pdfDocumentFile = $pdfDocument->getPdfDocumentFile();
Example of PDF document
generation of the us_standard_invoice PDF document type
in the deferred PDF document generation mode
:
$pdfDocumentDemand = new GenericPdfDocumentDemand(
sourceEntity: $order,
pdfDocumentName: 'order-0101',
pdfDocumentType: 'us_standard_invoice',
pdfOptionsPreset: PdfOptionsPreset::DEFAULT_PRESET,
pdfDocumentPayload: ['customer_notes' => 'Some notes']
);
/* @var $pdfDocument \Oro\Bundle\PdfGeneratorBundle\Entity\PdfDocument */
$pdfDocument = $this->pdfDocumentOperatorRegistry
->getOperator(Order::class, PdfDocumentGenerationMode::DEFERRED)
->createPdfDocument($pdfDocumentDemand);
// The PDF document will be generated once URL is accessed.
$pdfDocumentUrl = $this->pdfDocumentUrlGenerator->generateUrl(
$pdfDocument,
FileUrlProviderInterface::FILE_ACTION_DOWNLOAD,
UrlGeneratorInterface::ABSOLUTE_PATH
);
For information on how to generate a download URL for a PDF document
, see the How to Download a PDF Document section of the documentation.