0

I have a custom post type set up using CMB2.

I have overriden the standard print template, so when a user wants to print the page it takes the CMB2 fields and organizes them into a specific layout using HTML.

However, instead of it just opening a new window for the user to print. I want it to open a PDF of the HTML in a new tab to try and avoid user error.

Anyone have some good options out there?

  • Note that plugin recommendations are offtopic here, I've removed the plugins tag, but any answer you get will be technical/code based rather than a product or recommendation – Tom J Nowell May 26 at 21:09
  • I found a GREAT open source project call domPDF. It does take some work to get things set-up, however, it has been a lifesaver! github.com/dompdf/dompdf – Michael Jul 3 at 18:48
0

You may want to try a few PDF generation plugins out there. I did some quick Googling and found https://wordpress.org/plugins/wp-pdf-generator/ (but I would recommend searching for others). Once installed, you can directly link your users to the "generate pdf" link instead of the Custom Post Type permalink, generating the PDF automatically for them.

You can also run some custom code to generate the PDF. I've used https://github.com/tecnickcom/TCPDF and it works well, but this is a code-heavy solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.