PDF Printing

Time to read: 13 minutes


Introduction

If you can print a usable delivery note and a usable invoice at the push of a button, you save a lot of time and money. With this module for PDF delivery note and invoice printing, elegant PDF documents can be generated for each incoming order. You can also import your own PDF template, which is then used as a letter template. The module is optionally available for the PepperShop and must be purchased separately.

Module configuration

First you go to the PDF module administration: Main menu of the shop administration Modules > PDF

In the administration mask of this PepperShop module you can now upload your own PDF templates, activate the module and precisely configure the placement of the individual elements (address, title, article positions, …).

Figure 1: Extract from the PDF module configuration dialog

In the PDF module administration there are the following setting options:

Figure 2: Continuation of Figure 1

  • Restore default values: The module is reset to its default values, any configurations are lost, and the default values are set.

Configuration for the display of articles

  • Activation: Should the module be active?
  • PDF template for the first page: Here you can upload a PDF template for the first page. The upload is done without the save button.
  • PDF template for the next page: A PDF template for the next page is uploaded here. The upload is done without the save button.
  • Test view: A test PDF is generated.

Configuration settings Address block (address)

  • Maximum line length (longer lines are wrapped): The maximum number of characters that can appear on a line is expected.
  • Address block Distance from left document margin (in mm): How large should the total distance from left document margin to address block be? The indication must be given in millimetres.
  • Address block Distance from upper document margin (in mm): How large should the total distance from the upper document margin to the address block be? The indication must be given in millimetres.
  • Width of the address block (in mm): The width of the entire address block. The indication must be given in millimetres.
  • Address block font style: blank, B, I, U: Specify whether the text should be Bold (bold), Italic (italic), Underlined, or simply unformatted (blank).
  • Address block font size in dots: What size should the normal font in the address block be?

Configuration settings document title (e.g. invoice, delivery note)

  • Title block Distance from left document margin (in mm): How large should the total distance from left document margin to title block be? The indication must be given in millimetres.
  • Title block Distance from top edge of document (in mm): How large should the total distance from top edge of document to title block be? The indication must be given in millimetres.
  • Width of the left column (labels): How large should the left column be? The value should be given in millimetres.
  • Text alignment left column: The width of the entire address block. The indication must be given in millimetres.
  • Title block font style: blank, B, I, U: Specify whether the text should be Bold, Italic, Underlined, or simply unformatted.
  • Title block font size in dots: What size should the normal font be in the title block?

Configuration settings info block (invoice number, order date,..)

  • Infoblock Distance from left edge of document (in mm): How large should the total distance from left edge of document to infoblock be? The indication must be given in millimetres.
  • Infoblock Distance from top edge of document (in mm): How large should the total distance from top edge of document to infoblock be? The indication must be given in millimetres.
  • Width of the left column (labels): How large should the left column be? The value should be given in millimetres.
  • Width of the right column (contents): How large should the right column be? The value should be given in millimetres.
  • Width of the second left column (switched on with two columns): How large should the second left column be? The value should be given in millimetres.
  • Width of the second right column (switched on with two columns): How large should the second right column be? The value should be given in millimetres.
  • Text alignment left column: The alignment of the text within the left column. Enter L for left or R for right.
  • Text alignment right column: The alignment of the text within the right column. Enter L for left or R for right.

