Penguinable Guide

PAD PDF Generators 1.1.1

User Guide

Davide Alghi

www.penguinable.com

 

 

 

 
 


Rev 1

 







PAD PDF Generators

1.1.1

User Guide

YetiForce ERP-CRM

 

 

Index

Introduction

What it does

Screenshot

Requirements

Installation

Step 1: extension installation

Step 2: packages installation via Composer

Step 3: wkhtmltopdf installation

Step 4: Google Chrome installation

Migration from YetiForce 6.1 to YetiForce 6.2

I still have to migrate to YetiForce 6.2

I have already migrated to YetiForce 6.2

Migration from YetiForce 6.4 to YetiForce 6.4

I still have to migrate to YetiForce 6.4

I have already migrated to YetiForce 6.4

What has changed in PAD PDF Generators for YetiForce 6.4

Configuration

YetiForcePDF - YetiForce library

mPDF (Ian Back library)

Snappy (wkhtmltopdf wrapper)

Headless Chromium (Google Chrome wrapper)

Features, pros and cons

mPDF (Ian Back library)

Features

Pros

Cons

Snappy (wkhtmltopdf wrapper)

Features

Pros

Cons

Headless Chromium (Google Chrome wrapper)

Features

Pros

Cons

Styling examples

Different styles

Style families

Style families for the header and footer

Style families for the page

Watermark style families – mPDF excluded

Right to Left text

Setting style families for PAD Textparser Products Table extension

PADProductsTableSimple – lineitems table – Products / Services

PADProductsTableCursum – summary table – Tax / Discount

Discount in total class name

Discount summary class name

Tax mode class name

Tax summary class name

Printing examples in different languages

Workflow process for PDF sending

Textparser function for barcode and qrcode

Compatibility

Dependencies

Deprecated

Known Issues

Changelog

Bug report

 

Introduction

What it does

It adds alternative PDF generators: mPDF, WebKit Html To PDF (wkhtmltopdf) and Google Chrome (endless).

The new PDF generators can be used likewise the YetiForce built-in generator.

For single entity printing, multi-entities printing (zip), multi-entities printing in a single PDF file, sending by email and sending PDF via workflow.

It is possible to associate a style file (CSS) to each generator: the style classes can be used in the PDF template.

 

Screenshot

 
 

Requirements

IMPORTANT: to complete the installation, you must have full access to the web-server. The installation requires the use of "Composer", which must already be installed on the web-server. You also need to install the wkhtmltopdf package and/or the Google Chrome web browser.

Refer to the “Installation” chapter for details.

 

IMPORTANT: operation is only guaranteed on Linux web-servers

Installation

Installation requires full control of the web-server. This requirement is met in case YetiForce is installed on VPS, dedicated server or local server. In the event that YetiForce resides on a shared web space or on a cloud, installation can only be carried out by the provider, as long as it allows it. In cloud case, a convenient alternative is the purchase of the extension by the provider who will make it available to all users.

 

Step 1: extension installation

PAD PDF Generators installs as a common YetiForce extension:

 

     1. access the backend in the section "Standard modules / Modules - Installation"

     2. click on "Install from file"

     3. select the extension zip

     4. follow the procedure

 

Step 2: packages installation via Composer

Composer must be installed and available on the web-server in order to install the PHP packages: mPDF library, wrapper for wkhtmltopdf and wrapper for Google Chrome.

 

To install via Composer you need to have installed on the web server:

 

Furthermore, you will be prompted to enter your personal token to access the repositories.

 

How to get a personal token on GitHub:

 

  1. 1.register at https://github.com/ 

  2. 2.access the page https://github.com/settings/tokens/new (re-enter the registration password) 

  3. 3.enter a token name (Notes) 

  4. 4.check the options 

  1. 5.generate the token (click Generate token) 

  2. 6.save the displayed token in a safe place - it will no longer be possible to view it again on GitHub - the alternative is to generate it again 

 

Access the web server via the terminal - important: for security reasons, do not run Composer as root - with the same user of the web-server or with a user who has read and write privileges in the YetiForce folders.

 

Case of access via terminal with the web-server user

Run the following commands

  1. 1.move to the YetiForce "vendor/pad/" folder with: cd vendor/pad/ 

  2. 2.install via Composer with: composer install 

  3. 3.wait for the installation to complete 

  4. 4.a new “vendor” folder will be created which will contain all the packages just installed 

 

Case of access via terminal with user different from that of the web-server (but with read and write permissions)

