Tags:
create new tag
view all tags

SID-00151: Using GenPDFAddOn

Status: Answered Answered TWiki version: 4.2.4 Perl version: Active Perl 5.10
Category: GenPDFAddOn Server OS: Win Server 2003 Last update: 16 years ago

I have a problem getting GenPDFAddOn to work. I have experienced several issues but now when I try from the URL with genpdf instead of view (for testing purposes) i get:

Premature end of script headers: genpdf

I understood that proves that there is a problem with the rights set on the scripts but they are ok....public

This is the path to the htmldoc exec $TWiki::cfg{Extensions}{GenPDFAddOn}{htmldocCmd} = 'C:/HTMLDoc/htmldoc.exe';

I should mention that twiki is on my D drive. I used HTMLDoc for mediawiki as well so I know that the installation is correct and that it normally works. Could anyone help me?

-- RoxanaCraciun - 03 Mar 2009

Discussion and Answer

Just checking: have you edited the shebangs in /bin/genpdf and /lib/TWiki/Contrib/GenPDF.pm to fix the Perl path?

-- SeanCMorgan - 03 Mar 2009

Yes. I set the same path that the other scrips have so this should not be the problem. However I am unclear with regard to -wT. or -wI.

Now is set to #!d:/cygwin/cygwin/bin/perl -wI.

More details regarding the configuration:

$TWiki::cfg{Extensions}{GenPDFAddOn}{htmldocCmd} = 'C:\HTMLDoc\htmldoc.exe';

if the path is set like this I get generated 2 html files and one pdf. One html and the pdf are empty (0k), while the other html has smth but I cannot see what because it says I don't have access. That is actually strange that I cannot visualize the code behind the files. Do you have any idea how to set free permisions on the tmp file of cygwin from cygwin shell? Maybe this is the problem....

-- RoxanaCraciun - 04 Mar 2009

Generated PDFs were blank in Adobe 8.1 (but not FoxitReader) because of embedded fonts: removing those makes for smaller but less portable PDF files.

Modify /lib/TWiki/Contrib/GenPDF.pm (down near the end, where all the other arguments are added) to add an extra argument:

push @htmldocArgs, "--no-embedfonts"; # required with Adobe 8.1.

Also, here another parameter you might need:

push @htmldocArgs, "--no-compression"; # Work-around for occassional image corruption

-- SeanCMorgan - 04 Mar 2009

unfortunately it still doesn't work. Now i cannot manage to generate not even the html. I don't know what is the problem frown some other suggestions?

-- RoxanaCraciun - 10 Mar 2009

I've made things worse?! It wouldn't be the first time smile

You could try removing the warning flag entirely (-wT). I had to do that to get my form of PDF options to work (I never did figure out where the taint was coming from). [To see what I mean by an options form, see my attachment of 29 Jul 2008 at GenPDFAddOnDev].

I found cygwin permissions to be a constant headache, but things are much better now that I'm using ActivePerl. But to reset them, you need to do something like this:

cd /twiki
chmod 775 -R data pub bin lib tools

One more thing: is there any more information in your Apache or TWiki logs?

-- SeanCMorgan - 10 Mar 2009

