I was able to convert the HTML page into PDF document documents. Now I am adding a download for the PDF files to be included in the data of this document. I am looking to find a better way to do this, and have not found anything that works correctly. Here are the specifics:
- HTML is half a page, and a downloaded PDF file should be added starting from this page.
- If the PDF file is longer than half the page, it continues on to the second (without a page break between the HTML content and the PDF content).
- Multi-page PDF files are fully included (if I have a good solution, I can understand this part).
I tried several different approaches, each with its own flaws:
- Convert PDF to HTML and combine with original HTML. Tons of formatting questions. If the client supports formatting simply, this is not a problem (but we all know that this will not happen).
- Just add the PDF to the PDF file. Starts adding on page 2, not page 1.
- Drop PDF to image and place image tag in HTML. The most pleasant results, but it requires trimming spaces and presses for more than half a page for a second.
I am using DOMPDF to convert HTML to PDF. I tried PDFLib, FPDI, and ImageMagick / GhostScript (image conversion). Maybe it's a shot in the dark, but does anyone know a better way?
source share