in reply to Generating pdf file for and from an html file

This has been tried many times, but I have never seen a generally acceptable solution for converting a webpage to a PDF-file. It might be possible for very specific, narrowly defined and formatted webpages based upon a template where the variable data can be plugged both into an HTML and a PDF template.

The main problem is that the HTML format is geared towards very fluid and flexible rendering, all depending on the output device whereas PDF is a format for a page, where pagination, position of pictures, font size and type, ... are all most strictly defined.

If you do not care about an exact 1-to-1 rendering between the webpage and the PDF file and the HTML does not try to "fix" the lay-out but rather uses the tags as semantic and structural guides, then it might just be possible to write a parser that can translate HTML to another format (I was thinking of TeX or LaTeX) that can be rendered into a PDF-file.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics
  • Comment on Re: Generating pdf file for and from an html file