Run the following commands

  1. 1.move to the YetiForce "vendor/pad/" folder with: cd vendor/pad/ 

  2. 2.install via Composer with: composer install 

  3. 3.wait for the installation to complete 

  4. 4.a new “vendor” folder will be created which will contain all the packages just installed 

  5. 5.assign (via root user or sudo command) the owner/group of the new “vendor” folder and of all the files and folders contained therein (recursive), to the owner/group of the web-server. In other words, the user of the web-server must be able to read and write to all files and folders contained in the new "vendor" folder: just like in all YetiForce files and folders. 

 

Step 3: wkhtmltopdf installation

The wkhtmltopdf package installation is required if you want to use that generator in YetiForce. If you don't want to activate wkhtmltopdf in Yetiforce (but use other generators) you can skip this step.

 

Download wkhtmltopdf from https://wkhtmltopdf.org/downloads.html

Install according to the distribution of the web-server.

 

wkhtmltopdf is available for the following Linux distributions

 

 

Some Linux distributions include wkhtmltopdf package, among the packages available in the distribution itself.

The installation of the wkhtmltopdf package, included in the distribution, is not recommended because it often lacks some features. For example, the Debian 10 (Buster) distribution includes wkhtmltopdf, but does not have the header and footer feature of the PDF page.

Download from https://wkhtmltopdf.org/downloads.html and install the full version.

Step 4: Google Chrome installation

The Google Chrome package installation is required if you want to use that generator in YetiForce. If you don't want to activate Google Chrome in Yetiforce (but use other generators) you can skip this step.

 

In almost all distributions there is the Google Chrome package. If not present in the distribution, download and install Google Chrome from https://www.google.com/chrome/

 

Increase the security level of Google Chrome on the web server

It is possible to prevent Google Chrome to access to external sources, limiting access to local resources only. The limitation increases the level of security, while still allowing the use of the PAD PDF Generators extension.

 

  1. 1.create the folder
    /etc/opt/chrome/policies/managed/
     

  2. 2.create a file named URLAllowlist and insert the string
    {"URLAllowlist": []}
     

  3. 3.create a second file named URLBlocklist and insert the string
    {"URLBlocklist": [“*”]}
     

 

Migration from YetiForce 6.1 to YetiForce 6.2

Migration from YF6.1 to YF6.2 requires non-standard actions.

Unfortunately the migration package from YF6.1 to YF6.2 deletes all subfolders in /vendor, so also the folder /vendor/pad needed for the PAD PDF Generators plugin.

Refer to the PAD Extensions Manager manual for the actions required for a successful migration; paragraph “Migration from YetiForce 6.1 to YetiForce 6.2”.

Two cases are discussed below: if you have yet to migrate to YetiForce 6.2 or if you have already migrated to YetiForce 6.2.

 

I still have to migrate to YetiForce 6.2

  1. 1.make a backup of YetiForce: code folder (PHP) and database 

  2. 2.make a copy of the /vendor/pad folder and save it on your desktop 

  3. 3.proceed to migrate to YetiForce 6.2 

  4. 4.reload the /vendor/pad folder from your desktop 

  5. 5.download PAD PDF Generators 1.0.5 (from your private area on www.penguinable.com) and install it 

 

I have already migrated to YetiForce 6.2

If you have already migrated to YF 6.2, the /vendor/pad folder has been removed. In this case:

  1. 1.make a backup of YetiForce: code folder (PHP) and database 

  2. 2.download PAD PDF Generators 1.0.5 (from your private area on www.penguinable.com) and install it 

  3. 3.open a terminal 

  4. 4.go to the /vendor/pad folder 

  5. 5.run the command composer install 

 

Migration from YetiForce 6.4 to YetiForce 6.4

Migration from YF6.3 to YF6.4 requires non-standard actions.

Unfortunately the migration package from YF6.3 to YF6.4 deletes all subfolders in /vendor, so also the folder /vendor/pad needed for the PAD PDF Generators plugin.

Two cases are discussed below: if you have yet to migrate to YetiForce 6.4 or if you have already migrated to YetiForce 6.4.

 

I still have to migrate to YetiForce 6.4

  1. 6.make a backup of YetiForce: code folder (PHP) and database 

  2. 7.make a copy of the /vendor/pad folder and save it on your desktop 

  3. 8.proceed to migrate to YetiForce 6.4 

  4. 9.reload the /vendor/pad folder from your desktop 

  5. 10.download PAD PDF Generators 1.1.0 (from your private area on www.penguinable.com) and install it 

 

I have already migrated to YetiForce 6.4

