Question
I attempted to install the
GenPDFAddOn and it does not appear to work.
If I click the "this page" test PDF generation link that is located in the
GenPDFAddOn topic, the progress bar at the bottom of Internet Explorer begins moving, but only makes it about 1/3 of the way. Otherwise, the topic remains on the screen as though I didn't do anything. Nothing is written to the Apache error log. After 10 minutes or so, I just click the Stop button in Internet Explorer to kill the process (I'm not even sure anything is happening).
Here are some potential issues:
- HTMLDOC
- Installed Version 1.8.24
- Does it matter that I installed the binary version?
- I installed the trial version of HTMLDOC; does the GenPDFAddOn work with the trial version?
- Installation Location: I installed HTMLDOC under
C:/HTMLDOC.
- /lib/TWiki.cfg
- I inserted the following line just below the
$fgrepCmd line: $htmldocCmd = "c:/HTMLDOC/htmldoc.exe";
- No other changes were made to
TWiki.cfg.
- I can launch HTMLDOC independently from TWiki and generate PDF files (using the HTMLDOC user interface); this tells me that something in TWiki is not configured correctly.
- /twiki/bin/genpdf
- I set the perl path to
#!c:/cygwin/bin/perl -w
- No other changes were made to this file.
- File::Temp
- I verified that this CPAN dependency is installed and up to date.
Environment
--
JasonVensel - 16 Feb 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
I would greatly appreciate it if users who are successfully running the
GenPDFAddOn could describe their installation of it (that is, TWiki version, HTMLDOC version, etc.). If I could see some of the details of an actual running installation I can eliminate aspects of my installation that might be incorrect.
--
JasonVensel - 27 Feb 2006
Anyone? Please!!!
--
JasonVensel - 01 Mar 2006
Is anyone successfully running the
GenPDFAddOn with Cairo?
--
JasonVensel - 06 Mar 2006
I'm running it successfully on cairo --- on linux. Although the AddOn states it should run on AnyOS, it is possible you may have to tweak a few things to get it running on WinXP. For example, check out the 05 Mar 2006 entry on the
LatexModePluginDev.
--
ScottHoge - 06 Mar 2006
Scott, thanks for the suggestion but I've looked at and tried everything I can think of and have now reached the limits of my capabilities. I'm a technical writer with a degree in English, not computer science. This is one of three things left that I'm trying to configure in TWiki before turning it over to our company and all three are taking more time to configure than they should. Needless to say, I'm extremely frustrated.
Here are my problems
- I don't know whether the trial version of HTMLDOC works with this add-on.
- Nothing happens when I click the "Generate PDF" link (other than the Opening page...progress bar appears and VERY slowly begins to show progress; though it NEVER completes.); IE eventually times out with the standard "The page cannot be displayed" error message. I've tried each of the following 3 strings for my links and they all exhibit the exact same behavior:
<a href="%SCRIPTURLPATH%/genpdf%SCRIPTSUFFIX%/%WEB%/%TOPIC%?pdftitle=%TOPIC%">PDF</a>
[[%SCRIPTURL%/genpdf/%WEB%/%TOPIC%?skin=print][Printable]]
[[%SCRIPTURL%/genpdf/%WEB%/%TOPIC%][Generate this page as a PDF]]
- Not a single message (error or otherwise) appears in
c:/apache/logs/error.log when I click the "Generate PDF" link.
c:/twiki/bin/genpdf Configuration
# Copyright (C) 1999 Peter Thoeny, peter@thoeny.com
# Additional mess by Patrick Ohl - Biomax Bioinformatics AG
# January 2003
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html
BEGIN {
# Set default current working directory (needed for mod_perl)
if( $ENV{"SCRIPT_FILENAME"} && $ENV{"SCRIPT_FILENAME"} =~ /^(.+)\/[^\/]+$/ ) {
chdir $1;
}
# Set library paths in @INC, at compile time
unshift @INC, '.';
require 'setlib.cfg';
}
use strict;
use TWiki::Contrib::GenPDF;
TWiki::Contrib::GenPDF::viewPDF();
c:/twiki/lib/TWiki.cfg Configuration
All I did for this was insert the last two lines that pertain to HTMLDoc:
#
# NOTE: You might want to avoid c: at start of cygwin unix command for
# Windows, seems to cause a problem with pipe used in search
# Unix ls command : (deprecated since 01 Nov 2003)
$lsCmd = "/bin/ls";
# Unix egrep command :
$egrepCmd = "/bin/egrep -E";
# Unix fgrep command :
$fgrepCmd = "/bin/fgrep -F";
# HTMLDOC location
$htmldocCmd = "c:/HTMLDOC/htmldoc.exe";
c:/twiki/lib/TWiki/Contrib/GenPDF.pm Configuration
The only thing I modified from this file is the first line for the perl path (I did not include the rest of the file since it consists of 644 lines):
#!/usr/local/bin/perl -wI.
#
# GenPDF.pm (converts TWiki page to PDF using HTMLDOC)
# (based on PrintUsingPDF pdf script)
#
# This script Copyright (c) 2005 Cygnus Communications
# and distributed under the GPL (see below)
Possible Issues?
- File permissions on
c:/twiki/bin/genpdf?
- Using Windows Explorer (and right-click, click Properties, select Security tab), I made the permissions for all users match those on the
c:/twiki/bin/genpdf, but to no avail; still have the same problems.
- File permissions on any other files?
- Relock rcs files?
- File permissions on other files?
--
JasonVensel - 07 Mar 2006
Jason, I can try my best to help you out, but can't guarantee success since
"I don't do Window's".
First off, just to confirm, you state above that you are running TWiki v4.0.0 (aka Dakar) and I'll assume you are running the latest published version of the AddOn, 28 Jun 2005 (v0.6). The plugin documentation refers to a Cairo version of TWiki, so a few things should probably be changed from what you described above:
- move the htmldoc command variable to LocalSite.cfg. Specifically, remove your change to TWiki.cfg and add the following line to
C:\path-to-twiki\lib\LocalSite.cfg:
$TWiki::htmldocCmd = "c:/HTMLDOC/htmldoc.exe";
This change now will easy upgrading-pain later.
- you should not need to edit the
GenPDF.pm file. The location of perl should be declared in the first line of twiki/bin/genpdf. (Hmmm. looking over the documentation, now...) I'm not sure why the documentation states to modify GenPDF.pm. You can if you want, but it will have no effect.
Going forward:
- It is encouraging that you can run HTMLDOC from the command line outside of TWiki. That gives a good point to start from.
- One tool to aid in debugging is the LWP package from CPAN. This provides you with
lwp-download which can be more descriptive than IE when things go wrong. This allows you to call lwp-download http://localhost/twiki/view/genpdf/TWiki/GenPDFAddOn, for example, from a command line prompt. LWP has lots of hooks to display header (or lack of header) information, which can help in the process.
- For now, I recommend waiting on changing the templates/topics until you can confirm that the backend rendering is functioning properly.
- the only file-lock/file-permissions that you need to worry about at this point is
genpdf.
Possible Issues: These are a few issues I've run into in the past with WinXP and Cygwin--things to keep in mind as you work through this.
- I've seen WinXP munge
system calls within perl scripts. Specifically, it changes paths to what it consider's 'safe', and ignores other settings. If this is the case here, it is likely that either genpdf or htmldoc can't find a library that it depends on.
- I've seen the path get confused when interfacing between Cygwin and external programs. e.g. Cygwin in 'unix-like', so it may think perl is installed at
/usr/local/bin/perl instead of C:\cygwin\usr\local\bin\perl.
Again, it has been a few years since I've worked with either Windows or Cygwin.
These issues above may have been resolved in more recent releases.
For now, I recommend making the two changes in the first list above. Then, try to access the script at a lower level than through your browser. In a DOS box, you should be able to run
perl -Tw -IC:\path-to-twiki-lib\ C:\path-to-twiki-bin\genpdf topic=TWiki.GenPDFAddOn. If that doesn't work due to permissions or some such, try the lwp-download route.
Best of luck with this.
--
ScottHoge - 08 Mar 2006
Scott, thanks for the suggestions. I'm looking into them. I should clarify that I am in fact running Cairo, not Dakar. The table was incorrect. I have since corrected the table. In the meantime, if anyone else wants to respond I've included as much relevant information about my TWiki installation as I could think of.
Version Issues
- TWiki Version: I am running Cairo.
- HTMLDoc Version: I am running 1.8.24.
- Trial version: I have eliminated this as a potential issue by uninstalling the trial version and locating/installing free binary versions; I have zip files for both 1.8.23 and 1.8.24.
- Version #: What is the best/most compatible/least buggy version of HTMLDOC? From postings here on TWiki.org, it appears to be either 1.8.23 or 1.8.24.
TWiki-related Install File Paths
Here are the file paths where TWiki and all TWiki-related applications are installed on our TWiki web server:
- Apache:
c:/Apache
- Cron:
c:/Cron
- Cygwin:
c:/cygwin
- HTMLDOC:
c:/HTMLDoc
- Perl:
c:/cygwin/bin/perl.exe
- TWiki:
c:/twiki
Relevant File Configuration
Based on my research and TWiki documentation, here are all the files (so far as I can tell) that relate to
GenPDFAddOn functionality.
-
c:/twiki/bin/.htaccess
-
c:/twiki/bin/setlib.cfg
-
c:/twiki/lib/TWiki.cfg
-
c:/twiki/bin/genpdf
-
c:/twiki/lib/Contrib/GenPDF.pm
c:/twiki/bin/.htaccess
I configured
c:/twiki/bin/.htaccess so that users must log in when they first open our TWiki site. I also had the
genpdf script requiring a valid user:
<Files "genpdf">
require valid-user
</Files>
Because I've been having trouble with the
GenPDFAddOn, I removed the three lines that had
genpdf requiring a valid-user from
.htaccess just to eliminate as many potential issues as possible.
c:/twiki/bin/setlib.cfg
I believe everything in this file is configured correctly, but here's every single line from the file:
# TWiki Collaboration Platform, http://TWiki.org/
#
# Copyright (C) 2002-2004 Peter Thoeny, peter@thoeny.com
#
# For licensing info read license.txt file in the TWiki root.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html
#
# setlib.cfg: configuration file for TWiki and Perl library paths
#
# Used to configure non-standard locations for TWiki and Perl modules.
# -------------- Only needed to work around an Apache 2.0 bug on Unix
#
# If you are running TWiki on Apache 2.0 on Unix you might experience cgi
# scripts to hang forever. This is a known Apache 2.0 bug. A fix is
# available at http://issues.apache.org/bugzilla/show_bug.cgi?id=%2022030.
# It is recommended to patch your Apache installation.
#
# As a workaround, uncomment one of the following two lines. (As a drawback,
# errors will not be reported anymore to the browser via CGI::Carp)
# open(STDERR, ">>/dev/null"); # throw away cgi script errors, or
# open(STDERR, ">>/tmp/error.log"); # redirect errors to a log file of choice
# -------------- Change these settings if required
# Path to lib directory containing TWiki.pm.
# ATTENTION: Set to absolute file path:
$twikiLibPath = 'c:/twiki/lib';
# Path to local Perl modules (e.g. under home directory for users
# without 'root' on Unix/Linux). Uncomment and set if needed:
# $localPerlLibPath = '';
# -------------- Don't change anything below this line
# Prepend to @INC, the Perl search path for modules
unshift @INC, $twikiLibPath;
unshift @INC, $localPerlLibPath if $localPerlLibPath;
1; # Return success for module loading
Section Configuration Issues
-
Only needed to work around an Apache 2.0 bug on Unix: This entire section is commented out; it should be fine this way.
-
Change these settings if required: there are only two possible settings in this section.
-
$twikiLibPath = 'c:/twiki/lib';: I'm fairly certain this is configured correctly.
-
# $localPerlLibPath = '';: this is commented out; do I need to uncomment it and set it? If so, what do I set it to?
-
Don't change anything below this line: per the name of this section, I haven't changed anything. Do I need to?
c:/twiki/lib/TWiki.cfg
The only change I made to this file after installing the
GenPDFAddOn was to insert the
$htmldocCmd parameter.
#
# NOTE: You might want to avoid c: at start of cygwin unix command for
# Windows, seems to cause a problem with pipe used in search
# Unix ls command : (deprecated since 01 Nov 2003)
$lsCmd = "/bin/ls";
# Unix egrep command :
$egrepCmd = "/bin/egrep -E";
# Unix fgrep command :
$fgrepCmd = "/bin/fgrep -F";
# HTMLDOC location
$htmldocCmd = "c:/HTMLDoc";
#
I am a little uncertain as to whether Im using the correct format for this parameter. Would it be better to use one of the following variations instead?
-
$htmldocCmd = "c:/HTMLDoc";
-
$htmldocCmd = "c:/HTMLDoc/htmldoc.exe";
-
$htmldocCmd = "c:/HTMLDoc";
-
$htmldocCmd = "c:/HTMLDoc/htmldoc.exe";
-
$TWiki::htmldocCmd = "c:/HTMLDoc";
-
$TWiki::htmldocCmd = "c:/HTMLDoc/htmldoc.exe";
-
$TWiki::htmldocCmd = "c:/HTMLDoc";
-
$TWiki::htmldocCmd = "c:/HTMLDoc/htmldoc.exe";
Issues
- Do I specify
$htmldocCmd or $TWiki::htmldocCmd?
- Do I insert ONLY one space on either side of the equal sign or do I insert multiple spaces before it?
- Do I need to specify the executable (i.e.,
htmldoc.exe) or just the directory in which it resides?
- Does the location (line number-wise) in which I insert this parameter matter?
- The installation instructions simply state to look for
$fgrep.
- Does it matter if I place it before or after
$fgrep? (As you can see above, I placed it immediately after $fgrep).
c:/twiki/bin/genpdf
Here's the entire code from my file.
#!c:/cygwin/bin/perl -w
#
# pdf (converts TWiki page to PDF using HTMLDOC)
# (based on PRintUsingPDF pdf script)
#
# This script Copyright (c) 2005 Cygnus Communications
# and distributed under the GPL (see below)
#
# TWiki WikiClone (see wiki.pm for $wikiversion and other info)
#
# Based on parts of Ward Cunninghams original Wiki and JosWiki.
# Copyright (C) 1998 Markus Peter - SPiN GmbH (warpi@spin.de)
# Some changes by Dave Harris (drh@bhresearch.co.uk) incorporated
# Copyright (C) 1999 Peter Thoeny, peter@thoeny.com
# Additional mess by Patrick Ohl - Biomax Bioinformatics AG
# January 2003
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html
BEGIN {
# Set default current working directory (needed for mod_perl)
if( $ENV{"SCRIPT_FILENAME"} && $ENV{"SCRIPT_FILENAME"} =~ /^(.+)\/[^\/]+$/ ) {
chdir $1;
}
# Set library paths in @INC, at compile time
unshift @INC, '.';
require 'setlib.cfg';
}
use strict;
use TWiki::Contrib::GenPDF;
TWiki::Contrib::GenPDF::viewPDF();
Issues
- The first line of the file must be
#!c:/cygwin/bin/perl w.
- If this entire line is removed, the following error message appears in the
c:/Apache/logs/error.log file when the Create PDF link is clicked.
c:/twiki/bin/genpdf is not executable; ensure interpreted scripts have "#!" first line
- If the first line of the file is
#!c:/cygwin/bin/perl wT (taint switch (-T)), Internet Explorer immediately displays a Software error message: Insecure dependency in chdir while running with -T switch at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 516.
- In addition, these corresponding errors appear in the
c:/Apache/logs/error.log:
c:\\twiki\\bin\\genpdf: Insecure dependency in exec while running with -T switch at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 503.\n
c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 512.\n
c:\\twiki\\bin\\genpdf: Use of uninitialized value in hash element at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 513.\n
c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 511.\n
c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 512.\n
--
JasonVensel - 13 Mar 2006
Update
I stumbled across the following information, but hopefully it helps. When I click a link to create a PDF version of a topic, an .HTML file of that topic is immediately created in my
c:/cygwin/tmp directory.
For example, we have a topic named
Bulletins.DVRCameraSetup. I placed a "Create PDF" link on this topic and saved the changes. When I click the link, the following file was immediately created:
c:/cygwin/tmp/GenPDFAddOn21ku17CtYt.html. Sure enough, if I view this file it's an HTML version of our
Bulletins.DVRCameraSetup topic.
So, as I understand the functionality of the
GenPDFAddOn, a topic is first generated into an HTML file. Then the HTML file is generated into a PDF file. Therefore, something in the HTML-to-PDF file generation is causing the system to hang for an extended amount of time.
I'll investigate more and report back.
--
JasonVensel - 14 Mar 2006
Check your apache error log files for information on why
htmldoc fails. It should contain a list of the arguments used to convert the file (after
Calling htmldoc with args:), as well as information on why it fails (e.g. "no file found").
--
ScottHoge - 14 Mar 2006
There are absolutely no entries (corresponding to the date/time that I click the link) in
c:/Apache/logs/error.log. (The most recent entry in this log is from more than 2 hours ago.)
Here's all that appears in my
c:/Apache/logs/access.log:
127.0.0.1 - JasonVensel [14/Mar/2006:14:03:24 -0500] "GET /bin/view/Bulletins/WebHome HTTP/1.1" 200 15834
127.0.0.1 - - [14/Mar/2006:14:03:24 -0500] "GET /bin/view/Bulletins/%USERLAYOUTURL% HTTP/1.1" 400 293
127.0.0.1 - - [14/Mar/2006:14:03:24 -0500] "GET /bin/view/Bulletins/%USERSTYLEURL% HTTP/1.1" 400 293
127.0.0.1 - JasonVensel [14/Mar/2006:14:03:32 -0500] "GET /bin/view/Bulletins/CategoryNetworkBulletins HTTP/1.1" 200 17881
127.0.0.1 - - [14/Mar/2006:14:03:32 -0500] "GET /bin/view/Bulletins/%USERLAYOUTURL% HTTP/1.1" 400 293
127.0.0.1 - - [14/Mar/2006:14:03:32 -0500] "GET /bin/view/Bulletins/%USERSTYLEURL% HTTP/1.1" 400 293
127.0.0.1 - JasonVensel [14/Mar/2006:14:03:42 -0500] "GET /bin/view/Bulletins/DVRCameraSetup HTTP/1.1" 200 15865
127.0.0.1 - - [14/Mar/2006:14:03:42 -0500] "GET /bin/view/Bulletins/%USERSTYLEURL% HTTP/1.1" 400 293
127.0.0.1 - - [14/Mar/2006:14:03:42 -0500] "GET /bin/view/Bulletins/%USERLAYOUTURL% HTTP/1.1" 400 293
Note: The "created" time stamp on the HTML file that corresponds with the above
access.log entries is "Today, March 14, 2006, 2:03:48 PM". So it looks like the file was created after the above
access.log entries were recorded.
--
JasonVensel - 14 Mar 2006
In that case, that means this line of
lib/TWiki/Contrib/GenPDF.pm
L614: system($TWiki::htmldocCmd, @htmldocArgs);
is not executing properly. You might try changing it to
L614: system("$TWiki::htmldocCmd @htmldocArgs");
to see if that helps. Also, you can try commenting it out, (place a
#
at the start of the line) to confirm that this is where the code is hanging.
--
ScottHoge - 14 Mar 2006
No change as a result of modifying line 614 per your recommendation. In addition, no error when I comment out line 614. However, I was finally able to generate the following errors:
[Tue Mar 14 14:32:37 2006] [error] [client 127.0.0.1] [Tue Mar 14 19:32:37 2006] c:\\twiki\\bin\\genpdf: syntax error at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 588, near "else"\n
[Tue Mar 14 14:32:37 2006] [error] [client 127.0.0.1] [Tue Mar 14 19:32:37 2006] c:\\twiki\\bin\\genpdf: Compilation failed in require at c:\\twiki\\bin\\genpdf line 40.\n
[Tue Mar 14 14:32:37 2006] [error] [client 127.0.0.1] [Tue Mar 14 19:32:37 2006] c:\\twiki\\bin\\genpdf: BEGIN failed--compilation aborted at c:\\twiki\\bin\\genpdf line 40.\n
by commenting out this line of
lib/TWiki/Contrib/GenPDF.pm:
L584: if ($prefs{'toclevels'} eq '0' ) {
Note: I tried commenting out other lines between L614 and L584; L584 was the first to generate errors.
--
JasonVensel - 14 Mar 2006
Line 40 in
/twiki/bin/genpdf is:
use TWiki::Contrib::GenPDF;
--
JasonVensel - 14 Mar 2006
Unfortunately, that doesn't help much... the error log is complaining about an
else with no previous
if.
Commenting out L614 may not have caused an error. Rather, it should have returned an empty file.
The fact that the temporary html file is being created means everything up to L561 is OK. For now, I would replace L614 with
L614: print STDERR "$TWiki::htmldocCmd @htmldocArgs\n";
and add in a dummy output file for the server to return.
L571: print $outputFile "<p>This is a test\n"; $prefs{'format'}='html';
This effectively takes
htmldoc out of the processing (temporarily), so that you can confirm the problem is not with TWiki. (And of course, uncomment any other lines you commented out.)
--
ScottHoge - 14 Mar 2006
Followed your recommendation and still have the same problem: the HTML file is generated and there are no error messages. The system just hangs.
Question 1: Is there any difference between
$TWiki::fgrepCmd and
$fgrepCmd? Likewise, is there any difference between
$TWiki::htmldocCmd and
$htmldocCmd? I ask because the
$fgrepCmd and
$htmldocCmd formats are used in my
TWiki.cfg file whereas
$TWiki::fgrepCmd and
$TWiki::htmldocCmd are used in
GenPDF.pm.
Question 2: Would running the
/bin/genpdf script from a Cygwin command prompt provide any indication as to the problem? If so, what is the correct format? E.g.,
$ perl genpdf c:/twiki/Data/Main/JasonVensel.txt c:/twiki/Data/Main/JasonVensel.pdf?
--
JasonVensel - 14 Mar 2006
A to Q1: they are the same. Perl uses a "package" construct, keeping variables local as much as possible. So, in TWiki.pm, the TWiki package is defined. TWiki.cfg is then parsed, as a child to TWiki.pm. So, $var in TWiki.cfg becomes $TWiki::var in TWiki.pm.
A to Q2: Yes. Running the script outside of the browser will provide much useful information. The syntax
perl genpdf topic=Main.JasonVensel should work.
--
ScottHoge - 15 Mar 2006
Other last thought for the day: check for zombie processes. When the server hangs, does the
genpdf thread die? or does it just zone-out? In Win2k, the process list was accessible through a right-click on the task bar. I'm not sure if this will work on
WinXP or not.
--
ScottHoge - 15 Mar 2006
I performed the following steps:
- Opened the Cygwin Bash Shell (what I refer to as the Cygwin command prompt).
- Typed
cd /twiki/bin.
- Pressed
Enter. Cygwin changed to a /twiki/bin prompt.
- Typed
perl genpdf topic=Main.JasonVensel.
- Pressed
Enter. The following messages appeared in the Cygwin command prompt user interface:
[Wed Mar 15 08:20:13 2006] genpdf: Can't exec "/bin/fgrep -F": No such file or directory at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 503.
More errors appear in the Cygwin user interface. These same errors also appear in my
c:/Apache/logs/error.log file:
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] Premature end of script headers: c:/twiki/bin/genpdf
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Can't exec "/bin/fgrep -F": No such file or directory at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 503.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in pattern match (m//) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 214.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in pattern match (m//) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 127.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 76.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 77.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 78.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in pattern match (m//) at c:/twiki/lib/TWiki.pm line 3037.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki.pm line 3142.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
[Wed Mar 15 08:18:14 2006] [error] [client 127.0.0.1] [Wed Mar 15 13:17:20 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Prefs.pm line 490.\n
GenPDF.pm line 503
exec { $path } $path, @search
;
GenPDF.pm line 214
if ($text =~ /^http.*\/.*\/oops\/.*oopsaccessview$/) {
GenPDF.pm line 127
return $text if ($text !~ //);
GenPDF.pm lines 76, 77, and 78
$text =~ s|%GENPDFADDON_BANNER%|$prefs{'banner'}|g;
$text =~ s|%GENPDFADDON_TITLE%|$prefs{'title'}|g;
$text =~ s|%GENPDFADDON_SUBTITLE%|$prefs{'subtitle'}|g;
TWiki.pm line 3037
if( $intext !~ /<verbatim>/oi ) {
TWiki.pm line 3142
$text =~ s/(\s)\!\%([A-Z])/$1%$2/g;
Prefs.pm line 490
$_[0] =~ s/$term/$vals->[$x]/ge;
Note: No HTML file is created in my
/tmp directory when I run this from a command line.
Process List
I can view the processes list using Windows Task Manager. Here's what I've observed:
- TWiki scripts seem to appear as
perl.exe processes.
- E.g., With my TWiki site open and the Processes list in Task Manager open, when I click a link to open a new topic or change webs,
perl.exe entry (sometimes 2 of them) will appear briefly in the list of processes.
- I'm guessing at least one of these represents the
view script? After the page/web opens, perl.exe will disappear from the processes list.
- Likewise, if I click the "Create a PDF" link on my
Bulletins.DVRCameraSetup topic, a perl.exe entry appears in the process list. This instance remains in the process list while the progress bar at the bottom of Internet Explorer slowly moves from left to right.
- I've noticed that if I click Internet Explorer's "Stop" bottom, this instance of
perl.exe indefinitely remains in the list of processes.
- Clicking the "Create PDF" link again causes a new instance of
perl.exe to appear in the list. I can keep doing this so that multiple perl.exe instances appear in the Processes list at the same time. Eventually I have to select each and click "End Process" to remove them from the Processes list. I have not noticed this behavior with any other scripts.
- Apart from the
genpdf script, perl.exe typically does not appear in the processes list; when it does appear for other scripts, it seems to disappear from the processes list after the script finishes running.
- There don't appear to be any other processes that would interfere. That is, they're just the standard process such as Apache, explorer, winlogon, etc.
--
JasonVensel - 15 Mar 2006
Hmmmm.
Zombie processes are tougher to debug. But, good to know that is what is going on.
You should have seen output similar to
Calling htmldoc with args: --book --quiet --links --linkstyle plain --outfile /tmp/GenPDFAddOnckG7GppYhp.pdf --format pdf14 --portrait --size a4 --browserwidth 860 --titlefile /tmp/GenPDFAddOnhRRycuZRTx.html --toclevels 5 --tocheader ... --tocfooter ..i --firstpage toc /tmp/GenPDFAddOnttCkUmmFWm.html after all of the "uninitiallized value" warning messages (which, since you ran form the command line, are not necessarily critical). It is troubling that you didn't. Do you see it when you call
genpdf from the browser?
Nonetheless, the block of code where fgrep failed contains a few things that may not be stable on WinXP.... particularly,
L497: open $pipe. You can turn this block of code off by disabling recursion, e.g.
* Set RECURSIVE = 0
in the
TWiki.GenPDFAddOn topic. Give that a try. (from both the brower and command prompt)
--
ScottHoge - 15 Mar 2006
Sorry for the confusion. I do receive similar output after all the "uninitialized value" warning messages in the Cygwin Bash Shell user interface; this output does not appear in the Apache error log. Specifically:
Calling htmldoc with args: --book --quiet --links --linkstyle plain --outfile /t
mp/GenPDFAddOnBy77vywvAS.pdf --format html --portrait --size a4 --browserwidth 8
60 --titlefile /tmp/GenPDFAddOnWueFFvnnyL.html --toclevels 5 --tocheader ... --t
ocfooter ..i --firstpage toc /tmp/GenPDFAddOn2vrDJROFfC.html
c:/htmldoc/htmldoc.exe --book --quiet --links --linkstyle plain --outfile /tmp/G
enPDFAddOnBy77vywvAS.pdf --format html --portrait --size a4 --browserwidth 860 -
-titlefile /tmp/GenPDFAddOnWueFFvnnyL.html --toclevels 5 --tocheader ... --tocfo
oter ..i --firstpage toc /tmp/GenPDFAddOn2vrDJROFfC.html
Content-Type: text/html; charset=ISO-8859-1
I disabled recursion in
TWiki.GenPDFAddOn. There is no change in the behavior or reported errors when I run
genpdf from the link or command line.
Would it be preferable to run HTMLDoc 1.8.23, 1.8.24, or some other version? (I'm running 1.8.24 with Cairo.)
--
JasonVensel - 16 Mar 2006
This line:
Content-Type: text/html; charset=ISO-8859-1
is the start of the HTML page header. This is encouraging! This means that the entire code block is running, since the
print $query->header code block is at the end.
The HTMLDoc version should have little effect. Since you can run it from a command prompt, you should be able to run it from TWiki.
Here is my current thought. HTMLdoc is not executing, and the reason why is not reported. The zombie process occurs because of the
while loop at the end, attempting to read a file that doesn't exist or isn't closed.
I have no time at the moment to post code changes to try. Hopefully later I can.
--
ScottHoge - 16 Mar 2006
I'm sorry to hear that you don't have time to post code changes to try, but I understand. I really appreciate your help on this issue and look forward to hearing back from you.
--
JasonVensel - 16 Mar 2006
Here's some more information to consider. The
.html and
.pdf files that are reported in that last part of the output do not exist. I ran a file search across the entire TWiki machine's hard drive (including hidden/system files and folders) and none of the following files (reported above) were found:
-
GenPDFAddOnBy77vywvAS.pdf
-
GenPDFAddOnWueFFvnnyL.html
-
GenPDFAddOn2vrDJROFfC.html
--
JasonVensel - 16 Mar 2006
Here are the next steps I would try.
- run
genpdf from the browser to generate the temporary .html file.
- from the command line, call
htmldoc using the arguments generated by genpdf, hopefully from the browser call, or instead using the line you give above. Be sure to replace the temp file above with the new temp file.
assuming those both work as before ...
- set up a temporary cgi script in the twiki/bin directory, containing the following
- the shebang line
#! /usr/../perl -wI.
- a few lines to report results to the browser:
use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; print $q->header; print "hello;".
- a system call containing the same
htmldoc command as worked on the command line. e.g. system("htmldoc ...");
presumably, a PDF file will be generated by 2. Hopefully, the same file will be generated by 3. If not, hopefully a few error messages will report what went wrong.
--
ScottHoge - 16 Mar 2006
Here's what I did:
- I already have a bunch of temporary
.html files in my c:/cygwin/tmp directory from all the testing I've been doing.
- From a
c:/htmldoc command prompt, I ran htmldoc --webpage -f myfile.pdf c:/cygwin/tmp/GenPDFAddOnqZ1x88isEI.html. This successfully created a .pdf version of the GenPDFAddOnqZ1x88isEI.html file in my c:/htmldoc directory.
- Note: I initially thought I had to run the
htmldoc.exe command from the c:/htmldoc directory. As it turns out, you don't have to run htmldoc --webpage -f myfile.pdf c:/cygwin/tmp/GenPDFAddOnqZ1x88isEI.html from a c:/htmldoc command prompt. The file directory specified in the command prompt simply determines the location where the new .pdf file will be placed.
- I created a temporary cgi script in my
c:/twiki/bin directory named tempgenpdf. It contains the following:
#!c:/cygwin/bin/perl -wI.
#
# pdf (converts TWiki page to PDF using HTMLDOC)
#
#
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
print $q->header;
print "hello";
system("htmldoc --webpage -f newfile.pdf c:/cygwin/tmp/GenPDFAddOnAAA.html");
-
- When I run the script from a command line (i.e., from a
/twiki/bin prompt, type perl tempgenpdf and press Enter), I received the following output:
Content-type: text/html
<h1>Software error:</h1>
<pre> syntax error at tempgenpdf line 12, near "system"
Execution of tempgenpdf aborted due to compilation errors.
</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.
</p>
[Fr Mar 17 09:38:48 2006] tempgenpdf: syntax error at tempgenpdf line 12, near
"system"
[Fr Mar 17 09:38:48 2006] tempgenpdf: Execution of tempgenpdf aborted due to co
mpilation errors.
-
- Line 12 is the
system call. Since I don't know Perl, I spent a good deal of time looking at, and changing/testing, line 12.
- I eventually thought to look at line 11. From the amount of time I've spent looking at TWiki files, I've concluded that a semicolon is used to denote the end of a line for the compiler.
- Based on this assumption, I changed line 11 (
print "hello;") to print "hello";.
- Saved the change to
tempgenpdf and re-ran it from a command line.
- Received the following output:
Content-Type: text/html; charset=ISO-8859-1
helloERR014: Table on page 2 too wide - truncation or overlapping may occur!
PAGES: 8
BYTES: 416036
-
- I ran
perl tempgenpdf from a /twiki/bin prompt so I checked the c:/twiki/bin directory and sure enough, there was a newfile.pdf file there.
- The
ERR014 is unique to the content of the .html that I specified (it was the TWiki.GenPDFAddOn topic, which includes a very large table). I was able to convert a different .html file (a one-page topic that consists of plain text) without any errors by specifying a different .html file in the tempgenpdf script.
- The error-free file output was (I suspect I'm not telling you anything new or unexpected here):
Content-Type: text/html; charset=ISO-8859-1
helloPAGES: 1
BYTES: 155123
--
JasonVensel - 17 Mar 2006
OK. (And, my apologies for the typo on line 11)
Try running the same test script from the browser. If that works, then modify the system call in
GenPDF.pm to match your temp script. (i.e. hard-code the
htmldoc system call in
GenPDF.pm to something that you know works in the test script.) If that works, then slowing modify the hard-coded call to the dynamic call, adding or deleting arguments until you find the one (or ones) that fail.
--
ScottHoge - 17 Mar 2006
You needn't apologize; I'm grateful for the help. Besides, it boosts my confidence when I figure these things out on my own!
Same test script from browser
I inserted the following link in my TWiki.GenPDFAddOn topic:
[[%SCRIPTURL%/tempgenpdf%SCRIPTSUFFIX%/%WEB%/%TOPIC%][Create PDF]]
Saved the changes.
When I click the "Create PDF" link, Internet Explorer immediately opens a white/blank page with the following message:
helloContent-Type: text/plain HTMLDOC Version 1.8.24 Open Source Copyright
1997-2004 Easy Software Products, All Rights Reserved. This software is governed
by the GNU General Public License, Version 2, and is based in part on the work of
the Independent JPEG Group.
- Well, this is good news. This is the header output from HTMLDOC, meaning it successfully executed. Check to see if your PDF file was created. -- SH
When I view the Apache error log, I find the following message:
[Fri Mar 17 14:14:41 2006] [error] [client 127.0.0.1] File does not exist: c:/twiki/twiki/GenPDFAddOn
- I don't understand this at all. Why would the
tmpgenpdf script try to access GenPDFAddOn? -- SH
Note: Modifying the link to the following produces identical behavior and error messages:
[[%SCRIPTURL%/tempgenpdf%SCRIPTSUFFIX%][Create PDF]]
htmldoc system call location in GenPDF.pm
Note: the
htmldoc system call in
c:/twiki/lib/TWiki/Contrib/GenPDF.pm is located on line #614. This line, as it is included in the
GenPDFOn.zip file consists of the following:
system($TWiki::htmldocCmd, @htmldocArgs);
I tried modifying the values inside the parentheses, but it seems like the compiler (or whatever the technical term is for the engine that processes the lines of code) doesn't even reach this line because no matter what I enter in line 614, my TWiki site functions exactly the same way when I click my "Create PDF" link.
Looking Closer at the GenPDF.pm Code
While looking at the code of the
GenPDF.pm file for the system call issue, I started to wonder about the following lines/sections of the file:
- Line 555 of
GenPDF.pm creates the .html file.
- This makes me think that everything up to this point is okay since I'm able to generate
.html files in my temp directory.
- Line 555 is
my $contentFile = new File::Temp(TEMPLATE => 'GenPDFAddOnXXXXXXXXXX',
- Line 564 of
GenPDF.pm creates title file.
- I'm not sure what a title file is.
- Also, other than a commented out description of this line, there's no other code. There aren't additional lines that specify a temporary directory location or a file extension for this title file. The temporary
.html and .pdf file creation sections specify this info for those files.
- Line 567 of
GenPDF.pm creates a temporary .pdf file.
- Because I've yet to see a
.pdf file be created in my temp directory, this makes me believe that the problem either begins here or occurs between line 555 and here.
- Line 614 of
GenPDF.pm is the system call for htmldoc.
- I just included this here as a point of reference, to see how it fits in the overall scheme/order of the code.
--
JasonVensel - 17 Mar 2006
You've definitely got the right approach now for debugging.
Yes. Since the (or a?) temp
.html file is created, it is safe to assume that everything is fine up to L560. The call to
File::Temp, e.g. L567, doesn't actually create a temporary file. Rather, it returns a unique filename name in a temporary directory for use later. In this case, the temp file name is used as the output file for
htmldoc.
The title page is a GenPDFAddOn construct, to provide a cover page for the PDF. For now, you can safely comment out L564 and L583.
My best advice is to keep plugging away. It appears that your tmpgenpdf script works OK, and the htmldoc gets called successfully. Using the same system call in GenPDF.pm should work as well. If I get a free moment this weekend, I'll pull out my old Windows machine that has cygwin on it, to see if I can recreate the problem. Cheers!
--
ScottHoge - 17 Mar 2006
More testing...
- Commented out L564 so that it now looks like this:
# my $titleFile = _createTitleFile($webName);
- Commented out L583 so that it now looks like this:
# "--titlefile", "$titleFile";
- Also had to replace the comma (
,) at the very end of L582 with a semicolon (;). L582 now looks like this: "--browserwidth", "$prefs{'width'}";
- Saved the changes and tested the standard "Try loading _this page_" link. The web page immediately changed to an "Internal Server Error" that didn't state anything other than "The server encountered an internal error or misconfiguration and was unable to complete your request." I opened the Apache error log and found these corresponding error messages:
[Mon Mar 20 08:25:36 2006] [error] [client 127.0.0.1] malformed header from script. Bad header=HTMLDOC Version 1.8.24 Open So: c:/twiki/bin/genpdf
[Mon Mar 20 08:25:36 2006] [error] [client 127.0.0.1] Calling htmldoc with args: --book --quiet --links --linkstyle plain --outfile /tmp/GenPDFAddOneQbwx6xSM4.pdf --format pdf14 --portrait --size a4 --browserwidth 860 --toclevels 5 --tocheader ... --tocfooter ..i --firstpage toc /tmp/GenPDFAddOnl6HP2GKmJR.html\n
[Mon Mar 20 08:25:36 2006] [error] [client 127.0.0.1] child exited with value 1\n
[Mon Mar 20 08:25:36 2006] [error] [client 127.0.0.1] [Mon Mar 20 13:25:36 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in string ne at (eval 59) line 31.\n
-
- I checked
c/cygwin/tmp (my temp directory where the .html files are created) thinking that maybe the output .pdf file would have been generated, but the .html content file wasn't even there.
I'm going to keep changing things in
GenPDF.pm file to see if I can get a better idea of what is going on.
--
JasonVensel - 20 Mar 2006
Based on my testing described in this entry, I believe the system might be hanging up on the
_createTitleFile($webName) subroutine.
I've been throwing in
print STDERR "blah blah blah"; strings throughout
GenPDF.pm to get a better idea of what's happening and when. Here's what I've done so far:
L202-204
I inserted
print STDERR... at L203:
sub _createTitleFile {
print STDERR "About to createTitleFile content file";
my ($webName) = @_;
L553-556
I inserted
print STDERR... at L554:
$htmlData =~ s|.*(<!DOCTYPE)|$1|s;
print STDERR "About to create content file";
# Save this to a temp file for htmldoc processing
my $contentFile = new File::Temp(TEMPLATE => 'GenPDFAddOnXXXXXXXXXX',
L563-568
I inserted
print STDERR... at L563 and L566:
print STDERR "About to create title file";
# Create a file holding the title data
my $titleFile = _createTitleFile($webName);
print STDERR "About to create output file";
# Create a temp file for output
my $outputFile = new File::Temp(TEMPLATE => 'GenPDFAddOnXXXXXXXXXX',
Testing
- Open my
TWiki.GenPDFAddOn topic.
- Click the standard "Try loading _this page_" link in the GenPDFAddOn topic.
- Verify the
.html file is created in my temp directory using Windows Explorer.
- Click the "Stop" button in Internet Explorer.
- Open Windows Task Manager and kill the
perl.exe process so the relevant error messages will be written to the Apache error log.
- View the Apache error log.
- These corresponding error messages appear in the error log:
[Mon Mar 20 11:52:38 2006] [error] [client 127.0.0.1] About to create content fileAbout to create title fileAbout to createTitleFile content file[Mon Mar 20 16:52:11 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in pattern match (m//) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 215.\n
[Mon Mar 20 11:52:38 2006] [error] [client 127.0.0.1] [Mon Mar 20 16:52:11 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in pattern match (m//) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 127.\n
[Mon Mar 20 11:52:38 2006] [error] [client 127.0.0.1] [Mon Mar 20 16:52:11 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in substitution (s///) at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 76.\n
...(error message continues)
As you can tell, the
About to createTitleFile content file is the last
print STDERR... message to be printed before the other errors. Notice that the
print STDERR "About to create output file"; string (from L566) is NOT processed, but the one from L203 is. This leads me to believe that the system is hanging up on something inside the
_createTitleFile($webName) subroutine. I'll investigate more and report back.
--
JasonVensel - 20 Mar 2006
I've decided there's only one way to really understand this. I'm going to start over with a fresh copy of
GenPDF.pm. I'll insert
print STDERR "L###" statements (where
### is the line number in which I insert the statement) throughout the code of that file. I'll do this only in unused lines so as not to disturb the line numbering in the standard file.
--
JasonVensel - 20 Mar 2006
Lots of testing and debugging since my last post, so I'll try to summarize what I've learned.
Can't exec fgrep error appears to be resolved
The exact error message was:
[Fri Mar 24 16:29:35 2006] [error] [client 127.0.0.1] c:\\twiki\\bin\\genpdf: Can't exec "/bin/fgrep -F": No such file or directory at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 503.\n
Line 503 in
GenPDF.pm is:
exec { $path } $path, @search;
Furthermore, from Line 490 in
GenPDF.pm I saw that:
$path = $TWiki::fgrepCmd
and from Lines 492-493 in
GenPDF.pm, I saw that:
@search = splice(@files, 0, 512); # only search 512 files at a time
unshift @search, '%META:TOPICPARENT{'; #}
So I then replaced
my $path = $TWiki::fgrepCmd; with
my $path = "c:/cygwin/bin/fgrep -F";. This resulted in the exact same error I’ve been receiving.
Next, I replaced
my $path = $TWiki::fgrepCmd; with
my $path = "c:/cygwin/bin/fgrep";. Now, the “Can’t exec...fgrep” error no longer appears. The rest of the error messages still appear (malformed header, child exited, and use of unitialized value). I changed the
GenPDF.pm file back to
my $path = $TWiki::fgrepCmd; and then removed the “-F” parameter from the
$fgrepCmd = "/bin/fgrep -F"; setting in
TWiki.cfg. This error no longer appears.
Issues:
- It appears the "–F" parameter causes this error.
- What is the "–F" parameter? Do I need it? The Windows TWiki installation instructions told me to use it in
TWiki.cfg.
- This experience forces me to question whether I should remove the similar "–E" parameter from the egrep setting in
TWiki.cfg.
--
JasonVensel - 27 Mar 2006
Next Issue
I uncommented all of the #DEBUG statements that are included in the
GenPDF.pm file. They consisted of the following:
- L176:
print STDERR "var = '$var'\n"; #DEBUG
- L180:
print STDERR "var = '$var'\n"; #DEBUG
- L293:
print STDERR "title: '$title'\n"; # DEBUG
- L321:
print STDERR "meta: '$meta'\n"; # DEBUG
- L433:
print STDERR "%prefs"; #DEBUG
- L485:
for (@files
) { print STDERR "file: '$_'\n"; } # DEBUG
- L486:
print STDERR scalar @files
," files found\n"; # DEBUG
- L507:
print STDERR scalar @data
, " files have parent topics\n"; # DEBUG
- L509:
print STDERR "data: '$_'\n"; # DEBUG
- L527:
print STDERR "new child of $parent: '$_'\n"; # DEBUG
- L544:
print STDERR "preparing $topic\n"; # DEBUG
- L557:
UNLINK => 0, # DEBUG
- L569:
UNLINK => 0, # DEBUG
Test 1: Run GenPDF with All DEBUG Lines Uncommented
I wanted to see whether each DEBUG line would be generated in the Apache error log and what the output for each DEBUG line would be.
Two things happened when I clicked my "Generate PDF" link:
- The same web topic would remain visible in Internet Explorer as the progress bar slowly moves from left to right; after approximately an hour, the page dies out and IE reports the page as being unavailable. If I just click the Back button, the web topic reappears.
- A perl.exe process hangs in my list of running processes. After I click the End Process button in Task Manager, a bunch of error messages are written to my Apache error log. The last error message is based on the Line 509 DEBUG error:
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] Premature end of script headers: c:/twiki/bin/genpdf
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] Ln45Ln443Ln642Ln645%prefsvar = '%BASETOPIC%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = 'JasonVensel - 21 Mar 2006 - 16:46 - r1.9: Try loading Create PDF STARTINCLUDE DVR Camera Setup Original Message From: Joe Smith ">DVRCameraSetup'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = '%FORMFIELD{"DocumentClassification" topic="%WEB%.%BASETOPIC%"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = ''\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = '© Your Company %WEB%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = '© Your Company Bulletins'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = '%REVINFO{"r1.$rev ­ $date ­ $wikiusername" web="%WEB%" topic="%BASETOPIC%"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = 'r1.9 ­ 21 Mar 2006 - 16:46 ­ JasonVensel - 27 Mar 2006 - 15:16 - r1.71: Name: Jason Vensel Email: jdvensel@ourcompany.com My Links Sandbox.WebHome web to try out TWiki Sandbox.JasonVenselSandbox just for me Personal Preferences (details ...">JasonVensel'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = ''\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = ''\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = '$PAGE(1)'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] var = '$PAGE(1)'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'AutoTendering.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'BarcodePriceImporter.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'CategoryNetworkBulletins.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'DVRCameraSetup.txt'\n
...(shortening topic list to save space)
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebAdminTopicList.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebChanges.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebHome.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebIndex.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebLeftBar.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebNotify.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebPreferences.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebRss.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebRssReader.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebSearch.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebSearchAdvanced.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebSiteTools.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebStatistics.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebTopicEditTemplate.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebTopicList.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebTopicNonWikiTemplate.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] file: 'WebTopicViewTemplate.txt'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] 48 files found\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] 35 files have parent topics\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'AutoTendering.txt:%META:TOPICPARENT{name="WebHome"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'BarcodePriceImporter.txt:%META:TOPICPARENT{name="WebHome"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'CategoryNetworkBulletins.txt:%META:TOPICPARENT{name="WebHome"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'DVRCameraSetup.txt:%META:TOPICPARENT{name="WebHome"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'QwestModemDocumentation.txt:%META:TOPICPARENT{name="WebHome"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'SetupTools.txt:%META:TOPICPARENT{name="WebHome"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'SiteWatch.txt:%META:TOPICPARENT{name="WashCAPs"}%'\n
[Mon Mar 27 13:57:28 2006] [error] [client 127.0.0.1] data: 'SQLStatementToAddLeadingZerosToBarcodes.txt:%META:TOPICPARENT{name="WebHome"}%'\n
This last topic is where the system appears to get stuck. There are plenty of topics beyond it, but it can't seem to process them.
Test 2: Run GenPDF with Line 509 Commented Out (all else equal)
Because the error log/system seems to get stuck while processing Line 509, I decided to comment it out to see if it is this DEBUG line on which the system gets stuck or some other line; I was hoping to see if Line 527's DEBUG message would print.
Three things happened when I clicked my "Generate PDF" link:
- The web topic immediately switches to a "500 Internal Server Error" message in Internet Explorer, stating "The server encountered an internal error or misconfiguration and was unable to complete your request." I can click the Back button and my web topic reappears.
- If I open Windows Explorer (My Computer) and browse to
c:/cygwin/tmp (my designated temp directory), there are now three new files there:
-
cgisess_xxxxxxxxxxx: this is just a cgi session file that is created when I open my site or access functions that are controlled by authentication (I think). I don't know exactly what this file does (it appears to log my sessions) but I've grown accustomed to seeing these files in the temp directory and am not worried about it.
-
GenPDFAddOnXXXXXXX.pdf: this is the first time I've seen this file created here. However, it is a 0 KB sized file and I am unable to open it. When I try to open it, Adobe Reader starts up and I receive a message in a dialog box stating "Adobe Reader could not open 'GenPDFAddOnXXXXX.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)." I'm excited to see this because although it didn't run the conversion properly, TWiki has not been creating the temp PDF files. This is encouraging.
-
GenPDFAddOnXXXXXX.html: I've been able to create these before so it's now more a sense of relief to see both the HTML and PDF files being created at the same time.
- The error messages that now appear in my Apache error log are:
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] malformed header from script. Bad header=HTMLDOC Version 1.8.24 Open So: c:/twiki/bin/genpdf
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] Ln45Ln443Ln642Ln645%prefsvar = '%BASETOPIC%'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = 'JasonVensel - 21 Mar 2006 - 16:46 - r1.9: Try loading Create PDF STARTINCLUDE DVR Camera Setup Original Message From: John Smith ">DVRCameraSetup'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = '%FORMFIELD{"DocumentClassification" topic="%WEB%.%BASETOPIC%"}%'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = ''\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = '© Your Company %WEB%'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = '© Your Company Bulletins'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = '%REVINFO{"r1.$rev ­ $date ­ $wikiusername" web="%WEB%" topic="%BASETOPIC%"}%'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = 'r1.9 ­ 21 Mar 2006 - 16:46 ­ JasonVensel - 27 Mar 2006 - 15:16 - r1.71: Name: Jason Vensel Email: jdvensel@drbsystems.com My Links Sandbox.WebHome web to try out TWiki Sandbox.JasonVenselSandbox just for me Personal Preferences (details ...">JasonVensel'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = ''\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = ''\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = '$PAGE(1)'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] var = '$PAGE(1)'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'AutoTendering.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'BarcodePriceImporter.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'CategoryNetworkBulletins.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'CouponAnalysisReporting.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'DVRCameraSetup.txt'\n
...(topic list edited to save space)
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebAdminTopicList.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebChanges.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebHome.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebIndex.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebLeftBar.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebNotify.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebPreferences.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebRss.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebRssReader.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebSearch.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebSearchAdvanced.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebSiteTools.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebStatistics.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebTopicEditTemplate.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebTopicList.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebTopicNonWikiTemplate.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] file: 'WebTopicViewTemplate.txt'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] 48 files found\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] 35 files have parent topics\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] preparing DVRCameraSetup\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] title: 'Test Title'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] meta: '<META NAME="AUTHOR" CONTENT="Main.JasonVensel"/><META NAME="COPYRIGHT" CONTENT="Copyright © 1999-2006 by the contributing authors. \n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] All material on this collaboration platform is the property of the contributing authors. \n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] Ideas, requests, problems regarding DRB Systems, Inc.? Send feedback"/><META NAME="DOCNUMBER" CONTENT="r1.9 - 21 Mar 2006 - 16:46"/><META NAME="GENERATOR" CONTENT="DRB Systems, Inc. 04 Sep 2004 $Rev: 1742 $"/><META NAME="KEYWORDS" CONTENT="'zip'"/><META NAME="SUBJECT" CONTENT="'Practice PDF Creation'"/>'\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] Calling htmldoc with args: --book --quiet --links --linkstyle plain --outfile /tmp/GenPDFAddOn4u4O6SCzRW.pdf --format pdf12 --landscape --size letter --browserwidth 1060 --titlefile /tmp/GenPDFAddOnRVlHW74m8b.html --numbered --toclevels 5 --tocheader I.. --tocfooter .i. --firstpage toc --duplex --bodyimage c:/twiki/pub/wikiHome.gif --logoimage c:/twiki/pub/icn/bat.gif --top 0.5in --bottom 2.5cm --left 12pt --right 12pt /tmp/GenPDFAddOn7NXnfvEplr.html\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] child exited with value 1\n
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] [Mon Mar 27 20:48:07 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in string ne at (eval 59) line 31.\n
I'm now going to look closer at the reported error messages to see if I can determine why the PDF file isn't generating properly.
Issues:
- DEBUG Line 527 does not appear in the Apache error log. I assume this is because there is no new child of
$parent value to report.
- DEBUG Line 507 appears above. The next one that appears in the error log is DEBUG Line 544 ("preparing...").
I don't understand what the UNLINK debug lines do (Lines 557 and 569).
--
JasonVensel - 27 Mar 2006
From the grep man page:
-E, --extended-regexp
Interpret PATTERN as an extended regular expression
(see below).
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, sepa-
rated by newlines, any of which is to be matched.
-P, --perl-regexp Interpret PATTERN as a Perl regu-
lar expression.
Also,
In addition, two variant programs egrep and fgrep are
available. Egrep is the same as grep -E. Fgrep is the
same as grep -F.
So, I conclude if you are using
fgrep, you don't need the -F switch.
UNLINK => 0 : this tells the is Perl File::Temp module to
delete the
temporary file that is created by the function call, when the script exits.
This is interesting:
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] malformed header from
script. Bad header=HTMLDOC Version 1.8.24 Open So: c:/twiki/bin/genpdf
The HTMLDOC call is printing to STDOUT (or STDERR), which Apache is feeding
to your browser. This shouldn't be happening. The script should return a
proper header.
This next line is bad:
[Mon Mar 27 15:48:07 2006] [error] [client 127.0.0.1] child exited with value 1\n
This means HTMLDOC failed for some reason.
Try running HTMLDOC from the command line, using the same arguments as on
the line:
Calling htmldoc with args: That may tell you why it is failing.
--
ScottHoge - 28 Mar 2006
HTMLDOC from Command Line with Same Arguments
Here's what I did to successfully generate a PDF file out of an existing HTML file from a command line:
- Type
cd c:/cygwin/tmp.
- Press
Enter. Cygwin bash shell changes to a /tmp prompt.
- Type
htmldoc –-book --quiet --links --linkstyle plain --format pdf12 --landscape --size letter --browserwidth 1060 --numbered --toclevels 5 --tocheader I.. --tocfooter .i. --firstpage toc --duplex --top 0.5in --bottom 2.5cm --left 12pt --right 12pt c:/cygwin/tmp/GenPDFAddOn.html -f c:/cygwin/tmp/GenPDFAddOnTestB.pdf
- Press
Enter. HTMLDoc immediately converts the HTML file to a PDF file.
Note: My original configuration in TWiki specified a
bodyimage and
logoimage. Those did not prevent the PDF file from generating, but one of them (I suspect the
bodyimage setting) made the resulting PDF file unusable as each page was a tiled wallpaper of a TWiki logo image. I removed both settings from my command line and the PDF file was generated with the correct visible text. Based on this, I commented out the same settings in my
TWikiPreferences and then tested the PDF link from within TWiki. No luck; still getting the same errors.
Suggestions?
Line 613 in GenPDF.pm
What effect, if any, does Line 613 in
GenPDF.pm have on all this?:
$ENV{HTMLDOC_NOCGI} = "yes";
Note: If I comment it out and run the PDF script, Internet Explorer immediately displays a blank page with the following message (the temporary PDF and HTML files are generated):
HTMLDOC Version 1.8.24 Open Source Copyright 1997-2004 Easy Software Products, All Rights Reserved.
This software is governed by the GNU General Public License, Version 2, and
is based in part on the work of the Independent JPEG Group.
Content-Type: application/pdf
I see that
application/pdf comes from Line 629 in
GenPDF.pm. I also assume that the HTMLDOC Version and copyright message come from HTMLDOC files, I'm just not sure which one.
uninitialized value in string ne
Based on some debugging I did, it appears that this error message:
Tue Mar 28 08:46:09 2006] [error] [client 127.0.0.1] [Tue Mar 28 13:46:09 2006] c:\\twiki\\bin\\genpdf: Use of uninitialized value in string ne at (eval 59) line 31.\n
occurs as a result of this chunk of code being processed/compiled:
# output the HTML header and the output of HTMLDOC
if ($prefs{'format'} =~ /pdf/) {
print $query->header( -TYPE => "application/pdf" );
I'm not sure what the error means or whether it's relevant.
--
JasonVensel - 28 Mar 2006
One final note for today: If you look at the "Calling htmldoc with args..." error that appears in my Apache error log, I see that there are HTMLDOC "codes" for
--outfile and
--titlefile, but none for the temporary html file.
Is this relevant?
--
JasonVensel - 28 Mar 2006
Just for fun, I decided to see what would happen when I set
$TWiki::htmldocCmd = "c:/Program Files/Mozilla Firefox/firefox.exe"; in my
/lib/TWiki.cfg file. Everything else was left unchanged. I tested the "Create PDF" link I inserted in my
Bulletins.DVRCameraSetup topic and clicking this link opens Firefox in a new window. My
Bulletins.DVRCameraSetup topic remains visible the entire time and the Internet Explorer progress bar located in the bottom left of the screen moves from left to right about 1/2 way and then just hangs there. I suspect this may be a result of the
@htmldocArgs portion of the
system($TWiki::htmldocCmd, @htmldocArgs
); call in Line 614 in my
GenPDF.pm file. Not sure though. My Apache error log shows the following corresponding messages:
[Wed Mar 29 08:50:17 2006] [error] [client 127.0.0.1] Calling htmldoc with args: --book --quiet --links --linkstyle plain --outfile /tmp/GenPDFAddOnztP1g0868F.pdf --format pdf --portrait --size letter --browserwidth 1060 --titlefile /tmp/GenPDFAddOnRGg2YOpavs.html --numbered --toclevels 5 --tocheader I.. --tocfooter .i. --firstpage toc --duplex --top 0.5in --bottom 2.5cm --left 12pt --right 12pt /tmp/GenPDFAddOnxZssSY6CMN.html\n
[Wed Mar 29 08:50:17 2006] [error] [client 127.0.0.1] [Wed Mar 29 13:50:17 2006] c:\\twiki\\bin\\genpdf: Can't exec "c:/Program": No such file or directory at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 614.\n
[Wed Mar 29 08:50:17 2006] [error] [client 127.0.0.1] [Wed Mar 29 13:50:17 2006] c:\\twiki\\bin\\genpdf: Failed to start htmldoc (c:/Program Files/Mozilla Firefox/firefox.exe): No such file or directory\n
[Wed Mar 29 08:50:17 2006] [error] [client 127.0.0.1] [Wed Mar 29 13:50:17 2006] c:\\twiki\\bin\\genpdf: at c:/twiki/lib/TWiki/Contrib/GenPDF.pm line 615\n
So it looks like TWiki can call/start 3rd-party applications just fine. That suggests the problem lies with HTMLDOC. What puzzles me is that I can run HTMLDoc from a command line (htmldoc.exe), I can run HTMLDoc using the graphical user interface (ghtmldoc.exe), and I can create and run my own temporary generate pdf CGI script (using htmldoc.exe).
I ran this same test for WordPad and it starts WordPad. I should note that when WordPad is started, a dialog box appears with the following message:
c:\twiki\bin\plain
Cannot find this file.
Please verify that the correct path and file name are given.
If I click
OK, the dialog box and WordPad immediately close. Nothing relevant appears in the Apache error log. What does
c:\twiki\bin\plain refer to?
--
JasonVensel - 29 Mar 2006
Based on my most recent troubleshooting (see my entries on 29 Mar 2006), I have decided to reinstall HTMLDOC. I would greatly appreciate it if someone who's had experience using the
GenPDFAddOn (preferably on a Windows machine running Cairo) would suggest an ideal location from which to obtain a copy of HTMLDOC (or alternatively, just attach the install file to this topic) - I'm trying to eliminate as many variables as possible and would like to use an known-working install of HTMLDOC.
This is mostly a "shot in the dark" attempt to resolve the issue since I can run HTMLDOC from a command line, using the HTMLDOC GUI, and from a self-created perl script (see tempgenpdf above). For whatever reason, TWiki can't launch HTMLDOC.
Thanks.
--
JasonVensel - 30 Mar 2006
The one manual change I made to get TWiki to locate htmldoc was in GenPDF.pm, instead of TWiki.cfg as the Install instructions specify since that was probably for pre-Dakar installs.
From GenPDF.pm on line 375 (grep for the string below in case you're using a different version of this addon):
# $TWiki::htmldocCmd must be set in TWiki.cfg
On the following line specify the location of your htmldoc executable, like ..
$TWiki::htmldocCmd = 'c:/HTMLDOC/htmldoc.exe';
My suggestion would be to try this on an otherwise unmodified version of
GenPDF.pm (i.e. sans your other changes). The above should obviate the need to specify the location of the htmldoc executable anywhere else including LocalSite.cfg. Finally, if you're using mod_perl with Apache, bounce Apache after you've made the above change. HTH.
--
KalDe - 30 Mar 2006
I just uploaded a fresh patched release, suitable for use with TWiki-4 (and should still work on Cairo). However I have
not tested on Windies.
--
CrawfordCurrie - 05 Apr 2006