Download the PHP package eprofos/php-wkhtmltopdf without Composer
On this page you can find all versions of the php package eprofos/php-wkhtmltopdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eprofos/php-wkhtmltopdf
More information about eprofos/php-wkhtmltopdf
Files in eprofos/php-wkhtmltopdf
Package php-wkhtmltopdf
Short Description A PHP library for converting HTML to PDF using wkhtmltopdf with extensive customization options.
License MIT
Informations about the package php-wkhtmltopdf
PHP WKHtmlToPdf
A PHP library for converting HTML to PDF using the wkhtmltopdf
command-line tool with extensive customization options.
Installation
You can install the package via composer:
[!CAUTION] This package requires the
wkhtmltopdf
binary to be installed on your system. You can download it from the official website for your respective operating system.
Usage
Here's a basic example of how to use the library:
This will generate a PDF file named output.pdf
from the HTML content of https://example.com
, with the following options:
- Page size: A4
- Orientation: Portrait
- Grayscale: Enabled
- Zoom level: 75%
API Reference
The WKHtmlToPdf
class provides the following methods:
Constructor
The constructor accepts an optional $binary
parameter, which is the path to the wkhtmltopdf
binary. If not provided, the constructor will try to use the default paths (C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe
on Windows and /usr/local/bin/wkhtmltopdf
on other platforms).
Adding Pages
addPage()
adds a page to the PDF document. The$content
parameter can be either a URL or HTML content.addCover()
adds a cover page to the PDF document. The$content
parameter can be either a URL or HTML content.addToc()
adds a table of contents (TOC) page to the PDF document.
Setting Options
These methods allow you to set various options for the PDF generation process, such as headers, footers, margins, orientation, page size, zoom level, DPI, grayscale mode, and low-quality mode.
Generating the PDF
The generate()
method generates the PDF file with the specified output file path. It returns the output of the wkhtmltopdf
command.
License
This library is licensed under the MIT License. See the LICENSE file for more details.
Contributing
Contributions are welcome! Please submit pull requests or open issues to help improve this library.
Contact
If you experience bugs or want to request new features, please visit the issue tracker.