If you have already migrated to YF 6.4, the /vendor/pad folder has been removed. In this case:

  1. 1.make a backup of YetiForce: code folder (PHP) and database 

  2. 2.download PAD PDF Generators 1.1.0 (from your private area on www.penguinable.com) and install it 

  3. 3.open a terminal 

  4. 4.go to the /vendor/pad folder 

  5. 5.run the command composer install 

 

What has changed in PAD PDF Generators for YetiForce 6.4

YetiForce 6.4 introduces the use of different PDF generators, exactly like PAD PDF Generators plugin introduced in March 2021. YetiForce 6.4 associates a specific PDF generator to the single PDF template. This makes it useless to select the generator during the export phase: for this reason the generator selection screen has been eliminated.

 

In addition, this new feature has made obsolete the use of a specific workflow task for sending PDFs created with alternative generators: you can use the built-in workflow task to send a PDF (Send PDF). These changes required a deep reengineering of the plugin and some changes in the generation specifications.

 

In this regard, before switching to the new version (1.1.0), it is advisable to carry out some checks to certify that the PDFs are correctly rendered. Specifically, it is recommended, on a test instance of YetiForce, to verify the correctness of the header, footer, watermark and margins.

 

Configuration

There are three PDF generators in PAD PDF Generators:

 

  1. 1.mPDF - Ian Back library 

  2. 2.Snappy - wkhtmltopdf wrapper 

  3. 3.Headless Chromium - Google Chrome wrapper 

 

 

You can only enable the generators you want to use: leave the unwanted ones disabled.

Let's see case by case.

 

YetiForcePDF - YetiForce library

 

This option is no longer available: "PAD PDF Generators" manages only additional generators: Google Chrome, Web Kit Html to PDF and mPDF.

 

mPDF (Ian Back library)

 

Generator: generator code

Name: name of the generator

Owner site: link to the owner/creator site

Owner GitHub: link to the generator/wrapper source code

Enabled: generator enable option. If not enabled it will not be available in the front-end and in the workflow task

Default: define the default generator proposed in the operational phase

CSS style file: allows you to associate a style (CSS) file for the graphic formatting of the PDF. Just below a text editor with indentation via TAB (4 characters)

PDF Template: PDF template to use for previewing

Source: entity to preview

Generate: opens the PDF preview pop-up

Installed: indicates whether the generator has been correctly installed

 

Snappy (wkhtmltopdf wrapper)

 

Generator: generator code

Name: name of the generator

Owner site: link to the owner/creator site

Owner GitHub: link to the generator/wrapper source code

Enabled: generator enable option. If not enabled it will not be available in the front-end and in the workflow task

Default: define the default generator proposed in the operational phase

Path to the executable (e.g. /usr/local/bin/execname): enter the path to the executable of the package wkhtmltopdf

CSS style file: allows you to associate a style (CSS) file for the graphic formatting of the PDF. Just below a text editor with indentation via TAB (4 characters)

PDF Template: PDF template to use for previewing

Source: entity to preview

Generate: opens the PDF preview pop-up

Installed: indicates whether the generator has been correctly installed

 

Headless Chromium (Google Chrome wrapper)

 

Generator: generator code

Name: name of the generator

Owner site: link to the owner/creator site

Owner GitHub: link to the generator/wrapper source code

Enabled: generator enable option. If not enabled it will not be available in the front-end and in the workflow task

Default: define the default generator proposed in the operational phase

Path to the executable (e.g. /usr/local/bin/execname): enter the path to the executable of the package Google Chrome

CSS style file: allows you to associate a style (CSS) file for the graphic formatting of the PDF. Just below a text editor with indentation via TAB (4 characters)

PDF Template: PDF template to use for previewing

Source: entity to preview

Generate: opens the PDF preview pop-up

Installed: indicates whether the generator has been correctly installed

 

Features, pros and cons

The following features are valid for all generators:

 

     • very light PDF files

     • reduced processing time

     • possibility to associate a CSS style file - does not affect the weight of the PDF file

     • (limited) style definition for the header with class name header-body

     • definition of page body style with class name page-body

     • (limited) style definition for the footer with class name footer-body

     • (limited) definition of watermark style with page-watermark class name (mPDF excluded)

 

mPDF (Ian Back library)

Features

fonts available:

 

 

Pros

 

Cons

 

Snappy (wkhtmltopdf wrapper)

 

Features

available fonts: all fonts installed on the web-server

 

configuration via style of the repetition, at each page change, of the header and footer of the table

thead {display: table-thead-group}

tfoot {display: table-tfoot-group}

 

configuration via style of the header only at the top and footer only at the bottom

thead {display: table-row-group}

