Difference between revisions of "Html2pdf"

From OpenEMR Project Wiki
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
==OpenEMR 5.0.2 and above==
Html2pdf was removed. Now using mPDF.
==OpenEMR 5.0.1==
In process of removing this and migrating to mPDF.
==OpenEMR 4.2.2 to OpenEMR 5.0.0==
The html2pdf library and FPDI library was updated to support PHP7 per below steps:
1. Removing all old files
2. Downloading HTML2PDF 4.5.0 from:
:https://github.com/spipu/html2pdf/releases (composer package)
3. Running composer command "composer install"
4. Requiring "setasign/fpdi": "1.6.*" for latest FPDI package
5. Removing the examples directory from the html2pdf directory.
6. Modifying library/html2pdf/_class/myPdf.class.php so that HTML2PDF_myPdf extends FPDI instead of TCPDF.
:Note that FPDI extends TCPDF.
7. Modifying interface/patient_file/report/custom_report.php line # 52 to require html2pdf/vendor/autoload.php rather html2pdf.class.php
8. Passing two new parameters "unicode and encoding" to HTML2PDF constructor in interface/patient_file/report/custom_report.php on line 57 and 58 respectively
9. Modifying library/html2pdf/vendor/setasign/fpdi/fpdi_bridge.php class removing second parameter "false" of "class_exists" method because TCPDF is autoloading
10. Removed examples directory from the TCPDF package.
11. Modified HTML2PDF package with fix to support RTL languages.
:*(Note that this fix has been accepted into the development branch of html2pdf 4.5)
At this point the HTML2PDF(version 4.5.0) with TCPDF(version 6.2.12) and FPDI(version 1.6.1) is installed and working.
Here are the commits that did above steps:
:https://github.com/openemr/openemr/commit/09b37d7334a13d6724b02e302ec7af3885dc314d
:https://github.com/openemr/openemr/commit/5ef2c14518e75b4a849a8a9eceda8ea93bb3b3c5
:https://github.com/openemr/openemr/commit/770a9e84bf6d63e5e894993444181886a1e22c8f
:https://github.com/openemr/openemr/commit/6412a57d5dcc18258f228c0532a3f85940e645db
:https://github.com/openemr/openemr/commit/b2b976607f212b6babf5ce8f9339e7a9185813f4
<br>
==OpenEMR 4.2.1 and below==
HTML2PDF and FPDI are classes that allow PDFs to be created from existing HTML and existing PDF files, respectively. They are separate projects but were integrated for use with OpenEMR.  They are contained within OpenEMR's library/html2pdf directory, with the following steps used to put them there:
HTML2PDF and FPDI are classes that allow PDFs to be created from existing HTML and existing PDF files, respectively. They are separate projects but were integrated for use with OpenEMR.  They are contained within OpenEMR's library/html2pdf directory, with the following steps used to put them there:


Line 18: Line 63:


There's a CSS file style_pdf.css that can be tweaked to make the printout nicer.  This would be a good area for some additional work.
There's a CSS file style_pdf.css that can be tweaked to make the printout nicer.  This would be a good area for some additional work.
 
<br>
There is potential to use a newer 4.x version of HTML2PDF. Whereas 3.x bundles FPDF as its foundation for PDF manipulation, 4.x bundles TCPDF which is much larger and presumably more capable (and seems to have UTF8 support).  Currently 3.x seems more mature and is directly compatible with FPDI.  4.x will need some patching for FPDI compatibility.  The current plan is to wait a while before switching to 4.x.
 
:FUTURE PLAN
:*To support internationalization, plan to add a future version of html2pdf 4.x when it includes a more recent version of TCPDF that is compatible with FPDI.


[[Category:Developer Guide]]
[[Category:Developer Guide]]

Latest revision as of 23:23, 14 April 2019

OpenEMR 5.0.2 and above

Html2pdf was removed. Now using mPDF.

OpenEMR 5.0.1

In process of removing this and migrating to mPDF.

OpenEMR 4.2.2 to OpenEMR 5.0.0

The html2pdf library and FPDI library was updated to support PHP7 per below steps:

1. Removing all old files

2. Downloading HTML2PDF 4.5.0 from:

https://github.com/spipu/html2pdf/releases (composer package)

3. Running composer command "composer install"

4. Requiring "setasign/fpdi": "1.6.*" for latest FPDI package

5. Removing the examples directory from the html2pdf directory.

6. Modifying library/html2pdf/_class/myPdf.class.php so that HTML2PDF_myPdf extends FPDI instead of TCPDF.

Note that FPDI extends TCPDF.

7. Modifying interface/patient_file/report/custom_report.php line # 52 to require html2pdf/vendor/autoload.php rather html2pdf.class.php

8. Passing two new parameters "unicode and encoding" to HTML2PDF constructor in interface/patient_file/report/custom_report.php on line 57 and 58 respectively

9. Modifying library/html2pdf/vendor/setasign/fpdi/fpdi_bridge.php class removing second parameter "false" of "class_exists" method because TCPDF is autoloading

10. Removed examples directory from the TCPDF package.

11. Modified HTML2PDF package with fix to support RTL languages.

  • (Note that this fix has been accepted into the development branch of html2pdf 4.5)

At this point the HTML2PDF(version 4.5.0) with TCPDF(version 6.2.12) and FPDI(version 1.6.1) is installed and working.

Here are the commits that did above steps:

https://github.com/openemr/openemr/commit/09b37d7334a13d6724b02e302ec7af3885dc314d
https://github.com/openemr/openemr/commit/5ef2c14518e75b4a849a8a9eceda8ea93bb3b3c5
https://github.com/openemr/openemr/commit/770a9e84bf6d63e5e894993444181886a1e22c8f
https://github.com/openemr/openemr/commit/6412a57d5dcc18258f228c0532a3f85940e645db
https://github.com/openemr/openemr/commit/b2b976607f212b6babf5ce8f9339e7a9185813f4


OpenEMR 4.2.1 and below

HTML2PDF and FPDI are classes that allow PDFs to be created from existing HTML and existing PDF files, respectively. They are separate projects but were integrated for use with OpenEMR. They are contained within OpenEMR's library/html2pdf directory, with the following steps used to put them there:

1. Downloading HTML2PDF 3.31 from https://sourceforge.net/projects/html2fpdf/ and installing it as the library/html2pdf directory.

2. Downloading FPDI 1.4.2 and FPDF_TPL 1.2 from http://www.setasign.de/products/pdf-php-solutions/fpdi/downloads/ and installing them into the library/html2pdf/fpdi directory.

3. Removing the examples directory from the html2pdf directory.

4. Modifying library/html2pdf/fpdi/fpdf_tpl.php so that FPDF_TPL extends MyPDF instead of FPDF. Note that FPDI extends FPDF_TPL.

5. Modifying library/html2pdf/html2pdf.class.php to create its member pdf object as an instance of FPDI instead of MyPDF.

At this point the HTML2PDF class now includes the FPDI features.

Currently HTML2PDF is used for generating PDF versions of patient reports. ob_start() combined with ob_get_clean() captures the output that would otherwise be sent to the browser. When a PDF document is encountered or the end of script is reached, the HTML up to that point is captured and fed to HTML2PDF in this way.

Then for a PDF the features of the FPDI class (integrated into HTML2PDF) come into play, as it provides the ability to insert pages from an existing PDF file into the PDF that you are building. What's really nice is that the output PDF is built in a single pass, without having to use any temporary files or command line tools. It just works.

There's a CSS file style_pdf.css that can be tweaked to make the printout nicer. This would be a good area for some additional work.