view
script called genpdf
. genpdf
generates a PDF document using the htmldoc
tool from http://www.htmldoc.org/. genpdf
can generate a single topic, or a hierarchy of topics. Configuration options can control page headers and footers, and generation of cover pages.
See GenPDFAddOnDemo for a demonstration of some of the PDF generation capabilities.
genpdf
to front of the SKIN
setting. This will replace the PatternSkin 'Print Version' on the lower action bar with 'Generate PDF', eliminating the HTML printable view of the topic. Set SKIN=genpdf,pattern
(add ?skin=genpdf,pattern
to the end of the URL to test)
genpdf
for view
in the topic URL. (If using short URLs, insert /bin/genpdf/
prior to the Web name).
view.tmpl
to publish the current page (using the current topic as the document title). For example: <a href="%SCRIPTURLPATH%/genpdf%SCRIPTSUFFIX%/%WEB%/%TOPIC%?pdftitle=%TOPIC%">PDF</a>
* Set GENPDFLINK=<span style="margin:0 0 2em 5em; width:64px height:64px; text-align:center; float:right"> [[%SCRIPTURL{"genpdf"}%/%WEB%/%TOPIC%?%QUERYSTRING%][<img src="%PUBURL%/System/GenPDFAddOn/pdf-64.gif">]] </span>
[[%SCRIPTURL{genpdf}%/%WEB%/%TOPIC%][Printable]]
URL Variable | Foswiki Preference Variable | Default Value | Example | Explanation |
---|---|---|---|---|
pdfbanner | _BANNER | Foobar Documentation System | Used to override the banner of a title page. | |
pdftitle | _TITLE | Writing Foobars | ||
pdfsubtitle | _SUBTITLE | A short guide to creating foobar documents | ||
pdfheadertopic | _HEADERTOPIC | MyHeader | The name of a topic that defines headers and footers using <-- HEADER LEFT "foobar" --> syntax. See example | |
pdftitletopic | _TITLETOPIC | MyTitle | The name of a topic that defines the layout of the title page See example | |
pdftitledoc | _TITLEDOC | The name of an attachment if specified ,becomes the title page. Allows images - see htmldoc manual | ||
skin | _SKIN | pattern | nat | Default skin to use for PDF generation |
cover | _COVER | print.nat | Default cover to use for PDF generation | |
rev | rev=10 | Generate a PDF from a prior topic revision. This disables pdfrecursive |
||
pdfrecursive | _RECURSIVE | on | Include children of the base topic in the PDF | |
pdfformat | _FORMAT | pdf14 | pdf12 | HTMLDOC output format |
pdftoclevels | _TOCLEVELS | 5 | 3 | Number of levels to include in the PDF table of contents (use 0 to disable the generation of a table of contents). Note that HTMLDOC generates a table of contents based on HTML headers in the page. |
pdfpagesize | _PAGESIZE | a4 | letter | The page size for PDF output |
pdforientation | _ORIENTATION | portrait | landscape | The page orientation (e.g. landscape or portrait) |
pdfwidth | _WIDTH | 860 | 1060 | The pixel width of the browser (used to scale images--images wider than this will be truncated) |
pdfheadershift | _HEADERSHIFT | 0 | +3 | Shift all headers up or down (for negative values) by this amount (e.g. H1 would become H3 for a value of 2). Can also be set to auto to cause headers to shift according to the depth of recursive rendering |
pdfkeywords | _KEYWORDS | %FORMFIELD {"KeyWords"}% |
'foo, bar, baz, zip' | Used for PDF Keywords META info to help search engines |
pdfsubject | _SUBJECT | %FORMFIELD {"TopicHeadline"}% |
'Foobar document creation' | Used for PDF Subject META info to help search engines |
pdftoctitle | _TOCTITLE | Contents | See http://www.htmldoc.org/ Default is to use the htmldoc provided string "Table of Contents". Note that a current limitation is that strings containing embedded spaces are not passed correctly. | |
pdftocheader | _TOCHEADER | ... | l.. | See http://www.htmldoc.org/ |
pdftocfooter | _TOCFOOTER | ..i | .i. | See http://www.htmldoc.org/ |
pdfbodyfont | _BODYFONT | Specify font for body of document (Arial, Courier , Helvetica , Monospace , Sans , Serif , or Times |
||
pdfheadingfont | _HEADINGFONT | Specify font for headings of document (Arial, Courier , Helvetica , Monospace , Sans , Serif , or Times |
||
pdftextfont | _TEXTFONT | Specify font for all text in document (Arial, Courier , Helvetica , Monospace , Sans , Serif , or Times |
||
pdfheader | _HEADER | .1. | Specify content of header, see http://www.htmldoc.org | |
pdffooter | _FOOTER | .1. | Specify content of footer, see http://www.htmldoc.org | |
pdfheadfootfont | _HEADFOOTFONT | Helvetica-Bold | Font specification for headers and footers. | |
pdfheadfootsize | _HEADFOOTSIZE | 12 | Sets the size of the header and footer text in points (1 point = 1/72nd inch) | |
pdfbodyimage | _BODYIMAGE | ![]() |
The image that will appear tiled in the background of every page | |
pdflogoimage | _LOGOIMAGE | ![]() |
The logo that will appear in a header or footer if you specify 'l' in the string (see http://www.htmldoc.org) | |
pdfnumberedtoc | _NUMBEREDTOC | True | Option flag for getting numbered headings and Table of Contents. Set it to anything for true. | |
pdfduplex | _DUPLEX | True | Option flag to set up the document for duplex printing. Headers and footers will swap position on alternating pages. Set it to anything for true. | |
pdfpermissions | _PERMISSIONS | print,no-copy | PDF Security permissions to disable print/copy etc. By default the PDF is not protected. | |
pdfmargins | _MARGINS | top:0.5in, bottom:2.5cm, left:12pt, right:15mm |
Specify the page margins (white space to edge of page) | |
pdfbodycolor | _BODYCOLOR | #CCff99 | Specify the background colour of all pages | |
pdfstruct | _STRUCT | book | webpage | use book for structured topics, i.e. when rendering a bunch of topics recursively; use webpage when printing a topic without a specific heading structure, i.e. if it is just a normal webpage or if it has got a special VIEW_TEMPLATE |
pdfcopyright | _COPYRIGHT | %WEBCOPYRIGHT% | Copyright 2009 | Should PDF Metadata include the Foswiki %WEBCOPYRIGHT% or another value. If set to 0, copyright is excluded. If set to any other string, the string is included in the metadata. Htmldoc has a bug and appends the copyright to the author metadata, which can break some document management systems that depend on the metadata. Set to 0 to exclude the copyright from the PDF metadata. |
pdfdebug | _DEBUG | 0 | 1 | Include debug messages and don't clean up temporary files after execution |
pdffirstpage | _FIRSTPAGE | toc | First page viewer will open: toc table of contents; p1 first page; c1 first chapter. |
|
pdfdestination | _DESTINATION | view | Output to browser window or save-as prompt | |
pdfpagelayout | _PAGELAYOUT | single | View's initial presentation layout: single , one , twoleft , tworight |
|
pdfpagemode | _PAGEMODE | outline | Viewer's initial presentation mode: outline , document , fullscreen |
|
pdfcompress | _COMPRESS | 9 | Set compression level of the document. 1=minimum, 9=maximum, none to disable compression |
|
pdfjpegquality | _JPEGQUALITY | 80 | Set JPEG image quality. Lower quality is higher compression. Set to none to disable JPEG image compression |
<!-- PDFSTART -->
to mark the starting point in the topic for PDF generation.
<!-- PDFSTOP -->
to mark the stopping point in the topic for PDF generation.
raw
mode or edit it, you'll see an example of multiple PDFSTART/PDFSTOP sections to exclude the Foswiki table of contents). If no PDFSTART/PDFSTOP comment pair appears in the topic, the entire topic text is used. In general, this should not be a problem except for title topics that include forms as the form meta-data will show up in a fairly illegible manner at the end of the document. Therefore, for topics that reference forms, a PDFSTART comment should be placed at the beginning of the topic and a PDFSTOP should be placed at the end.
genpdf
script will perform variable substition for the %GENPDFADDON _BANNER%, %GENPDFADDON _TITLE%, and %GENPDFADDON _SUBTITLE% variables as it does for the title page. Finally, the PDFSTART and PDFSTOP HTML comments should be placed at the beginning and end of header/footer topic. An example header/footer page can be found at GenPDFExampleHeaderFooterTopic?.
Note that HTMLDOC will not generate a page header on any page generated by a Level 1 header (---+ header). This is a known issue in htmldoc through version 1.27. A patch is provided further on in this page.
pdfheadershift
option is set to auto
, then the first header in each topic will be set to the absolute depth of the child topic in the tree. In this case the PDF will consist of only a single chapter.
<!-- TOC PROMOTE -->
anywhere in the topic. Wiki Structure | Default Rendering | pdfheadershift=auto |
pdfheadershift=auto <!-- TOC PROMOTE --> in SecondChild |
ParentTopic - FirstChild - GrandChildOne - GrandChildTwo - SecondChild - GrandChildThree - ThirdChild |
1 ParentTopic 2 FirstChild 3 GrandChildOne 4 GrandChildTwo 5 SecondChild 6 GrandChildThree 7 ThirdChild |
1 ParentTopic 1.1 FirstChild 1.1.1 GrandChildOne 1.1.2 GrandChildTwo 1.2 SecondChild 1.2.1 GrandChildThree 1.3 ThirdChild |
1 ParentTopic 1.1 FirstChild 1.1.1 GrandChildOne 1.1.2 GrandChildTwo 1.2 ThirdChild 2 SecondChild 2.1 GrandChildThree |
rev=xx
parameter on the URL in the same format that you would view an older topic revision.
GENPDFADDON_*
will be taken from the curent version and not from the requested topic revision.
'pdftoclevels=0'
as a URL parameter.
book
requires that headings be present in the topic. Try setting pdfstruct=webpage
pdftoclevel=0
in the view.genpdf.tmpl
file has been removed. An alternative approach is to set GENPDFADDON_TOCLEVELS=0
in SitePreferences
lib/Foswiki/Contrib/GenPDF.pm
to lib/Foswiki/Contrib/GenPDFAddOn.pm
A shim version of GenPDF.pm is shipped so that existing configurations will still work without requiring any configuration changes to =lib/LocalSite.cfg
bin/configure
script - Extensions tab, click "Find Extensions", locate GenPDFAddOn in the table and click "Install"
bin/configure
script, visit the GenPDFAddOn settings and optionally set the path to the htmldoc
command. If this is not set, the plugin will look for htmldoc
in the default path. bin/configure
in order to set the required hidden Switchboard entry even if you have not changed any settings!
bin/genpdf
script and update the "shebang" #!/bin/perl
to match your system perl location #!C:\strawberry\perl\bin\perl.exe
genpdf
to the list of restricted scripts in the apache configuration.
tgz
or zip
file and the GenPDFAddOn_installer
file from the Add-on Home (see below)
perl GenPDFAddOn _installer
) or unzip GenPDFAddOn.zip
in your Foswiki installation directory
chown nobody genpdf
) if needed.
chmod 755 genpdf
).
$Foswiki::cfg{Extensions}{GenPDFAddOn}{htmldocCmd} = "/path/to/htmldoc";
using configure
(in the Extensions
section) LocalSite.cfg
file
File: | Description: |
---|---|
bin/genpdf |
|
data/System/GenPDFAddOn.txt |
Add-on topic |
data/System/GenPDFAddOnPlugin.txt |
Helper plugin topic |
data/System/VarGENPDF.txt |
Defines GENPDF macro |
data/Sandbox/GenPDFAddOnDemo.txt |
Demonstration topic |
data/Sandbox/GenPDFAddOnDemoChild.txt |
Demo child for recursive rendering |
data/Sandbox/GenPDFAddOnDemoChild2.txt |
Demo child for recursive rendering |
data/Sandbox/GenPDFAddOnDemoForm.txt |
Document classification form |
data/Sandbox/GenPDFExampleHeaderFooterTopic.txt |
|
data/Sandbox/GenPDFExampleTitleTopic.txt |
|
pub/System/GenPDFAddOn/pdf-32.gif |
|
pub/System/GenPDFAddOn/pdf-32.png |
|
pub/System/GenPDFAddOn/pdf-64.gif |
|
pub/System/GenPDFAddOn/pdf-64.png |
|
htmldoc_force_header.patch |
|
lib/Foswiki/Contrib/GenPDF.pm |
Shim module to avoid breaking old installations |
lib/Foswiki/Contrib/GenPDFAddOn.pm |
Renamed GenPDF?.pm to packaging standards |
lib/Foswiki/Contrib/GenPDFAddOn/Config.spec |
|
lib/Foswiki/Plugins/GenPDFAddOnPlugin.pm |
|
templates/view.genpdf.tmpl |
$Foswiki::cfg{Extensions}{GenPDFPlugin}{htmldocCmd} = '/usr/bin/htmldoc'; $Foswiki::cfg{SwitchBoard}{genpdf} = { 'function' => 'viewPDF', 'context' => { 'view' => 1 'static' => 1 }, 'package' => 'Foswiki::Contrib::GenPDF' };
Conversion failed: 'Inappropriate ioctl for device' at /var/www/Foswiki/lib/Foswiki/Contrib/GenPDF.pm line XXX
*** htmldoc-1.8.24/htmldoc/ps-pdf.cxx Sat Oct 30 05:53:59 2004 --- htmldoc-1.8.24/htmldoc/ps-pdf_force_header.cxx Tue Jun 13 02:12:28 2005 *************** *** 1465,1471 **** pspdf_prepare_heading(page, print_page, pages[page].header, top, page_text, sizeof(page_text), ! page > chapter_starts[chapter] || OutputType != OUTPUT_BOOK); pspdf_prepare_heading(page, print_page, pages[page].footer, 0, page_text, sizeof(page_text)); --- 1465,1472 ---- pspdf_prepare_heading(page, print_page, pages[page].header, top, page_text, sizeof(page_text), ! /* page > chapter_starts[chapter] || */ ! 1 || /* force heading onto chapter front page */ OutputType != OUTPUT_BOOK); pspdf_prepare_heading(page, print_page, pages[page].footer, 0, page_text, sizeof(page_text));
Add-on Author: | Foswiki:Main/BrianSpinar, Foswiki:Main/WadeTurland, Foswiki:Main/GeorgeClark | ||||||||||||||||||
Copyright: | © 2009, Foswiki Contributors | ||||||||||||||||||
License: | GPL (GNU General Public License) | ||||||||||||||||||
Release: | 1.2 | ||||||||||||||||||
Version: | 7410 (2010-05-14) | ||||||||||||||||||
Change History: | |||||||||||||||||||
14 May 2010 | Release 1.2 Foswikitask:Item9008 - Remove the X-Foswiki headers from the response. | ||||||||||||||||||
9 Mar 2010 | Release 1.1 Foswikitask:Item8586 - resolve packaging issue, Foswikitask:8575 - Add a "static" context to allow other plugins to recognize pdf output, Foswikitask:Item8691: Add support for heading and body fonts | ||||||||||||||||||
6 Feb 2010 | Foswikitask:Item559 - Correct handing of embedded images, Foswikitask:Item1599 - Improve compatibility with EditTable?, Foswikitask:Item2084 - Add support of topic revisions, Foswikitask:Item2435 - Correct DEPENDENCIES file, Foswikitask:Item2492 - support configurable image compression, Foswikitask:Item2592 - Correct issues with Examples, and handling of missing images, Foswikitask:Item2604 - Improve handling of TOC for recursive rendering, Foswikitask:Item8081 - Support passing %MACROS% in GENPDF settings, Foswikitask:Item8090 - Remove pdftoclevels from view.genpdf.tmpl, Foswikitask:Item8361 - Add support for TOC Title, and improve handling of HTML arrows. Foswikitask:Item1174 - Initial release of GenPDFPlugin helper | ||||||||||||||||||
28 Feb 2009 | Added missing Config.spec file Item1161: GenPDFAddOn result in "Not Found" page | ||||||||||||||||||
Feb 2009 | Conversion to Foswiki. Better <a and <img tag handling. Rewrote attachment handling to use Func:: API Rewrote recursive mode to use %SEARCH | ||||||||||||||||||
24 Dec 2008 | Added FIRSTPAGE, DESTINATION, TITLEDOC, PAGELAYOUT & PAGEMODE. fixed tag rendering, again. Now accepts either quote. Incorporated body extraction patch; made it work for title pages. removed outdated comment from example title page. Limited testing; use previous version if that makes you nervous. -- Foswiki:Main/TimotheLitt | ||||||||||||||||||
02 Jul 2008 | added support for VIEW_TEMPLATE and COVER ; fixed rendering of anchor and img tags; added pdfstruct parameter to print unstructured webpages as well; Foswiki:Main.MichaelDaum |
||||||||||||||||||
25 Jun 2008 | added template activation and Configure script spec file Foswiki:Main.SvenDowideit |
||||||||||||||||||
25 Jun 2008 | security and Foswiki 4.2 fixes Foswiki:Main.SvenDowideit | ||||||||||||||||||
2 Nov 2007 | Added new header and footer control (Bugs:Item4916) and fixed generation of wrong Foswiki page (Bugs:Item4915) | ||||||||||||||||||
23 Oct 2007 | Fixed Bugs:Item4452 & Bugs:Item4885, compatibility with Perl 5.6 and missing images with SSL certificates | ||||||||||||||||||
31 Aug 2007 | Fixed Bugs:Item4530, improper rendering of lists | ||||||||||||||||||
13196 | Removed nop tags before sending to htmldoc, fixed Bugs:Item3549 |
||||||||||||||||||
11673 | Foswiki:Main/RickMach updated MIME type to pdf from x-pdf, fixed bug preventing disabling the TOC | ||||||||||||||||||
9716 | Foswiki:Main/CrawfordCurrie added content-disposition header to files, so they download using a sensible file name | ||||||||||||||||||
9683 | Foswiki:Main/CrawfordCurrie updated for Foswiki-4 | ||||||||||||||||||
Version 0.6 (28 Jun 2005) |
|
||||||||||||||||||
Version 0.5 (16 Jun 2005) |
|
||||||||||||||||||
Version 0.4 (13 Jun 2005) |
|
||||||||||||||||||
Version 0.3 (12 Apr 2005) |
|
||||||||||||||||||
Version 0.2 (26 Mar 2005) |
|
||||||||||||||||||
Version 0.1 (30 Jan 2005) |
|
||||||||||||||||||
Home: | http://foswiki.org/Extensions/GenPDFAddOn | ||||||||||||||||||
Support: | http://foswiki.org/Support/GenPDFAddOn | ||||||||||||||||||
Dependencies: |
|
![]() |
pdf-32.gif (0.31K)
32x32 GIF Logo
version 1 uploaded by ProjectContributor on 09 Jan 2010 - 02:29
|
![]() |
pdf-32.png (0.79K)
32x32 PNG Logo
version 1 uploaded by ProjectContributor on 09 Jan 2010 - 02:29
|
![]() |
pdf-64.gif (3.00K)
64x64 GIF Logo
version 1 uploaded by ProjectContributor on 09 Jan 2010 - 02:29
|
![]() |
pdf-64.png (5.30K)
64x64 PNG Logo
version 1 uploaded by ProjectContributor on 09 Jan 2010 - 02:30
|