Is it potentially the html causing the left margin to come in more than the right?
wrote on 2018-10-12:
Margins are applied to all pages. A cover page with no margins can be achieved by few ways:
Solution 1. The easiest way is to run 2 phases - convert HTML to PDF and afterwards join a cover page with the PDF.
Sample: // create the API clients $html_to_pdf_client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); $pdf_to_pdf_client = new \Pdfcrowd\PdfToPdfClient("your_username", "your_apikey");
// run the conversion for a cover page $cover = $html_to_pdf_client->convertFile("conver.html"); $pdf_to_pdf_client->addPdfRawData($cover); // if it's always the same, you can create it just once and use a local file $pdf_to_pdf_client->addPdfFile('/home/my_cover_page.pdf');
// run the conversion for a content of document $document = $html_to_pdf_client->convertFile("document.html"); $pdf_to_pdf_client->addPdfRawData($document);
// join cover page and document $pdf_to_pdf_client->convertToFile("final.pdf");
Solution 2: Let's say that your final PDF has maximum 10 pages. Let your document HTML to have 1st page empty (e.g. with CSS page break rules). Create a cover page PDF with 1 cover page and 9 empty pages (e.g. with <div style='height: 7000'>). Use the PDF with setMultipageWatermark($coverPdf).
Solution 3: Quite complicated solution is to update your HTML to define margins inside (e.g. with fixed positions or dummy HTML elements) and use $client->setNoMargins(true)
I'd prefer 1st solution because it's the most flexible and can combine any type of PDFs.
Please feel free to contact us for further assistance.