wan_pdf
The plugin _(mono)wan_pdf_ generates PDF-versions of your articles. The output is a link to the PDF-file. The PDFs are not generated every time the article is called, but only when the title or the body has changed. For this plugin I used xhtml2pdf and ufpdf which are based on fpdf. All needed files can be found at the end of this article.
Attention: If you update from a version <= 0.2 please download xhtml2pdf.zip once again and delete all PDFs due to changes in the name scheme.
Example
Installation
The installation of this plugin is a little bit more complicated than the installation of other plugins. So here are the instructions:
- download the plugin and install and activate in the admin-panel
- download the file xhtml2pdf.zip and unzip it to your local harddrive. After that you copy the folder xhtml2pdf (and not only the content of this folder) into the folder /textpattern/lib/ via ftp.
- create a new style with the name _(mono)article_pdf_ and copy & paste the content of the file _(file)article_pdf.css_ into it
- create a new file category with the name _(mono)article_pdf_
Usage
Just put the tag <txp:wan_pdf /> somewhere in you article form and there will be placed a link to the PDF-version of this article. The following optional arguments are possible:
- class: CSS-class for the link (default: class=”“)
- name: Link-text (default: name=“This article as a pdf”)
- _(mono)show_body:_ show article body in PDF (“y” or “n”, default: show_body=“y”)
- _(mono)show_excerpt:_ show excerpt in PDF (“y” or“n”, default: show_excerpt=“y”)
- image: ID of an image that is linked instead of the text (like you can see on this page). If the argument is not set, the default text is used (default: image=”“)
- _(mono)file_category:_ file categrory the PDF will belong to (default: file_category=“article_pdf”)
- _(mono)pdf_css_class:_ CSS-class for PDF-creation (default: pdf_css_class=“article_pdf”)
- debug: only for testing. The XHTML- and CSS-file are not deleted (default: debug=“n”)
The last three arguments are only for advanced users who know what they do.
How it works
With every call of an article the plugin checks, if there exists a PDF with the current version of an article. If this is not the case, first a xhtml-document with this article is created. With the help of xhtml2pdf and the stylesheet article_pdf this xhtml-document is converted into a PDF document. It will be saved in the folder files/ and put into the database at file category “article_pdf”.
If the file is already existing, the only thing the plugin does ist output a link to it.
Customization (for advanced users)
Edit the stylesheet _(mono)article_pdf_ . Also a different stylesheet can be used via the optional argument pdf_css_class.
You can edit the header and the footer of the pdf in the file /textpattern/lib/xhtml2pdf/classes/x2fpdf.php in line 377 (functions header() and footer() ).
At default the PDFs are saved in the category article_pdf. If you want to save in in another category, you have to create it and use it with category=“new_category”.
Changelog
Version 0.3 (2006-02-22)
- Feature: Use an image for linking to the PDF instead of text
- Feature: Debug switch
- Bugfix: Uses updf instead of fpdf for (hopefully) complete unicode support
- Bugfix: New name scheme (articleid_urltitle.pdf)
- Bugfix: Images in the PDF should now work everywhere
Version 0.2 (2006-01-29):
- Feature: include body and/or excerpt optionally
- Feature: write PDF metadata (thanks to ChrisJ)
- Bugfix: new name scheme for PDFs (articleid_title.pdf) to distinguish between two articles with the same title
- Bugfix: some changen in xhtml2pdf.
Version 0.16 (2006-01-25):
- Bugfix: Forgot to add the class-argument to the link
Version 0.15 (2006-01-25):
- Bugfix: replace hardcoded directories with global vars (thanks to chriloi)
- Bugfix: UTF-8-support for umlauts (thanks to chriloi)
Version 0.1 (2006-01-24):
- first version









If there is a comment form at the Information URL, you may want to leave your comments/questions there or at the Forum thread for quicker feedback. Otherwise, comment away:
Commented (12)
Fatal error: Class ‘xhtml2pdf’ not found in /path/to/textpattern/lib/txplib_misc.php(459) : eval()’d code on line 106
Anybody can help me plz ?
Fatal error: Class ‘xhtml2pdf’ not found in /path/to/textpattern/lib/txplib_misc.php(459) : eval()’d code on line 106
— Grunhilde Feb 2, 2:15am #
—-
Problem : Your textpattern install directory is not in webroot.
Solution : From plugins > wan_pdf > edit
at line 106, you need to change X_PATH to point correct directory.
I would love to use this – I have downloaded the correct files – ftp’ed them and installed the plugin in textpattern.
I get the following when trying to access a page with the ‘wan tag’.
Any ideas were I’m going wrong, please?
tag_error -> Warning: wan_pdf(/home/sites/wrightplace.co.uk/public_html/textpattern/lib/xhtml2pdf/classes/x2fpdf.php): failed to open stream: No such file or directory on line 138
tag_error -> Warning: wan_pdf(): Failed opening ’/home/sites/wrightplace.co.uk/public_html/textpattern/lib/xhtml2pdf/classes/x2fpdf.php’ for inclusion (include_path=’.:/usr/share/pear’) on line 138
Fatal error: Cannot instantiate non-existent class: xhtml2pdf in /home/sites/wrightplace.co.uk/public_html/textpattern/lib/txplib_misc.php(459) : eval()’d code on line 141
Cheers!
Mike
Still struggling to get this to work – now get the following:
tag_error -> Warning: getimagesize(textpattern/lib/xhtml2pdf/images/57.jpg): failed to open stream: No such file or directory on line 215
tag_error -> Warning: getimagesize(textpattern/lib/xhtml2pdf/images/57.jpg): failed to open stream: No such file or directory on line 254
tag_error -> Warning: getimagesize(textpattern/lib/xhtml2pdf/images/57.jpg): failed to open stream: No such file or directory on line 901
tag_error -> Warning: getimagesize(textpattern/lib/xhtml2pdf/images/57.jpg): failed to open stream: No such file or directory on line 1515
FPDF error: Missing or incorrect image file: textpattern/lib/xhtml2pdf/images/57.jpg
Obviously, can’t find the articles images. Any suggestions, please?
Cheers!
Mike
I have this mistake
FPDF error: Missing or incorrect image file
anybody can help ?
Subscribe to this article's comments RSS feed. [ ? ] View Recent Comments across the site. Get a Gravatar.
Would you care to write a comment or visit the forum discussion?