Home Devert | PDF Export: Shopping cart, listing, product page, wishlist (DevertPdfExport) Documentation Shopware Store ↗ Deutsch

Change PDF templates

Every PDF is a Twig template. Change single blocks in your own plugin without editing the PDF Export plugin.

Direct changes to the files of this plugin are lost with the next update.

What the PDF engine can do

The PDFs are created by DomPDF, not by a browser. It mainly supports classic CSS. Do not rely on flexbox and grid; build columns with tables, as the plugin does. float often behaves differently than expected. Links are disabled in the PDFs on purpose. Pictures are embedded into the document.

Structure of a customization plugin

The following examples were tested with a small separate plugin on Shopware 6.7. The files are in src/Resources/views/storefront/pdfexport/pdf/, the same path as the original. Each starts with sw_extends to the original:

{% sw_extends '@DevertPdfExport/storefront/pdfexport/pdf/listing-download.html.twig' %}

The plugin needs a composer.json with require.shopware/core. After installing it and after changes: bin/console cache:clear.

FilePDF
base.html.twigshared base of all PDFs: header, footer, styles
product-download.html.twigproduct
listing-download.html.twigcategory
cart-download.html.twigcart
wishlist-download.html.twigwishlist
productoffer-download.html.twigoffer from the product page
cart-offer-download.html.twigoffer from the cart
offer-header.html.twigaddress and offer data

Example: colors and page numbers

File base.html.twig. By default the headline bars use the primary color of your theme. The placeholder DOMPDF_PAGE_COUNT_PLACEHOLDER is replaced by the number of pages.

{% sw_extends '@DevertPdfExport/storefront/pdfexport/pdf/base.html.twig' %}

{% block document_head_base %}
    {{ parent() }}
    <style>
        .pdfexport-headline { background-color: #0a7d5a; border-radius: 6px; }
        footer:after { content: "Page " counter(page) " of DOMPDF_PAGE_COUNT_PLACEHOLDER"; }
    </style>
{% endblock %}

Example: additional column

File listing-download.html.twig. Table head and rows are separate blocks, you need both.

{% sw_extends '@DevertPdfExport/storefront/pdfexport/pdf/listing-download.html.twig' %}

{% block element_product_listing_head_ordernumber %}
    {{ parent() }}
    <td>Stock</td>
{% endblock %}

{% block element_product_listing_box_ordernumber %}
    {{ parent() }}
    <td>{{ product.availableStock }}</td>
{% endblock %}
Listing PDF before the change
Before
Listing PDF with a stock column, green headline and page number (German example texts)
After, with both examples

Another column takes space from the others, long names can be cut off. Hide a column in the configuration or set widths with CSS then. For several languages use a snippet for “Stock”.

Example: your own note

File product-download.html.twig:

{% sw_extends '@DevertPdfExport/storefront/pdfexport/pdf/product-download.html.twig' %}

{% block page_product_detail_tabs_content_description %}
    {{ parent() }}
    <p style="border: 1px solid #0a7d5a; padding: 10px;">
        <strong>Note:</strong> All dimensions are approximate.
    </p>
{% endblock %}
Description page with a framed note and page number (German example texts)

Page break

<div class="page_break"></div>

More useful blocks

TemplateBlocks (selection)
Basedocument_header_logo, document_header_col1 to col3, document_footer, document_content
Productpage_product_detail_header_title, page_product_detail_media, page_product_detail_price, page_product_detail_tabs_content_properties
Category, wishlistelement_product_listing_head_*, element_product_listing_box_*
Cartpage_checkout_cart_table_head_row, page_checkout_cart_table_item, page_checkout_aside_summary
Offer headerpdfexport_offer_header_address, pdfexport_offer_header_meta

Find problems

With debug you get the HTML in the browser and can inspect it with the developer tools. The layout in the browser differs from the PDF, so always check the result as a PDF too.