Configuration settings Item table

  • Invoice, maximum line length of the article name (longer lines are wrapped): After how many letters should the content be wrapped?
  • Delivery, maximum line length of the article name (longer lines are wrapped): After how many letters should the content be wrapped?
  • Article table distance from the left document margin (in mm: How large should the total distance from the left document margin to the title block be? The indication must be given in millimetres.
  • Article table distance from upper document margin (in mm): How large should the total distance from the upper document margin to the title block be? The indication must be given in millimetres.
  • Wide position columns: How wide should the column be that displays the individual positions? The indication must be given in millimetres.
  • Wide label column: How wide should the column containing the labels be? The value should be given in millimetres.
  • Width Column Number: How wide should the column containing the number of articles be? The value should be given in millimetres.
  • Width column Unit: How wide should the column containing the unit (piece, kg, etc.) be? The value should be given in millimetres.
  • Wide price column: How wide should the column containing the prices be? The value should be given in millimetres.
  • Wide VAT column: How wide should the column containing the VAT be? The value should be given in millimetres.
  • Width of total column: How wide should the column containing the totals be? The value should be given in millimetres.
  • Text alignment position columns: The alignment of the text within the position columns. Enter L for left or R for right.
  • Text alignment label column: The alignment of the text within the label column. Enter L for left or R for right.
  • Text alignment column number: The alignment of the text within the column number. Enter L for left or R for right.
  • Text alignment column Unit: The alignment of the text within the column Unit. Enter L for left or R for right.
  • Text alignment price column: The alignment of the text within the price column. Enter L for left or R for right.
  • Text alignment VAT column: The alignment of the text within the VAT column. Enter L for left or R for right.
  • Text alignment total column: The alignment of the text within the total column. Enter L for left or R for right.

Configuration settings Additional article information (variants, options, text fields)

  • Article supplement information font size in points: What size should the normal font in the address block be?
  • Article Supplement Information Font Style: blank, B, I, U: Specify whether the text should be Bold, Italic, Underlined, or simply unformatted.

Configuration settings (article)Images

  • Display article images in invoice
  • Show article pictures in delivery note
  • Article pictures: Maximum height
  • Article pictures: Maximum width
  • General pictures: Resolution in dpi (dpi = dots per inch)

Article pictures are always taken from the current assortment (identified by the internal article ID). If an article is removed from the assortment or its image has changed in the meantime, this will also affect the invoice/delivery note imprint. It should also be noted that only JPG and PNG (8-bit only) images can be displayed.

Configuration settings Total positions

  • Wide currency column: How wide should the column containing the currency column be? The value should be given in millimetres.
  • Width of total column: How wide should the column containing the total column be? The value should be given in millimetres.
  • Text alignment label column: The alignment of the text within the label column. Enter L for left or R for right.
  • Text alignment column Currency: The alignment of the text within the Currency column. Enter L for left or R for right.
  • Text alignment total column: The alignment of the text within the total column. Enter L for left or R for right.

Configuration settings Number of pages/total number of pages

  • Page number Distance from left document margin (in mm): How large should the total distance from left document margin to title block be? The indication must be given in millimetres.
  • Page number Distance from upper document margin (in mm): How large should the total distance from the upper document margin to the title block be? The indication must be given in millimetres.
  • Font style: blank, B, I, U: Specify whether the text should be Bold, Italic, Underlined, or simply unformatted.
  • Font size in points: What size should the normal font in the address block be?
  • Alignment: The alignment of the text of the page number/page total. Enter L for left or R for right.

Configuration settings invoice payment deadline

  • Display payment deadline (only for invoice PDF document): display in invoice
  • Payment period: Number of days: Indication in days

General configuration

  • Text color Red portion of the RGB: The red portion of the text color for the PDF.
  • Text color Green portion of the RGB: The green part of the text color for the PDF.
  • Text color Blue portion of the RGB: The blue portion of the text color for the PDF.
  • Font name: Select the font for the PDF here.
  • Font Style: blank, B, I, U: Specify whether the text should be Bold, Italic, Underlined, or simply unformatted.
  • Font size in points: What size should the normal font be?
  • Top margin: Specify the top margin in millimeters from the top margin.
  • Right margin: Specify the margin in millimeters from the right margin.
  • Bottom margin: Specify the page margin in millimeters from the bottom margin.
  • Left margin: Specify the margin in millimeters from the left margin.
  • Output the orientation grid for the entire document: Places an auxiliary grid over the entire PDF so that the alignment can be checked.
  • Display of prices incl. VAT.

Operation

To create a delivery note or an invoice, simply click on the new PDF button under Customers/Orders > Customer Management and select the corresponding link.

Figure 3: Customer management and orders view

The generated PDF files are stored in the following directory:

{shopdir}/shop/Admin/pdf/generated/

Import your own fonts (for advanced users)

In the PepperShop, PDFs are created using the FPDF Library. This can only use specifically formatted fonts. A TrueType font must be converted first. There is an easy to use online generator for this: http://fpdf.fruit-lab.de/

Here you specify a TrueType font (.TTF file) and save the two files .php and .z after the conversion. These two files must be copied to the following directory for each typeface (normal, bold, italic and bold+italic):

{shop_directory}shop/Admin/pdf/fpdf/font/

In order for the FPDF font to be used, it must correspond to a special naming scheme: Only lower case letters and no special characters (e.g. font: Lars Sans):

  • Normal:{Font Name}.ttf Example: larssans.ttf
  • Bold:{Font Name}b.ttf Example: larssansb.ttf
  • Italic:{Font Name}i.ttf Example: larssansi.ttf
  • Bold+italic:{Font Name}bi.ttf Example: larssansbi.ttf

Convert own font via PepperShop batch import

With this tool, which is available from PepperShop v.3.2, you can quickly convert many fonts to FPDF.

Connect to the web server via FTP or console. Create the following two new directories in the shop, if they do not already exist:

shop_directory}/shop/Admin/pdf/fpdf/src (if necessary adjust directory permission to 777)

