You can now use Rotativa.io from PHP. We have developed a PHP helper class that you can download from here.
Using Rotativa.io you can achieve quicker PDF creation times since web page assets can be transferred to the API with a single call.
This PHP helper class is still in early stages of development but we are going to work to quickly put it on par with the features available with the .Net library.
Usage is very simple:
1: Instantiate a Rotativa.io object. You’ll need to sign up at Rotativa.io. After signing in you can get your ApiKey and choose for one of our 4 endpoints (Us West, Us East, Europe, Asia).
$rhq = new Htm2PdfApi(< YOUR ENDPOINT >, < YOUR APIKEY >);
2: Set options if needed
// use this if you want to set the file name the user will download $rhq->SetFilename('my-report.pdf'); // values can be 'Landscape' or 'Portrait' (default is 'Portrait') $rhq->SetPageOrientation('Landscape'); // values can be A4, B0, Letter etc $rhq->SetPageSize(...); // set the page width $rhq->SetPageWidth(...); // set the page height $rhq->SetPageHeight(...); // set the margins $rhq->SetPageMargins(....); // set other wkhtmltopdf switches // docs at http://wkhtmltopdf.org/usage/wkhtmltopdf.txt $rhq->SetCustomSwithes(...);
3: Load and/or build your html (no need to use absolute URL for images, css, fonts, etc …)
$html = '<html><body><h1>Report</h1><p><img src="/img/logo.png" /></p>...'; // or $html = file_get_contents('../pdf/report1.html'); // or build with your favorite template engine.
4: Get the user to download the PDF from a private and secure cloud URL
If you need different functionality or need to report a bug, please write an email to firstname.lastname@example.org
Any feedback is appreciated.