• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item4915: Generate PDF of wrong page

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension GenPDFAddOn Normal Closed   n/a  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


I'm running TWiki via mod_perl. I sometimes experienced a weird behavior of bin/genpdf. It sometimes generated a PDF of a different page from specified.

I looked into the code and came up with the following patch to fix it. I made this patch against the Oct 23 2007 release, but should be applicable to prior versions.

--- lib/TWiki/Contrib/GenPDF.pm 2007-10-24 05:54:42.000000000 +0900
+++ lib/TWiki/Contrib/GenPDF.pm.patched 2007-10-31 09:27:06.000000000 +0900
@@ -67,7 +67,7 @@

 $| = 1; # Autoflush buffers

-our $query = new CGI;
+our $query;
 our %tree;
 our %prefs;

@@ -519,6 +519,11 @@

 sub viewPDF {

+   # initialize module wide variables
+   $query = new CGI;
+   %tree = ();
+   %prefs = ();
    # Initialize TWiki
    my $thePathInfo = $query->path_info();
    my $theRemoteUser = $query->remote_user();

In the original code, $query is initialized when it's loaded. Under mod_perl and other persistency methods, viewPDF() is invoked multiple times after GenPDF.pm is loaded. So the second and onward invocations of viewPDF() keep seeing the CGI instance of the first invocation. That led to the problem I experienced.

-- HideyoImazu - 31 Oct 2007

Summary Generate PDF of wrong page
ReportedBy TWiki:Main.RickMach

SVN Range TWiki-4.3.0, Fri, 12 Oct 2007, build 15261
AppliesTo Extension
Component GenPDFAddOn
Priority Normal
CurrentState Closed

Checkins TWikirev:15443 TWikirev:15469 TWikirev:15470
TargetRelease n/a

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r5 - 2007-11-05 - RickMach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback