best width of HTML/PDF document for printing

12,673

Solution 1

Pixels and Dots-Per-Inch are different beasts entirely, there is no simple way to translate from one to another. Obviously, then, I suggest not trying to do so.

Instead, I'd suggest using a print style-sheet and defining widths and sizes in relevant terminology for the medium, such as pt (point), pc (picas), cm, mm or in (centimetres, millimetres or inches)...

Solution 2

Printing is generally specified in mm rather than pixels. I would suggest calculating to the paper size you're targeting.

See: http://www.unitconversion.org/unit_converter/typography.html

Solution 3

The best approach is to make all the parameters configurable (with some common default values): width, height, and px/pt ratio. For US you may neeed USLetter, for Europe, Russia - A4. px/pt is a hardware dependent parameter. You can make it configurable to fit different needs. P.S. All these come from my 6-year experience on XML to PDF software.

Share:
12,673
Ilian Andreev
Author by

Ilian Andreev

Senior Full Stack Developer, proficient either on the backend or frontend in different fields like bespoke eCommerce, SaaS solutions, Crypto Blockchain systems and more. Strong communication skills and experience working remotely in distributed teams across the world.

Updated on June 17, 2022

Comments

  • Ilian Andreev
    Ilian Andreev almost 2 years

    I'm creating HTML documents for printing, by testing I found that width of around 650px is close to the margin. It's also good for PDF documents since I need to convert the HTML to PDF if the client wishes to.

    Can you tell me what is the suggested width in px for a print HTML document, that afterwards needs to be converted to PDF? I know these are relative to the DPI and stuff like that, but there should be a simpler guide to this .... e.g. most of the sites that can offer printing of certain pages, have a fixed width of around 600px for the content.

    Thanks

  • Adam Heeg
    Adam Heeg almost 8 years
    Certainly a page width of 1200px would be less advantageous than one of 700px, right? Can you make a range suggestion based on your experience?