Hello devs!
I need orientation regarding a specific topic. I need to find a way to generate custom PDFs files on the fly using WordPress. The content comes from a db query and these values have to be inserted within a custom template.
I’m currently using the TCPDF library with my own custom plugin, but I keep getting weird errors (“Headers already sent”, corrupted files that cant be read except by firefox, completely blank files).
Is there a plugin or library wich does NOT require composer to be used?
Just to clarify, I do NOT want to convert a post or page to PDF (unless this helps me with my task).
Thank you in advance!
[ad_2]
Are you trying to do this from inside WordPress? Do you only want the post content in the PDF, and not the header/footer?
You can definitely do this. A few years I wrote a plugin that added the ability to put /pdf at the end of a WooCommerce product URL and download a spec sheet for the product that was generated on the fly using a PDF template. Unfortunately I can’t find the code at the moment. 😩 I may have it on another hard drive. I’ll have to see if I can find it.
But, have confidence: you can definitely do it.
I think that issue means something is starting to communicate with the user’s browse before you try to generate/download the PDF. Since the PDF is a different mime type than an HTML page the process has to crap out. Have you tried googling “TCPDF headers already sent”?