Jump to content

Recommended Posts

Just doing some research on Coverting HTML content quotes into PDF.

Allot of what I read and watched is pointing to using composer then a tool like dompdf.  For the guru's out there what would you recommend to turn a page like the below with a customers name quote number and 10 to 20 line items and then some totals into a pdf document. I eventually want to have some type of cron job run a task and email pdfs out.  Most quotes will be a single page but project quotes will go over to 2 pages. I don't really want to muck around installing composer but before I go too far down the garden path with this section I thought I'd get some feedback on the best way/path to go for php pdf generation for things like quotes and invoices.

Option 1. mPDF

Options 2. jsPDF

Options 3. Puppeteer

Option 4. Dompdf

This is basic example of the data to go on the quote.
image.thumb.png.e85ad0f12f15c71fa3c2063200963a9a.png

Link to comment
https://forums.phpfreaks.com/topic/327475-pdf-recommendations/
Share on other sites

What's the problem with installing composer?  Takes 2 seconds, and that is what PHP uses for dependency management and autoload building.  Every option you have is going to start with using composer, and not using it is going back to PHP development as it was done in the bad old days of copying entire library codebases into project directories and everything that was painful, error prone and annoying with PHP library use, as of 10+ years ago.

As for "best path" there really isn't one.  There are different technical approaches to the problem, that tend to have different requirements, gotchas and limitations.  You are best off doing a quick evaluation using the html docs you already have to explore the libraries.

One up and coming option you didn't mention is gotenberg: a sophisticated go based conversion engine that has a php api.  It has a lot going for it, but also has more moving parts. 

Here's the PHP Api that lets you talk to the Gotenberg server:  https://github.com/gotenberg/gotenberg-php

Puppeter (or rather the PHP api to it) takes a similar approach, in that it's a bridge to a headless browser used to render a page, which then allows you to save a pdf version.  The https://github.com/zoonru/puphpeteer library is still being maintained, but already it's a fork of the original. You also have more moving parts (depending on Node, and the rialto bridge to Node).

jspdf has similar issues, being a js library.

For the Pure PHP library options, I'd start with dompdf and see if that works for you.  Known limitations are the lack of support for flexbox or grid, so that might be a deal breaker. I probably wouldn't use mpdf, due to the age and lack of updates. It's a fork of fpdf. With that said, not unlike dompdf, if you constrain your html it might be fine for your use case, but the lack of updates is not a great sign.  Along those same lines, lots of people are still using Snappy https://github.com/KnpLabs/snappy particularly with Laravel or Symfony, since there are integrations for both of those, but it does depend on a https://wkhtmltopdf.org/ which is now a dead project, even though you can still get builds of it for most linux distros.

 

Link to comment
https://forums.phpfreaks.com/topic/327475-pdf-recommendations/#findComment-1653480
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.