TorstenBergmann / WKHTML2PDF
About WKHTML2PDF
WKHTML2PDF for Pharo
Project info
The "WKHTML2PDF for Pharo" is a project to provide the possibility to use the WKHTML2PDF project from Pharo. It allows you to convert HTML into PDF documents.
With this tool you can provide easy portable printing for your Pharo based applications.
Project location
The project is located on STHub at http://smalltalkhub.com/#!/~TorstenBergmann/WKHTML2PDF/
License
WKHTML2PDF is licensed under MIT License.
Installation
Install WKHTML2PDF
Please check out http://wkhtmltopdf.org/ to install the necessary software on your machine. Note that the library/executable should be accessible to Pharo. Often it is enough by providing the binary files next to the Pharo VM executable.
Install in Pharo
You can access the project from the Pharo configuration browser. Just select "Tools" -> "Configuration Browser" from the world menu, enter "WKHTML2PDF" and install the stable version.
Alternatively to install the packages manually into your Pharo image just evaluate:
Gofer new
url: 'http://smalltalkhub.com/mc/TorstenBergmann/WKHTML2PDF/main';
package: 'ConfigurationOfWKHTML2PDF';
load.
((Smalltalk at: #ConfigurationOfWKHTML2PDF) project stableVersion) load.
If you need access to the SQLite3 database engine you need at a minimum the "WKHTML2PDF-Core" package which is loaded by the ConfigurationOfWKHTML2PDF class.
This package includes all necessary API to access the WKPDF engine.
Use in your own application
Selecting the engine
Initially you have to select the engine that you want to use. Either you want to use the WKHTML2PDF library or the executable.
HTML2PDFConverter useExecutable.
or
HTML2PDFConverter useLibrary.
The executable is the default.
Converting
Now you can convert an HTML file or an URL into a PDF document:
HTML2PDFConverter
convert: 'http://www.pharo.org'
toFile: 'pharo.pdf'
will convert the Pharo homepage to a pdf document.
Packages
- WKHTML2PDF-Core - the core package required to use the project
- WKHTML2PDF-Tests-Core - includes SUnit tests for the core project
Testing
The package comes with tests in the package WKHTML2PDF-Tests-Core. Just use the SUnit TestRunner to run them.
