Print Page | Close Window

Best way to handle images - pixels and millimeter

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2042
Printed Date: 04 Apr 26 at 7:03PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Best way to handle images - pixels and millimeter
Posted By: that0th3rGuy
Subject: Best way to handle images - pixels and millimeter
Date Posted: 16 Nov 11 at 7:04AM
Good day,

I am currently using QuickPDF 7.16

The FAQ post  http://www.quickpdflibrary.com/faq/i-want-to-draw-an-image-onto-a-pdf-but-the-page-size-is-in-millimeters-and-the-i.php - http://www.quickpdflibrary.com/faq/i-want-to-draw-an-image-onto-a-pdf-but-the-page-size-is-in-millimeters-and-the-i.php  refers.

The mentioned post helped a little bit, but I still don't know how I am going to draw my pixel-measured image onto a millimeter-measured document accurately every time regardless of environment. I can't really make an assumption as to the dpi configuration on a client's machine.

I there a way to programmatically determine Acrobat's dpi settings in order to generate a PDF document accordingly?

Thanks



Replies:
Posted By: AndrewC
Date Posted: 16 Nov 11 at 7:59AM
points, mm and mm are constant measurements.

You need to work the other way around.  You need to determine the DPI from the image and use that to determine how big to draw the image.

  QP.ImageHorizontalResolution()
  QP.ImageVerticalResolution()

  QP.ImageWidth() and ImageHeight() will return the pixel width and height of your image.

From here you can work out the physical size of the image.

  ImageWidthInInches = QP.ImageWidth() / QP.ImageHoizontalResolution();
  ImageWidthInmm = ImageWidthInInches * 25.4


7.16 is an older version and there have been may bug fixes.  You are entitled toa free upgrade to the 7.26 version which can be downloaded from

http://www.quickpdflibrary.com/downloads/binaries/qp/oldversions/0726/quick_pdf_library.exe

Andrew.




Posted By: that0th3rGuy
Date Posted: 16 Nov 11 at 8:54AM
Alright, thanx; I'll give that a go.

In the meantime could you please explain something to me?
The documentation says that ImageHorizontalResolution() and ImageVerticalResolution() respectively returns the horizontal and and vertical resolutions of the selected image. Does that mean that I'll need to add the image, determine resolution, remove the image, do the calculation and then add the image with it's new dimensions?

Thanx.


Posted By: AndrewC
Date Posted: 16 Nov 11 at 10:27AM
No.

You can add the image which add the pixel scanline as a resource in the PDF.  You then obtain the resolution.   A 100 x 100 pixel image will always remain that size in pixels.  When you draw the image it is scaled to the size required.  If you told it to draw a 100x100mm image then each pixel could would be 1mm square on the page.

Andrew.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk