Export your article to Adobe Acrobat PDF (via PHP script)!

MyEgo.cz

home foto blogy mywindows.cz kontakt

Export your article to Adobe Acrobat PDF (via PHP script)!

adobe

I’ve created a new plugin which allows a current article to be automatically exported into Adobe Acrobat PDF file format. This plugin is based on FPDF PHP class, from www.fpdf.org.

Main Features

The plugin can do the following:

  • display bold, italics, underline text.
  • display red and blue text.
  • understands and converts NP_FancyText plugin pseudo-text.
  • removes tags specific to NP_Poll plugin.
  • displays h1, h2, h3, h4 tags with appropriate font sizes and colors.
  • displays lists <li> with a proper list-style.
  • displays XHTML links as Adobe Acrobat links.
  • can embed pictures / images and/or link them!
  • displayes blockquote tags.
  • displayes <pre> and <code> tags with Courier font.
  • displays other text with Times New Roman font.
  • allows not to embed fonts into a PDF file, thus making them efficient, and very small.
  • displays ™, € and © characters.
  • supports iconv character conversions, if necessary.
  • creates a filename like this-is-a-title.pdf.
  • features automatic temporary files deletion after 60 minutes.
  • displays article name and URI in page header.
  • displays page number, and total number of pages in page footer.
  • creates a :banner: page with article name, article URI (hotlink), author name, creation date, and site URI.
  • allows to specify directory for creating temporary files (by default MEDIA_DIR/rsscache/). You have to issue chmod 777 command to this directory.

Usage

Usage of this plugin is very simple. Download all files provided, upload them to your FTP server, and add <%PDF%> in your detailed template (I’l write this one more time, in detailed template, not detailed skin!).

Download

Download at: NP_PDF.zip (240kB).

Want to export this article into a PDF?

You want to try PDF export right now? Click on [Exports] link just under the current article, and then on "You can [print] this article, [email] it, or export a [PDF]".

Local fonts

I have supplied fonts in Central Europen encoding (Windows-1250). These should be fine for the rest of Europe as well, which is using Windows-1252. If you are using ISO-8859-1, or ISO-8859-2, you can use iconv function built-in my plugin.

If you still need different fonts, you can create them from TTF (TrueType) fonts, by going step by step according to this manual (same as I did!).

Patch for non-XE installations

This patch (already included) is necessary for plugin to work in XE and non-XE Nucleus as well.

// patch for non-XE editions
if (!is_callable('fancyLink')){
  function fancyLink($id){
    global $CONF;
    return $CONF['IndexURL'].createItemLink($id);
  }
}

Komentáře

  1. 1 clinch 01.05.04, 07:05:10
    FB

    not all the webserver support PDF lib
    but still i like it!
    I'v collected it from you website.
    thx!
    ----clinch-from China

  2. 2 drcolossus 13.06.04, 09:06:06
    FB

    I'll get "FPDF error: Could not include font metric file"!
    Does it mean my Server doesn't support PDF lib?

  3. 3 Radek Hulán 13.06.04, 02:06:13
    FB

    [2] there are font metrics files under /nucleus /plugins /pdf /font directory. I guess you forgot to copy them to your server, or have paths set incorrectly.

  4. 4 snowcrash 14.11.05, 04:11:10
    FB

    Hello

    when I try testing the pdf creating on this page as you suggest, it creates a pdf ok, but some text (the main features section) is displayed incorrectly/garbled.
    I'm using acrobat 5.1.0

    thanks