Content last modified Monday 6 March 2017
hop to #bottom
Categories:
Author:
Current version:
0.3
About It:
Get it:
Rate it:
  • Helpful?
  • 1 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

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

Original article
PDF version

Installation

The installation of this plugin is a little bit more complicated than the installation of other plugins. So here are the instructions:

  1. download the plugin and install and activate in the admin-panel
  2. 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.
  3. create a new style with the name _(mono)article_pdf_ and copy & paste the content of the file _(file)article_pdf.css_ into it
  4. 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
Article Request Count:
Keywords/tags:
Initially released:
24 Jan 06
Posted here:
24 Jan 2006
Article modified:
01 Nov 2006

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:

Your comment will NOT be submitted until you click the 'Submit' button on the next pageload.

Commented (12)

Chess:
Super! I have been wanting this plugin forever. However, I followed the directions precisely but the pdf’s are not being generated. The link is attempting to download the pdf, but the pdf does not exist in the /files directory.
Chess:
Works great now, thanks!! And thank you for adding the excerpt argument, too. Great plugin!
Grunhilde:
I get the following when trying to use this plugin:
Fatal error: Class ‘xhtml2pdf’ not found in /path/to/textpattern/lib/txplib_misc.php(459) : eval()’d code on line 106
Did you download xhtml2pdf.zip und put it in your webfolder as described in the readme?
Really strange, I installed it, but the pdf documents which are generated are blank, only with the name of the article in header.

Anybody can help me plz ?
Harsha Master:
I get the following when trying to use this plugin:
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.
@Radek: Have a look at the forum thread. I think at the moment you have to turn textile on to get pdf output. But I am working on this.
Its really strange, I have textile on, but its running on php5, and blank page still remain.
Hi,

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
Hi,

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.

Would you care to write a comment or visit the forum discussion?

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.
Published with Textpattern