This question about Using an extension: Answered

GenPDFAddOn: How to do Pdf link in view.tmpl

Hello.

I have checked GenPDFAddOn support page and Foswiki site for answers already. Sorry if I missed the obvious. I am running Ubuntu lucid, Apache 2.x and Foswiki 1.0.9 all latest CPANs, etc.

1. I am trying to get a PDF button to appear next to Edit and Attach in the upper right of each topic. I am using the instructions from the GenPDFAddOn page:

To make it even easier for novice Foswiki users to use, you can add a link (like edit and attach) to view.tmpl to publish the current page (using the current topic as the document title). For example: \PDF\

In the $Foswiki::cfg{TemplateDir} the view.tmpl file does not have any html like the above.

So where does this go exactly?

Thanks STephen


Sorry for the long delay answering this - somehow I missed the question.

The actual template changes might vary depending on the version of PatternSkin currently installed, and or other skin settings. But here are some examples. Edit a file in the templates directory - for example "view.mypdf.tmpl". Here are the important pieces you might set:

(Note that all of the solutions must include the base view template or you'll get a "blank" screen.)

To add the [PDF] button on the top of the page, so it shows [Edit] [Attach] [PDF]

Create a new PDF button and add it to the top of the page, and also to the bottom bar on the page.

%TMPL:INCLUDE{view}%
%TMPL:DEF{"topicactionbuttons"}%%TMPL:P{"action_activatable_edit_or_create"}%%TMPL:P{"action_activatable_attach"}%%TMPL:P{"action_activatable_subscribe"}%%TMPL:P{"action_printable"}%%TMPL:P{"action_genpdf"}%%TMPL:P{"action_revisions"}%%TMPL:P{"action_backlinks_simple"}%%TMPL:P{"action_raw_or_view"}%%TMPL:P{"action_activatable_raw_edit"}%%TMPL:P{"activatable_more"}%%TMPL:END%
%TMPL:DEF{"action_genpdf"}%%TMPL:P{"genpdf"}%%TMPL:P{"sep"}%%TMPL:END%
%TMPL:DEF{"genpdf"}%<span><a href='%SCRIPTURLPATH{"genpdf"}%/%BASEWEB%/%BASETOPIC%?%QUERYSTRING%%REVARG%' rel='nofollow' %MAKETEXT{"title='PDF version of this topic' >&PDF"}%</a></span>%TMPL:END%

%TMPL:DEF{"top:toolbarbuttons"}%%TMPL:P{"activatable_edit_or_create"}%%TMPL:P{"activatable_attach"}%%TMPL:P{context="SubscribePluginEnabled" then="activatable_subscribe"}%%TMPL:P{"genpdf"}%%TMPL:END%

To activate, Set SKIN = mypdf,pattern, or include the URL Parameter ?skin=mypdf,pattern to test the results.

To add a Print PDF Icon to the famfamfam button bar

Define the button. (A suitable ICON is attached to this topic and will be included in a future GenPDFAddOn release. And then override the button bar.

%TMPL:INCLUDE{view}%
%TMPL:DEF{"top:toolbarbutton_genpdf"}%<span>
        <a href="%SCRIPTURL{"genpdf"}%/%WEB%/%TOPIC%?%QUERYSTRING%%REVARG%" title="%MAKETEXT{"PDF version of this topic"}%">
                <img alt="%MAKETEXT{"PDF version of this topic"}%" src="%PUBURL%/%SYSTEMWEB%/GenPDFAddOn/pdf-16.png" width="16" height="16" />
        </a></span>%TMPL:END%
%TMPL:DEF{"top:toolbarbuttons_inner"}%          %TMPL:P{
                        "top:toolbarbutton_edit"
                }%%TMPL:P{
                        "top:toolbarbutton_attach"
                }%%TMPL:P{
                        context="SubscribePluginEnabled" then="top:toolbarbutton_subscribe"
                }%%TMPL:P{
                        "top:toolbarbutton_rdiff"
                }%%TMPL:P{
                        "top:toolbarbutton_raw"
                }%%TMPL:P{
                        "top:toolbarbutton_create"
                }%%TMPL:P{
                        "top:toolbarbutton_print"
                }%%TMPL:P{
                        "top:toolbarbutton_genpdf"
                }%%TMPL:P{
                        "top:toolbarbutton_more"
                }% %TMPL:END%

To activate this solution, Set SKIN = mypdf,famfamfam,pattern, or include the URL Parameter ?skin=mypdf,famfamfam,pattern to test the results.

To replace the "Print" option on the bottom bar to make it print to a PDF file

%TMPL:INCLUDE{view}%
%TMPL:DEF{"nop:printable"}%<span>
<a href='%SCRIPTURLPATH{"genpdf"}%/%WEB%/%TOPIC%?skin=%TMPL:P{printskin}%;%QUERYPARAMSTRING%%REVARG%' rel='nofollow' %MAKETEXT{"title='Generate PDF version of this topic' accesskey='p'>Generate &PDF"}%</a>
</span>%TMPL:END%

To activate, Set SKIN = mypdf,pattern, or include the URL Parameter ?skin=mypdf,pattern to test the results.

The file templates/view.genpdf.tmpl is provided by the plugin as an example to "skin" the topic view to make the "print" link generate a PDF (The 3rd example above). Instead of editing that file, it's best to create your own template so future releases of the extension won't overwrite your changes.

-- GeorgeClark - 02 Aug 2011

  • 16x16 pdf gif:
    pdf-16.gif

  • 16x16 pdf png:
    pdf-16.png

QuestionForm edit

Subject Using an extension
Extension GenPDFAddOn
Version Foswiki 1.0.9
Status Answered
Related Topics
I Attachment Action Size Date Who Comment
pdf-16.gifgif pdf-16.gif manage 676 bytes 02 Aug 2011 - 00:25 GeorgeClark 16x16 pdf gif
pdf-16.pngpng pdf-16.png manage 799 bytes 02 Aug 2011 - 00:25 GeorgeClark 16x16 pdf png
Topic revision: r2 - 02 Aug 2011, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy