Penguinable Guide PAD PDF Generators 1.1.1 User Guide Davide Alghi
|
|
|
PAD PDF Generators
1.1.1
User Guide
YetiForce ERP-CRM
Setting style families for PAD Textparser Products Table extension |
PADProductsTableSimple – lineitems table – Products / Services |
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.
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 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.
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
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:
•composer
•git
Furthermore, you will be prompted to enter your personal token to access the repositories.
How to get a personal token on GitHub:
1.register at https://github.com/
2.access the page https://github.com/settings/tokens/new (re-enter the registration password)
3.enter a token name (Notes)
4.check the options
◦repo
◦workflow
◦notifications
◦user
◦write: discussion
5.generate the token (click Generate token)
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.move to the YetiForce "vendor/pad/" folder with: cd vendor/pad/
2.install via Composer with: composer install
3.wait for the installation to complete
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.move to the YetiForce "vendor/pad/" folder with: cd vendor/pad/
2.install via Composer with: composer install
3.wait for the installation to complete
4.a new “vendor” folder will be created which will contain all the packages just installed
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.
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
•Debian
•Ubuntu
•CentoOS
•Amazon Linux
•openSuse Leap
•Arch Linux
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.
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.create the folder
/etc/opt/chrome/policies/managed/
2.create a file named URLAllowlist and insert the string
{"URLAllowlist": []}
3.create a second file named URLBlocklist and insert the string
{"URLBlocklist": [“*”]}
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.
1.make a backup of YetiForce: code folder (PHP) and database
2.make a copy of the /vendor/pad folder and save it on your desktop
3.proceed to migrate to YetiForce 6.2
4.reload the /vendor/pad folder from your desktop
5.download PAD PDF Generators 1.0.5 (from your private area on www.penguinable.com) and install it
If you have already migrated to YF 6.2, the /vendor/pad folder has been removed. In this case:
1.make a backup of YetiForce: code folder (PHP) and database
2.download PAD PDF Generators 1.0.5 (from your private area on www.penguinable.com) and install it
3.open a terminal
4.go to the /vendor/pad folder
5.run the command composer install
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.
6.make a backup of YetiForce: code folder (PHP) and database
7.make a copy of the /vendor/pad folder and save it on your desktop
8.proceed to migrate to YetiForce 6.4
9.reload the /vendor/pad folder from your desktop
10.download PAD PDF Generators 1.1.0 (from your private area on www.penguinable.com) and install it
If you have already migrated to YF 6.4, the /vendor/pad folder has been removed. In this case:
1.make a backup of YetiForce: code folder (PHP) and database
2.download PAD PDF Generators 1.1.0 (from your private area on www.penguinable.com) and install it
3.open a terminal
4.go to the /vendor/pad folder
5.run the command composer install
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.
There are three PDF generators in PAD PDF Generators:
1.mPDF - Ian Back library
2.Snappy - wkhtmltopdf wrapper
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.
This option is no longer available: "PAD PDF Generators" manages only additional generators: Google Chrome, Web Kit Html to PDF and mPDF.
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
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
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
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)
fonts available:
•Aboriginal Sans
•Abyssinica SIL
•Aegean
•Aegyptus
•Akkadian
•Ayar
•MPH 2B Damase
•Dai Banna SIL Book
•DejaVu Sans
•DejaVu Sans Mono
•DejaVu Serif
•Dhyana
•FreeMono
•FreeSans
•FreeSerif
•Garuda
•Jomolhari
•KaputaUnicode
•Khmer OS
•Lanna Alif
•Lateef
•Lohit Kannada
•ocrb10
•Padauk Book
•Pothana2000
•Quivira
•Sundanese Unicode
•Sun-ExtA
•Sun-ExtB
•Estrangelo Edessa
•Taamey David CLM
•Tai Heritage Pro
•TharLon
•UnBatang
•KFGQPC Uthman Taha Naskh
•XB Riyaz
•Zawgyi-One
•quality (1-10): 6
•similar to YetiForce engine
•text-only watermark
•the table header is always repeated at the page change: it cannot be managed
•blocks, such as table cells, with a lot of text do not print continuously, but jump to the next page
•blocks, such as table cells, with images do not print continuously, but jump to the next page
•inserts blank compensation lines if the image jumps to the next page
•problems with the style of nested elements
•the repetition of the table header at the page change is not optimal
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
•quality (1-10): 7.5
•good style rendering
•possibility to correct anomalies by style
•page number and total pages are not available in the page body
•metadata (creator, author, title, subject, keywords) not available
•blocks, such as table cells, with a lot of text do not print continuously, but jump to the next page
•blocks, such as table cells, with images are not printed continuously, but jump to the next page: the image is not cut
•inserts blank compensation lines if the image jumps to the next page
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
•quality (1-10): 9.5
•excellent style fidelity and print quality
•possibility to correct anomalies by style
•page number and total pages are not available in the body of the page and in the watermark
•font type not available in the header and footer
•metadata (creator, author, title, subject, keywords) not available
•blocks, such as table cells, with images are not printed continuously, but jump to the next page: the image is not cut
•some overlapping problems when the table footer is repeated at page change (this behavior can be disabled)
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;
...
}
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;
...
}
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”.
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;
}
...
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.define a watermark text with
<span class=”wm-img”>###WMIMAGE###</span>
2.switch to the watermark image
3.select the image
4.save
in the CSS style file define families style
/* watermark image family style standard definition */
.wm-family-standard .wm-img {
...
}
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>
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.
Tabella class name
products-table-simple
Table header class name
•header row
◦head-row
•header cell
◦headcol
◦col-<field name>
◦headcol-<even | odd>
◦headcol-<first | middle | last>
◦headcol-all
◦headcol-<field name>
◦headcol-<column number>
Tabel footer class name
•footer row
◦foot-row
•footer cell
◦footcol
◦col-<field name>
◦footcol-<even | odd>
◦footcol-<first | middle | last>
◦footcol-all
◦footcol-<field name>
◦footcol-<column number>
Additional row class name
•additional row
◦additional-row-<before | after>
•additional row cell
◦bodycol
◦bodyrow-<even | odd>
◦body-all-all
◦body-<row number>
body table class name
•row
◦body-row
•cell
◦bodycol
◦col-<field name>
◦bodyrow-<even | odd>
◦bodycol-<even | odd>
◦bodycol-<first | middle | last>
◦body-all-all
◦body-all-<field name>
◦body-all-<column number>
◦body-<row number>-all
◦body-<row number>-<nome campo>
◦body-<row number>-<column number>
Table class name
products-table-cursum
Currency class name
currency-label
currency-value
discountmode-label
discountmode-value
discountsummary-label
discountsummary-value
taxmode-label
taxmode-value
taxsummary-label
taxsummary-value
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
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
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.
Compatible with YetiForce ERP-CRM 6.4.x.
PAD Extensions Manager 1.2.x
No functionality or feature deprecated.
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.
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
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.