shop_directory}/shop/Admin/pdf/fpdf/dest (if necessary adjust directory permission to 777)

Store the TTF files to be converted in the src directory.

The TTF files must comply with the naming convention mentioned in the previous chapter and all four font styles must always be present!

a) Make the following call in the browser or via command line (safe mode must be off!):

http://www.example.com/mein/pfad_to_the_webshop/shop/Admin/pdf/makefont_batch.php

b) …or via command line:

cd {shopdirectory}/shop/Admin && php pdf/makefont_batch.php commandline

The now created fonts (.php + .z files) from the folder

.../shop/admin/pdf/fpdf/makefont/_dest_

to the folder

shop/Admin/pdf/fpdf/_font_ move. The fonts can now be used.

UTF-8 support

By default, the underlying FPDF system only supports the Latin1 character set. If you want to use the extensive UTF-8 character set, which can also be used to display many characters from other languages, proceed as follows:

Prerequisites:

  • System requirement is a PepperShop version 5.0.0.24 or higher.
  • Direct file access must be available (FTP or SCP).
  • Knowledge of PHP and an editor that can work with UNIX line breaks

UTF-8 switchover / activation:

  • unzip admin/pdf/tfpdf.tar.gz
  • If you have a TrueType font (.ttf) that supports UTF-8 (!), you can configure the module to work with UTF-8.
  • In the file {shop_directory}/shop/Admin/pdf/pdf_config.php you have to change the control constant PDF_USE_UTF8 to true.
  • The constant PDF_USE_UTF8_FONT_NAME contains the name of the UTF-8 capable TTF font.
  • The file name of the font is entered in the constant PDF_USE_UTF8_FONT.
  • The font must be in the directory {shop_verzeichnis}/Admin/pdf/tfpdf/font/unifon/.
  • The constant PDF_USE_UTF8_FONTB is the same as PDF_USE_UTF8_FONT for ‘bold’.
  • The constant PDF_USE_UTF8_FONTI is the same as PDF_USE_UTF8_FONT for ‘italic’.

Installation

System requirements

To be able to use the PDF print module, a PepperShop v.3.0 Professional or Enterprise is required.

Copy and upload files

The module consists of some files and subdirectories that you have to copy into your installed PepperShop. First unzip the included ZIP archive. It contains the subfolders with the files:

{shopdir}/shop/Admin/pdf
{shopdir}/shop/Admin/module/pdf
{shopdir}/shop/module/pdf

The files can be easily uploaded via FTP or SCP to the web server. The placeholder {shopdir} stands for the shop directory on the web server, where the file index.php can be found together with the file README.txt.

Now the module is recognized and integrated by the shop. It is listed in the Shop Settings > Shop Configuration menu at the bottom of the internal module info.

Module installation

After copying the files you can go to the shop administration and switch to the Modules menu. On the left side, at the not yet installed modules, you can see the PDF module listed.

Now select the PDF module and click on the Install button. If the installation routine runs without problems, this will be communicated on the following page. The module is now installed. We now click on the button Back to module administration and there Back to module administration. We now see a button for the PDF module. If you click on this button, the management of this module will appear.

Figure 4: Module administration (the displayed modules may differ)

Further installation steps

The PDF printing module contains two packages which have to be unpacked to use the module smoothly:

{shopdir}/shop/Admin/pdf/fpdf.tar.gz
{shopdir}/shop/Admin/pdf/fpdi.tar.gz

If PHP is running on a UNIX server as a web server module (and only then):

  • assign the access rights 777 to the directory {shopdir}/shop/Admin/pdf
  • assign access rights 777 to the {shopdir}/shop/Admin/pdf/generated directory
  • Assign access rights 777 to the directory {shopdir}/shop/Admin/pdf/template

The file access rights can also be set automatically (FTP based): Shop Settings > Shop Configuration > Operations you should now adjust the file permissions.

The installation of the PDF module is now complete. In order for the module to be used, it must now be adapted to the specific configuration of the shop operator, see the next chapter Module configuration, below.

Attachments

Appendix 1: Example invoice

Appendix 2: Example delivery note

🌶️
🔥
🌶️