Sorry, I cannot find anything in any log :(( I am starting to get desperate. Why can't I get not even a html? Where can it crash?

So when i try getpdf instead of view I get a white page with the status done. However there is nothing generated on the server.... any clues for what I should look for...?:(

-- RoxanaCraciun - 12 Mar 2009

A few more things to try...

In addition to setting {Extensions}{GenPDFAddOn}{htmldocCmd}, I had to have the HTMLDOC directory in the PATH environment variable for the Apache process.

It seems to be mandatory to have a level 1 header in your document (---+). That's been a common problem in the past, and I'm not sure the bug has been fixed yet.

Also, according to GenPDFAddOnDev, the permissions should NOT be public:

Just a point-out regarding an installation issue I ran into. I was getting a Browser error - premature end of headers. With no apparent errors logged. It turns out that bin/genpdf is installed by default as group writable. Apache su_exec functionality will not run anything that is writable by any other userid. chmod 755 bin/genpdf resolved the issue.

If that doesn't help, you could try increasing the logging. Unfortunately this add-on doesn't have a debug flag: you would have to edit the file /lib/TWiki/Contrib/GenPDF.pm and uncomment the lines with the word 'DEBUG'.

-- SeanCMorgan - 12 Mar 2009

I ended up debuggin in a nasty way...but i feel pretty confused. Why:

# Save this to a temp file for htmldoc processing my ($cfh, $contentFile) = tempfile('GenPDFAddOnXXXXXXXXXX', DIR => File::Spec->tmpdir(), UNLINK => 0, # DEBUG SUFFIX => '.html'); open $cfh, ">$contentFile"; print $cfh $hfData . $htmlData; close $cfh; push @contentFiles, $contentFile;

Here the $htmlData has the html file, but it does not write it in the html.

I commented the lines where the temporary files were deleted and now i see it generates 2 htmls and one pdf. I think there is a problem at print or at opening the temporary file to write it in, but I don't understand why because on the /cygwin/tmp directory the admin and the sys have full control.

Plus, when I am trying to open the temporary files it does not allow me....this i really don't understand.....

So until generating the pdf I am looking at getting the right html content in the temporary hmtl file. I am not there yet.

Btw. I modified the permissions...everyting is writable in twiki for troubleshooting purposes. I would do that with all cygwin dir but i cannot manage to get to it....any ideas? frown

-- RoxanaCraciun - 13 Mar 2009

A few more things to try :

  • For cygwin installations, add /cygdrive/c/windows/system32 and "pathtohtmldoc" to the SafeEnvPath variable ( configure-> Security setup -> Paths -> SafeEnvPath ). Validate these settings on a dedicated machine before production environnement ( see PublishContribPDFproblem)
  • Use
    <!-- PDFSTART -->
    and
    <!--PDFSTOP-->

-- OlivierThompson - 13 Mar 2009

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- PeterThoeny - 2009-04-17

Hi again, sorry for reopening this but I have another question.

In GenPDF.pm the file used by HTMLDoc to write in is calling the arguments + /tmp/theFile.html. However the path is not good because I am running a windows server 2003 and it accepts only on the form: c:\\cygwin\\tmp\\theFile.html.

Unfortunatelly I don't know how to change that in perl, i.e. I have no clue how to manipulate @contentFiles to indicate the path under the right form.

I have encountered this problem with the paths when I was using in MediaWiki an extenstion which was using HTMLDoc.

Thanks in advance!

-- RoxanaCraciun - 2009-04-27

I'm using Windows 2003 as well. Whenever possible, I try to avoid using the backslash in paths because it can work sometimes but then break when it happens to run into something it interprets as \n (e.g., \newfile.html).

Perhaps your other path settings are colliding with GenPDF? For example, here's what I have in LocalSite.cfg:

$TWiki::cfg{DataDir} = 'D:/TWiki/data';
$TWiki::cfg{WorkingDir} = 'D:/TWiki/working';
$TWiki::cfg{SafeEnvPath} = 'C:\\windows\\system32';

Warning, important The last one displays as C:\windows\system32 when viewed with /bin/configure. But I use ActivePerl instead of cygwin, so yours would be /cygdrive/c/windows/system32

-- SeanCMorgan - 2009-04-27

Hi!

In GenPDF.pm I have commented the parts with unlinking the file, so I see that I get 2html files generated and one pdf in D:\cygwin\cygwin\tmp. For example:

GenPDFAddOnDBjL2qsEor.html - 0 byte GenPDFAddOnexUhjrGm72.html - 5 byte GenPDFAddOnG2AvPT_pqs.pdf - 0 byte

Now I printed out from GenPDF.pm the arguments that I passed to htmldoc.exe : Calling htmldoc with args: --book --quiet --links --linkstyle plain --outfile /tmp/GenPDFAddOnG2AvPT_pqs.pdf --format pdf14 --portrait --size a4 --browserwidth 860 --titlefile /tmp/GenPDFAddOnDBjL2qsEor.html --toclevels 5 --tocheader ... --tocfooter ..i --firstpage toc --no-embedfonts --no-compression /tmp/GenPDFAddOnexUhjrGm72.html

I am not sure if it is ok, but I tried to run this from the command line and it just with /tmp/theFile or with the whole path and it says: "No HTML Found!", although I can clearly see the files in tmp folder.....

Any other hints?:(

Thanks in advance

-- RoxanaCraciun - 2009-04-28

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- PeterThoeny - 2009-06-02

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title Using GenPDFAddOn
SupportCategory GenPDFAddOn
TWiki version 4.2.4
Server OS Win Server 2003
Web server Apache 2.2.10
Perl version Active Perl 5.10
Edit | Attach | Watch | Print version | History: r15 < r14 < r13 < r12 < r11 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r15 - 2009-06-02 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.