wsfilter=pdf, any shop page can be output as a PDF. The system interprets the requested URL as usual, but does not output the page as HTML; instead, it converts it server-side into a PDF document. The result can be displayed directly to the user in the browser or offered as a file for download.
Dynamically generated PDFs cannot currently be automatically sent as an email attachment. However, they can be provided as a download link — on a shop page or in an email (see PDF download in an email).
Modules
Only the module $wsViews is strictly required, in order to use viewUrl() and view information. The use of other modules depends on the respective page context from which a PDF is to be generated.URL parameters
| Parameter | Value | Required | Description |
|---|---|---|---|
wsfilter | yes | Outputs the page as a PDF. | |
wsfilterName | filename.pdf | no | Specifies the file name of the generated PDF, including the .pdf extension. Without this specification, the system assigns a default name. |
How it works
Output any shop page as a PDF
The simplest way is to append?wsfilter=pdf to any shop URL. The system then renders the requested page, including navigation, header, and footer, and outputs it as a PDF.
Example for a product page:
Using your own template for the PDF view
If the PDF should look different from the normal shop page, for example without navigation, header, or footer, a separate template must be created for this. A PDF view is a normal view template that, like any other view template, is stored in thetemplates/views/ directory and linked via $wsViews.viewUrl(). To force PDF output, the parameter wsfilter=pdf is additionally passed when calling.
Example call of your own template as a PDF:
Data availability in the PDF template
A PDF template is generated server-side in exactly the same way as a normal shop page. It therefore offers the same access to modules as any other shop template. This means that the data does not have to be passed separately or rebuilt. What is decisive for the availability of the modules is the context in which the PDF is generated:- Session and shop-wide data are always available, regardless of which template is currently being used. This includes, for example, the basket ($wsBasket), the customer account including addresses ($wsAccount), or configuration values ($wsConfig). A basket PDF can therefore read the basket directly via $wsBasket, for example.
- Page-context-related data — for example the currently called product or current category — are bound to the respective page context and can be accessed via $wsViews.current.info. A product PDF must therefore be generated from the context of the respective product so that the product data is loaded.
Examples
Outputting the basket as a PDF
To offer a PDF version of the basket page within the basket, a PDF template is needed that displays the basket, as well as a download link via which this template can be called as a PDF. The download link is embedded in the template of the basket page (e.g.,basket.htm — the exact name depends on how the basket page is named in the respective shop). It calls the PDF template and appends wsfilter=pdf.
views/pdf/basket.htm) reads the basket data directly via $wsBasket.
Providing an order confirmation as a PDF
A frequent use case is offering the customer a PDF order confirmation after a successful order. Like any other PDF view, it is generated via a PDF template (stored here underviews/pdf/bestellbestaetigung.htm) that displays the order data and is called with the parameter wsfilter=pdf. Since the order data is bound to the context of the completed order, the download link is placed on the order confirmation page that the customer sees directly after completing the order.
PDF download link in an email
PDF files can be provided as a download link in email templates (e.g., the order confirmation email). The PDF is not attached to the email, but is generated when the link in the email is clicked. The link is built according to the already known scheme. Two things are important here: the type “absolute”, because emails require complete URLs, and the parameters that uniquely identify the content (e.g., voucherId, productId). This way, the PDF can be generated independently of the session.
Example: Download links in the email template for purchased vouchers, which is sent after vouchers have been purchased through the shop.
voucher/default_voucher.htm is the PDF template that outputs the voucher data based on the passed voucherId and productId.
