> To get the desired result, set page size to
> letter, horizontal margins to 1 inch, and change
> body width from 234pt to 175.5pt.
> Here is an explanation:
> Browsers render HTML at 96 CSS pixels per inch
> whereas PDF uses 72 DPI.
> So, 72 pts in HTML is 96/72=1.333 inch in PDF.
> Similarly, 1 inch in PDF is 72/96=0.75 inch i.e.
> 54 pts in HTML.
> So, to get 3.25'' in PDF you must specify 3.25 *
> 54 = 175.5 pts in HTML.
I was just wondering if my equations below are correct...PDF Settings
(96 / 72) = 1 pdf inch
(96 / 72) * 11.7 = 11.7 pdf inches
((96 / 72) * 11.7) * 96 = 1497.2256 (CSS Pixels Height)
((96 / 72) * 8.3) * 96 = 1 062.4 (CSS Pixels Width)
Obviously if you have got margins set then you will need to convert both the pdf page width or height and horizontal or vertical margin into the same unit of mesurement. Then subtract the margin width from the pdf page size (width or height) and then use the equations above. See example below...PDF Settings
Margins: 30mm Horizontal
, 25mm Vertical
In this example we will calculate the page height...
1 inch is 25.4 mm
(30 / 25.4) = magrinWidth
But do not forget that setting horizontal margin will give a header and footer margin, vertical will set left and right margins. Therefore we need to multiply the result by two to get the total margin width for that page axis.
((30 * 2) / 25.4) = magrinWidth
Now that we have converted the total margin width into the same units as the page height we can now use our original equation to work out the total page height in CSS pixels.
((CssInch / pdfDpi) * (page height - totalMarginWidth)) * CssInch = TotalCssPixelHeight
((96 / 72) * (11.7 - ((30 * 2) / 25.4)) * 96 = 1195.2378 (Css Pixels Height)
It is working pretty good but that was based of a estimate I made for the total css pixels height for the PDF. When I saw this page I thought that I could work out the propert widths and heights of a page based on the information read in the quoted bit of this post.
I was just wondering if you help me to ensure that I have got the correct equations and if so I would suggest to create a section on the API page with this information "Calculting Css Pixels For PDF Dimensions" so that others can use this very useful information.
Many thanks in advance,