Determine DPI (resolution) used in Acrobat document with API

I'm extracting pages to a JPG image (using the JSObject), however I want to know the Height and Width (in inches) of the Page before I extract it (so I can store it for later use).

I can get the X and Y in pixels, but need to know the DPI of the document.  I know that the standard normally is 72 (so just oPage.GetSize.x / 72 should equal the width in inches), however, I could have sworn I've seen some documents (that I created) with other DPI settings.

Is there a way to determine the current DPI setting of the page/document?
		Dim oDoc As New Acrobat.AcroPDDoc
		Dim oApp As New Acrobat.AcroApp
		If oDoc.Open("test.pdf") Then
			Dim oJS As Object = oDoc.GetJSObject()
			Dim oPage As Acrobat.AcroPDPage
			oPage = oDoc.AcquirePage(0)
			Dim oSize As Object
			oSize = oPage.GetSize
			oJS.SaveAs("c:\temp\test.jpg", "com.adobe.acrobat.jpeg", True)
		End If

Open in new window

Who is Participating?
Karl Heinz KremerCommented:
You are not getting the document size in pixels. You are getting the size of one specific page in points. That is what GetSize returns. You can find details on this page:

It says "The LPDISPATCH for an AcroExch.Point containing the width and height, measured in points. Point x contains the width, point y the height."

It's just like when you have a European document and somebody tells you that the page size is 210x297mm - in order to convert to inch, you have to divide by 25.4. This has nothing to do with a 25.4 dpi resolution, it's just how you convert from mm to inch. The same goes for points, points is a unit of measure, just like inch, mm, mile, ...
So just try to get the "dpi" out of your mind when you are dealing with page sizes (or any other sizes in PDF for that matter).

When you select a 12point font in your MS Word document, you are not thinking that the size of your characters has anything to do with resolution, it's just how large the font is (again, it's a unit of measure).
Karl Heinz KremerCommented:
There is no resolution associated with a PDF document. A page has a size (e.g. 8.5x11"), and that is what you can get via the API. In Acrobat, all sizes are provided in points (and this is probably why you think that ou are dealing with 72dpi "resolution" - 72 points are one inch). Most objects in a "normal" PDF file do not have a resolution, because they are vector graphics or text. Only bitmap images have something like  a resolution associated with them, but it's not as straight forward as you might think: A bitmap has a certain number of pixels, and it also has a certain size when rendered on the page. This information let's you calculate the effective resolution. Just because you placed a 600dpi image on a PDF page does not mean that it's effective resolution is 600dpi. If the image was 1" square, but you changed it's size so that it now appears as a 1/2" square, your effective resolution is actually 1200dpi.
So forget about the idea of a "PDF file resolution"    
MarkWThompsonAuthor Commented:
Here's my confusion:

When I open up a document and go to File, Properties ... then under Advanced, Page Size: it reads 12.50 x 23.00 in (obviously for this particular doc)

How can I obtain this info via API?  If the document knows the inches, then shouldn't I be able to obtain that as well?
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Karl Heinz KremerCommented:
Yes, and you are getting that information - just not in inches. As I said, Acrobat uses points internally - you need to convert that to inches. Your approach originally outlined in your question is correct, just divide by 72. If that's all you are after, that is your solution. I guess I misunderstood your question, and thought you really were after a resolution. Do you have access to the Acrobat SDK documentation? That should tell you, what unit is used for the x and y sizes.
MarkWThompsonAuthor Commented:
So, in essence, you are sure there are no documents created with other than the default 72 dpi used?  I was somehow under the impression it could change.
Karl Heinz KremerCommented:
Again, this is not a resolution, so it's not 72dpi. The unit the page size is reported back is "point". It just happens to be that 72 points make one inch (at least in PostScript and PDF). A point is a typographical unit of measure (
MarkWThompsonAuthor Commented:
I must be very confused by all this.

a) I get the Document Width in Pixels (via the API)
b) I get the Width (in inches) of the document via the Document Properties

c) and Pixels / DocumentWidthInInches always = 72
d) document is a 72 dpi, correct?

Now, I realize that all the objects in the document may not truly be at 72 dpi, a graphic can be embedded at 200 dpi, and text can be scalable to any dpi, so I understand where dpi does not apply in this situation, but if steps a-d always are true, then for measurement sake (and SaveAs JPEG sake), then initial dpi is always 72?

I'm sorry if I'm making this more confusing than necessary, but I'm just not getting these documents seem to always be set at 72 dpi, but yet dpi is supposedly irrelevant.

Maybe each item is set at 72 dpi (when viewed as a whole) so as to have a common scale, but when printing (or whatever), it uses each objects own point of scale/reference???
MarkWThompsonAuthor Commented:
So, a point is a unit of measurement that has nothing to do with a physical attribute (because a digital medium can be scaled up, down and all around).

Any attempt I make at assigning the document width / 72 to get the # of inches is, possibly, relative only to the creator of the document (since they were creating the document to fit a specific sized medium).

Thanks for all your help (and patience!).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.