tfoot {display: table-row-group}

 

definition of a wrapper for the watermark image

the "text watermark" can be used to create a wrapper for the image by inserting the ###WMIMAGE### marker

 

Pros

 

Cons

 

Headless Chromium (Google Chrome wrapper)

Features

available fonts: any imported font via CSS

@font-face {

    font-family: myFont;

    src: url ('/var/www/html/yetiforce/fonts/myFont.ttf');

}

 

repeating, at each page change, of the header and footer of the table configurable via style

thead {display: table-thead-group}

tfoot {display: table-tfoot-group}

 

header only at the top and footer only at the bottom configurable via style

thead {display: table-row-group}

tfoot {display: table-row-group}

 

wrapper definition for the watermark image

the "watermark text" can be used to create a wrapper for the image by inserting the ###WMIMAGE### marker

 

Pros

 

Cons

 

Styling examples

Different styles

A different style can be defined for each “piece” of the PDF template using the class name.

Let's take an example with the "piece" related to the logo:

 

<span class=”company-logo-standard”><img src=”...”></span>

 

In CSS file are defined types of style for the logo with

 

/* company-logo-standard definition */

.company-logo-standard {

     border: 1px solid red;

     ...

}

/* company-logo-modern definition */

.company-logo-modern {

     border: 3px solid green;

     ...

}

 

Style families

Each "piece" of the PDF template can be included in a "div" or "span" block with one o more style classes

 

<div class=”class-name”>here the template “piece”</div>

 

This feature allows to define, in the style file (CSS) associated to a PDF generator, multiple families of styles to be used in the PDF template.

Let's take an example with the logo "piece":

 

<span class=”company-logo”><img src=”...”></span>

 

In the PDF template the logo is nested in a block to define the style family

 

<div class=”family-style-modern”>

     

     <span class=”company-logo”><img src=”...”></span>

     ...

</div>

 

In the CSS file are defined the style families

/* family-style-standard definition */

.family-style-standard .company-logo {

     border: 1px solid red;

     ...

}

/* family-style-modern definition */

.family-style-modern .company-logo {

     border: 3px solid green;

     ...

}

 

Style families for the header and footer

Let's see how to define different style families for the header.

Since the header is included in a block with class "header-body" we define two families: standard and modern.

 

/* header standard definition */

.header-standard .header-body {

     font-size: 10px;

     color: #DDDDDD;

     text-decoration: italic;

     ...

}

...

/* header modern definition */

.header-modern .header-body {

     font-size: 8px;

     color: blue;

     font-weight: bold;

     ...

}

 

Same for footer styling: just replace “header-body” with “footer-body”.

 

Style families for the page

Different style families can also be defined for the page.

 

/* family style standard definition */

.family-standard .page-body {

     font-family: Courier;

     font-size: 12px;

     color: #444444;

     ...

}

.family-standard .company-logo {

     border: 0.5mm solid #222222;

     box-shadow: 5px 10px #888;

     ...

}

.family-standard thead,

.family-standard tfoot {

     display: table-row-group;

}

...

 

Watermark style families – mPDF excluded

In the case of watermark text, the style definition is identical as header, footer and page.

If the text watermark is

 

<span class=”wm-txt”>DRAFT</span>

 

the families are defined in the CSS style file

 

/* watermark text family style standard definition */

.wm-family-standard .wm-txt {

     ...

}

 

Style families can also be defined for watermark image, using the watermark text editor and the ###WMIMAGE### marker

 

  1. 1.define a watermark text with
    <span class=”wm-img”>###WMIMAGE###</span> 

  2. 2.switch to the watermark image 

  3. 3.select the image 

  4. 4.save 

 

in the CSS style file define families style

 

/* watermark image family style standard definition */

.wm-family-standard .wm-img {

     ...

}

 

Right to Left text

To insert text with RTL orientation it is necessary to define a dedicated css class:

 

.rtl-dir {

    direction: rtl;

}

 

in the PDF template, the text must be enclosed in a tag with class rtl-dir:

 

<span class = ”rtl-dir”> … here the text … </span>

 

Setting style families for PAD Textparser Products Table extension

The PAD Textparser Products Table extension allows you to create a table of Services and Products and tables with tax and discount summaries.

The tables have a graphic style defined during creation. The tables are then inserted into a PDF template or an email template.

With the PAD PDF Generators extension it is possible to increase the graphic control by using the various classes of the tables in the CSS files associated with the generator.

Let's see, in the two specific cases, the classes that can be used.

 

PADProductsTableSimple – lineitems tableProducts / Services

