Measurement unit and DPI

Hi Folks,

As far as I know PDF is DPI independent. However, when I call GetWidth/GetHeight on PageInfo I get the dimension in pixel unit with 72 dpi resolution instead of inch or millimeter or anything not related to DPI. When I would like to put a watermark on a page I have to set its size in pixel unit instead of inch or millimeter. Would it be possible to use DPI independent measurement when getting/setting sizes on a PDF document? Currently I don’t find any possibility to add any image to the document in better quality than 72 DPI.

I hope I could describe my issue clearly.

Thanks in advance.

Regards,|
Richard

Hi Richard,

You’re right the PDF files are DPI independent and the DPI only comes to play when you render the PDF file; also, it depends upon the DPI of the device the PDF is rendered on. However, in order to perform calculations, the unit of the measurement is pixel. Moreover, the size returned by GetPageHeight and GetPageWidth methods is the size of the MediaBox.

As far as your issue of adding image is concerned, could you please elaborate it with the help of the sample PDF, image and code snippet which you’re using at your end? We’ll look into it in detail and let you know the results.

We’re sorry for the inconvenience.
Regards,

Hi,

Thanks for you answer.

So, the API generates PDF DPI independently from other file formats, however when I try to get size info or set watermark images the API renders the PDF in 72 DPI resolution to perform the task. Is it correct?

Am I able to set your API to render the pdf in 300 DPI for me? For example when I set watermark images on the pages. On the other hand, in my understanding when I get PageWidth/Height for Press printing purposes I need the size of the TrimBox and not the MediaBox. Am I right?

Regards,
Richard

Hi Richard,


r1cs4rdz0n:

So, the API generates PDF DPI independently from other file formats, however when I try to get size info or set watermark images the API renders the PDF in 72 DPI resolution to perform the task. Is it correct?


Yes, that’s correct.

r1cs4rdz0n:

Am I able to set your API to render the pdf in 300 DPI for me?


I’m afraid, this is not feasible.

r1cs4rdz0n:

For example when I set watermark images on the pages. On the other hand, in my understanding when I get PageWidth/Height for Press printing purposes I need the size of the TrimBox and not the MediaBox. Am I right?


I’m sorry, I couldn’t understand your requirement clearly. Could you please elaborate what exactly are you trying to achieve using Aspose.Pdf.Kit and where are you having the problem, so I would be in a better position to understand and then guide you? If you could share some sample document(s) and code snippet, that will be helpful.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,