I am trying to render a view to a PrintedPdfDocument. The size of the page, as expected, is in units 1/72nd of an inch. So, for an A0 size page (width = 33.11 in), document.getPageWidth()
returns 2384 (33.11 * 72). The page canvas width equates one pixel to one 1/72nd of an inch unit - so, pageCanvas.getWidth()
returns 2384. This is true on different devices. So far so good.
The problem I am facing is that on different devices, the generated PDF document for the same view looks different. On some devices it is stretched on the PDF page, and on somes devices it renders as it should.
What could be the issue here? Isn't the generation of the PDF supposed to be device independent? I noticed that pageCanvas.getDensity()
is different on different phones. Why does the phone screen density impact the density of the PDF page canvas?
Given that the numerically document.getPageWidth()
in 1/72nd of an inch == pageCanvas.getWidth()
in pixels, shouldn't pageCanvas.getDensity()
always be 72 DPI? On some phones it is 320 (where it shows correctly) and on others it is 420 (where the view is rendered stretched).
A bit stuck here, so would really appreciate any pointers. Thanks in advance!