Tabella class name
products-table-simple

Table header class name

Tabel footer class name

Additional row class name

body table class name

 

PADProductsTableCursum – summary tableTax / Discount

Table class name

products-table-cursum

 

Currency class name

currency-label

currency-value

 

Discount in total class name

discountmode-label

discountmode-value

 

Discount summary class name

discountsummary-label

discountsummary-value

 

Tax mode class name

taxmode-label

taxmode-value

 

Tax summary class name

taxsummary-label

taxsummary-value

 

Printing examples in different languages

 
 

Workflow process for PDF sending

The extension adds a workflow task for sending PDFs.

NO LONGER AVAILABLE IN YF 6.4 USE THE BUILT-IN WORKFLOW TASK TO SEND PDFs

Task title: the description of the process
 

Select PDF template: the PDF template to send

SMTP: the SMTP to be used for sending

Select an email template to be send: the email template to send

Select email address: the recipients of the email sent

Verify if the recipient agreed to receive e-mails: if checked, send only if the recipient has granted the sending

PDF Engine: alternative enabled generators

 

Textparser function for barcode and qrcode

The extension adds a textparser function to include a barcode or qrcode in the PDF template.

The syntax is:

$(custom : PADBarcode||<field_name>|<barcode_code>|<width>|<height>|<color>|<show_value>)$

where:

<field_name>: name of the entity field

<barcode_code>: code of the barcode or qrcode

The available codes are:

Barcode 1D
C39: Code 39
C39+: Code 39 with checksum
C39E: Code 39 Extended
C39E+: Code 39 Extended with checksum
C93: Code 93
S25: Code 25 standard
S25+: Code 25 standard with checksum
I25: Code 25 interleaved
I25+: Code 25 interleaved with checksum
C128: Code 128
EAN2: EAN 2
EAN5: EAN 5
EAN8: EAN 8
EAN13: EAN 13
UPCA: UPC A
UPCE: UPC E
MSI: MSI
MSI+: MSI with checksum
POSTNET: Postnet
PLANET: Planet
RMS4CC: RM4SCC
KIX: KIX
IMB: IMB
CODABAR: Codabar
CODE11: Code 11
PHARMA: Pharmacode
PHARMA2T: Pharmacode 2-tracks

Barcode 2D
QRCODE: QR Code
PDF417: PDF417
DATAMATRIX: Data Matrix

<width>: integer (1, 2, 3, 4, ...) - the width of the single bar for 1D barcodes; the width of the barcode for 2D - default1D = 2, default2D = 3

<height>: integer (1, 2, 3, 4, ...) - the height of the barcode - default1D = 30, default2D = 3

<color>: in hexadecimal format (#FF0000) - the color of the barcode

<show_value>: boolean value (0, 1) - only for 1D barcode - displays the value under the barcode

Example: QRCODE of the 'text_area' field in red color

$(custom : PADBarcode||text_area|QRCODE| | |#FF0000)$

NB: leave white space between the pipe symbols ( | ) if value is not assigned. In the example width and height are not assigned.

 

 

Compatibility

Compatible with YetiForce ERP-CRM 6.4.x.

 

Dependencies

PAD Extensions Manager 1.2.x

 

Deprecated

No functionality or feature deprecated.

 

Known Issues

Migrating from YF6.1 to YF6.2 removes all folders in /vendor and therefore also the folder /vendor/pad. Please refer to the paragraph “Migrating from YetiForce 6.1 to YetiForce 6.2” for the correct procedure.

 

Migrating from YF6.3 to YF6.4 removes all folders in /vendor and therefore also the folder /vendor/pad. Please refer to the paragraph “Migrating from YetiForce 6.3 to YetiForce 6.4” for the correct procedure.

Changelog

1.2021-03-15: fixed responsivity problems

2.2021-03-15: added css editing

3.2021-03-15: added PDF preview

4.2021-03-15: added PDF function for barcode and qrcode

5.2021-03-15: fixed front-end PDF generation problem for non-admin users

6.2021-03-23: fixed image rendering issue

7.2021-03-29: removed javascript console.log()

8.2021-03-29: added activation check on correct installation

9.2021-04-15: fixed filename parsing

10.2021-04-15: fixed preview query

11.2022-12-19: PDF generators available in PDF templates

12.2022-12-19: eliminated generator choice screen during PDF export

13.2022-12-19: eliminated workflow task PADSendPDF: use the built-in one

14.2023-05-30: fixed classes references

 

Bug report

In the face of problems, the report must be made on www.penguinable.com.

In the same way, notification of any suggestions can be made.