Forum archive 2000-2006

Christopher Harrington - Fixing PDF generation problems...

Christopher Harrington - Fixing PDF generation problems...

by Arnold Pizer -
Number of replies: 0
inactiveTopicFixing PDF generation problems... topic started 5/18/2001; 5:13:35 PM
last post 5/18/2001; 5:13:35 PM
userChristopher Harrington - Fixing PDF generation problems...  blueArrow
5/18/2001; 5:13:35 PM (reads: 1585, responses: 0)
One of the major problems that we ran into while installing our Debian WeBWorK system was trying to generate hard-copy working PDF files and send them across the server so a user could receive them.

Here's a summary of our findings and some suggestions if you are having problems. ============================================================

Part I: Local Software Problems

1. First make sure have a current version of Adobe Acrobat (or another PDF file viewer) installed, and set to read PDF files. We found that it was best to have Adobe open the files in it's own window (not in the browser). To do this, open Adobe and go Edit -> Preferences -> Options and then uncheck "Display PDF in Browser".

2. Update your browser to the latest version. We were having problems with Microsoft Internet Explorer 4.0, but things started going better after we moved up to IE version 5.5.

3. After you click "Get_hard_copy" and have PDF chosen, another window might pop-up. It says, "You have chosen to download a file from this location." If it says, "welcome.pl from [servername]" then choose "Open the file from its current location". Usually, this will happen again. Do the same thing. On the third time, the server will display the same message but instead the file will be "[setname].pdf from [servername]". We recommend saving this file to the hard-drive and then opening in the viewer. See Step Four for more details.

4. If you open the file in your PDF browser and it doesn't work it is very possible that the PDF file you got in the first place wasn't working. Save the file (see step 3) and look at the filesize. If it seems too small that usually indicates a problem over on the WeBWorK server.

5. If you receive an "Internal Server Error" message when you click on "Get_hard_copy" that usually means that Apache isn't able to return any data because something else (often PERL) crashed and returned an error message. This is a WeBWorK server problem. =================================================================== Correcting Problems on the WeBWorK server.

First, an outline of how a PDF file is generated: welcomeAction.pl (located /usr/local/webwork/system/cgi/cgi-scripts/ on Debian configuration) processes the "Get_hard_copy" button and assuming you have selected a valid set, begins generating a TeX file. [.tex] welcomeAction translates each problem in the set into TeX and creates a huge string which it writes to disk as a TeX file. Then, makePS (located /usr/local/webwork/system/scripts in Debian) is ran. It generates two files: a postscript [.ps] from the TeX file and then a Device Version Independent [.dvi] file which is generated from the postscript file. Next, a makePDF script (located /usr/local/webwork/system/scripts in Debian) creates a Portable Document Format [.pdf] using the postscript file.

Note, more TeX tools exist widely distributed format since welcomeAction was originally written. Therefore, now we can translate the .tex file directly into .pdf!

Problem: You are getting an "Internal Server Error" when you try to "Get_hard_copy" Reason: This means that Apache isn't able to return a correct page usually because it did not receive a usable message from the system. This usually means that PERL crashed and is giving an error message to Apache that it can't understand. Solution: Find which script is failing and directly run it from the server. It will most likely give you an error message and possible lines that can't understand. A possible source of this error was editing a file without word-wrap and some comment got moved to it's own line. Use -w switch with nano to avoid this! EXAMPLE: >./welcome.pl "use" not allowed in expression at ./welcomeAction.pl line 12, at end of line syntax error at ./welcomeAction.pl line 12, near "use lib " BEGIN not safe after errors--compilation aborted at .welcomeAction.pl line 17.

Problem: PDF File that is sent to user is invalid or does not exist. Reason: There is most likely a problem in generating the files. Order of file creation: 1) set.tex (from problems in set) 2) set.ps (from .tex file) 2b) set.di (from .ps file) 3) set.pdf (from .ps file)

Solution: At the beginning of welcomeAction.pl there is a line that reads: "my $debugON=0; ## set this to 1 to save debugging information for errors ..." If you change the number to 1 then debug mode is ON. This means that the files will also be saved in the temp directory when generated. So, you can now go look in /usr/local/webwork/courses/demoCourse/html/tmp and you should find the set.tex, set.ps, set.dvi, and set.pdf files!

If Post-Script files are working, but PDF file is invalid (possibly suspiciously small) then most likely the ps2pdf conversion is failing. This could because you are getting an "invalid font" message. Try "ps2pdf set.pdf newset.ps" and observe error messages. Either way, we can use a different utility. "pdflatex newset.pdf set.tex" will generate a PDF file directly from the TeX source. Try this. If it works then you'll want to edit makePDF to reflect these new changes.

Editing makePDF: In Debian this script is located in, /usr/local/webwork/system/scripts/makePDF Load the file in your editor and change .ps to .tex and change "ps2pdf" to "pdflatex".

If your system doesn't have "pdflatex" then you can get it in the "tetex-bin" library. To retrieve this file, use "apt-get install tetex-bin" while as root.

Hopefully, in the next distribution of WeBWorK we'll split welcomeAction.pl into several files and correct makePS and makePDF so only they generate files when needed. (Currently, a .ps file is generated despite the fact that .pdf can be made directly from .tex)

Chris Harrington

<| Post or View Comments |>