Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


HTML Becomes PDF - Page 3

August 28, 2000

As you've probably guessed by now, we're going to create PDF output by converting HTML into PDF. This is not a perfect solution, for several reasons:

  • Unless our Perl script has already been coded to produce HTML output, this could be seen as a circuitous extra step.
  • The HTMLDOC program does not always yield perfect reproductions of HTML pages, especially very complex pages. It also does not yet support style sheets.
  • Integrating HTMLDOC into our Perl scripts will require making a system call, which costs us some processing time.

We proceed nonetheless, because HTMLDOC also offers several palpable advantages for generating PDF output from Perl back-end scripts:

  • Most such Perl scripts are already coded to produce HTML output.
  • Developers working with Perl as a back-end to web sites are likely more familiar with HTML than PDF, and so simple formatting of results is much quicker to implement with a known language (HTML) than an unknown (PDF).
  • It gets the job done with the least development effort!

From the commandline, we can send a stream of HTML to HTMLDOC using a pipe, while instructing HTMLDOC to return the results to standard output. We can simply whip up a PDF file for a small web page as follows:

prompt> echo "<H2>Results</H2><TABLE><TR><TD>Score</TD><TD>95</TD></TR></TABLE>" 
| htmldoc --webpage -t pdf - > resultTable.pdf

Note that in the example above we've line-wrapped the code at the pipe symbol (|), but in reality the command is one long line. The logic: send the text contained in the echo call to the htmldoc program, which accepts the text as a web page and spits the PDF results out, which we redirect to the file resultTable.pdf. Were we to open this masterpiece in Adobe Acrobat, the results would gleam forth:

Skipping the Learning Curve - Page 2
The Perl You Need to Know
Enter the Perl - Page 4


Up to => Home / Authoring / Languages / Perl / PerlfortheWeb




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers