[dompdf] DPI, background images, final PDF size

4,872 views
Skip to first unread message

kudy

unread,
Apr 20, 2010, 7:02:39 PM4/20/10
to dompdf
I might be a bit confused here, but I am trying to figure out why the
final display size of the PDF I am generating doesn't match up to the
dimensions specified by "PAPER_SIZES" in dompdf.

I am creating a "legal" size document, with DPI set to "72".

Each page of my document is an HTML table element set to 612x1008px
(the size of a "legal" document), with a background image of 612x1008
pixels. The PDF generates fine, with the background image filling the
entire page, as it should, but it only looks non-distorted when the
zoom is at 64%. If I change the zoom to 100% when viewing the PDF,
the page is displayed at 934 pixels wide, and not the 612 I would
expect, and images are distorted. It is 612 pixels wide at 64% zoom.

I might be missing something simple here, but I can't make sense of
what's going on, and why I am seeing a seemingly larger than 72 DPI
for the PDF document, but the images still fit in the background? Any
help or clues you can give me would be appreciated, thanks.

--
You received this message because you are subscribed to the Google Groups "dompdf" group.
To post to this group, send email to dom...@googlegroups.com.
To unsubscribe from this group, send email to dompdf+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dompdf?hl=en.

kudy

unread,
Apr 21, 2010, 5:05:56 PM4/21/10
to dompdf
So the background image is at 72 dpi for sure, since it fills the
background - the rest of the elements on the page don't seem to match
the correct pixel dimensions at 72 dpi.

I would use percentages to set height and width on table elements, but
I am having the user submit photos, and need to specify the pixel
dimensions of their uploads, and I would also prefer to set the table
dimensions with pixels.

What am I missing here? Why does my 612 pixel wide table only reach
2/3 of the way across the final PDF, if the result *should* measure
612 pixels wide?

BrianS

unread,
Apr 23, 2010, 11:42:31 PM4/23/10
to dompdf
Which version of DOMPDF are you using? I tested this out using DOMPDF
0.6.0 beta 1 with a basic page and it looks correct. See here:
http://eclecticgeek.com/dompdf/index.php?input_file=9941eb38c9fbd639.htm&paper=legal&orientation=portrait&dpi=72&dompdf_ver=trunk&load_method=1

If you can post a sample document I can try it out.

kudy

unread,
Apr 26, 2010, 11:34:07 AM4/26/10
to dompdf
Hi Brian, I am using 0.5.1, I will try the 0.6.0 beta 1 and let you
know if it helps fix things. Here is a sample of the problem I am
encountering:

http://www.ccseo.com/dompdf/sample.zip

I'll let you know how the beta version works, thanks.

kudy

unread,
Apr 26, 2010, 11:53:56 AM4/26/10
to dompdf
Brian, I've just tried it with the 0.6.0 beta, and I am getting the
same result.

One thing I don't understand, is why is it that at 100% zoom, the 612
pixel width is shown at 934 pixels (on your example as well)? As you
can see in my sample download, the background image fits the page fine
(at 612 pixels), but the table holding the content of the page doesn't
seem to match up to the 612 pixel width that the document is supposed
to be at 72 dpi. Am I just not grasping how this works, or is this an
actual bug/error - maybe I just don't understand how the dimensions
work? You'll also notice, the embeded image on the first page of my
sample doesn't seem to be displaying at 72 dpi either.

Thanks,

-Kevin

BrianS

unread,
May 3, 2010, 9:35:31 PM5/3/10
to dompdf
I'm not entirely sure I understand what the problem is with your
output. It appears to be correct to me, based on the HTML (though I
could be missing something). Is this what you're seeing?
http://eclecticgeek.com/dompdf/index.php?input_file=9941eb38c9fbd639_user.htm&paper=legal&dpi=72&dompdf_ver=trunk&load_method=1

I'm not sure why at 100% zoom your PDF would span 934 pixels on the
screen. It could have something to do with the PDF viewer, your screen
resolution or screen DPI. I haven't measured the pixel span on my own
monitor, but it appears to be correct.
Reply all
Reply to author
Forward
0 new messages