Generate pdf from custom post type with custom meta fields? - Wordpress Solution
[Solved] - Generate pdf from custom post type with custom meta fields? - Wordpress Solution |
---|
Try following codes |
I use a custom post type (ansatte - meaning employees) to register/show the employees of a company (or actually, several daughter-companies of one company), and the single-ansatte.php shows the CV, contact-info and so on, for each individual employee.
I think I have tried all the different plugins available, but some doesn't seem to work, and the ones I have found that otherwise works, doesn't include the meta fields. Using some outside service to generate the pdf is not an option. Then I'll rather make the pdf's by hand and use a meta field for the link. Except from outside services and branded pdf's, almost any solution is acceptable.
As you see, I also have an option to download a vcard with the mail/phone++ of the employee, [[LINK href="http://www.wpquestions.com/question/show/id/2575"]]solved very nice, simple & elegant by John Cotton here[[/LINK]]. The ideal solution would be something similar to johns solution, where I can include the meta fields I want to and I can use some html and css to get a nice layout on the pdf.
I will need an example of working code since my php-skills really suck :)
Here is the code for the single-ansatte.php and the custom post type including the meta fields.
Please ask if there is any other info you need. If I get a good solution quickly, I'll also add a bonus.
single-ansatte.php
The code for the custom post type and the meta fields:
Solution - 1How about using [[LINK href="https://code.google.com/p/dompdf/"]]dompdf[[/LINK]] to convert your html to pdf? It has some caveats and it's a bit overhelming with large files, but i think it's perfect for the task you're asking Solution - 2Hi, If you still cannot get your pdf library to work. You may want to try using this FPDF library. http://www.fpdf.org/ You can download the whole library zip file that includes the demos. Just put the whole folder within your htdocs and navigate to the examples. All demos work out of the box. They got well documented manual online too. You can follow the demo codes to familiarize with how it works, before applying to your codes. Library is written in Object Oriented Programming. No additional PHP extension required. Thanks. Denzel |
Date: 2022-10-21 05:12:31 |
Category: Wordpress |