< Day Day Up > |
Print via HTTP by submitting your print streams as HTML form data . Printing over the Internet brings the way people like to read and write to the way we plumb information in the 21st century. The idea is to enable authors to create documents using their favorite editor and then print it to a web site. Once on the web server, the PostScript print stream can be converted to PDF and posted online for reading or downloading. In this scenario, the author controls the source document and is responsible for maintenance.
This hack demonstrates how to "print" a PostScript print stream to a web server. In our examples, we won't be printing to an elaborate document hosting service. Instead, we will print to the simple http://www.ps2pdf.com web site.
4.17.1 Download and InstallVisit http://www.pdfhacks.com/submit_file/ and download submit_file-1.0.zip . Unzip this archive, and then copy SubmitFile.exe to a convenient location. This is a simple program that uses the Windows WinInet API to submit a local file to a web server. It then opens the default web browser to view the server's response. The source code is available and you should consult it for HTTP submission details. 4.17.2 Install a ps2pdf.com PrinterThe procedure for creating an Internet printer is the same as the procedure for creating the PDF printer in [Hack #39] , except you don't need to install Ghostscript. The configuration is also a little different. Follow the Print to PDF instructions, except:
The RedRun program takes the PostScript print stream and creates a temp file for it. RedRun then runs the program SubmitFile, replacing the %1 with the temp filename. Note that you should not put quotes around this %1 , because RedRun seems to pad the temp filename with whitespace that disrupts the SubmitFile arguments. You can run SubmitFile from the command line, which is useful for debugging. It takes arguments in order: SubmitFile <cgi path> <cgi server name> \ <html form field name> <local filename of upload> 4.17.3 Test Your ps2pdf.com PrinterOpen the ps2pdf.com Printer properties dialog, click the General tab, and click Print Test Page. When your PDF is ready for download from http://www.ps2pdf.com, a browser will open with a hyperlink to follow. If an error occurs, check the log file for feedback from RedRun or SubmitFile. Note that the previous configuration is tailored to the current state of http://www.ps2pdf.com. The site administrators might choose to alter it at any time, requiring you to change this printer's configuration. |
< Day Day Up > |