Determine DPI (resolution) used in Acrobat document with API

Posted on 2009-02-09
Last Modified: 2012-06-27
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

Question by:MarkWThompson
    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    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"    

    Author Comment

    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?
    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    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.

    Author Comment

    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.
    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    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 (

    Author Comment

    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???
    LVL 44

    Accepted Solution

    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).

    Author Comment

    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!).

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe In a previous Experts Exchange article, How To Rename-Move a Batch of PDF Files Based on Contents of the Files (http://www.experts-exchan…
    Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe INTRODUCTION This article presents a solution to a question (…
    In this second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…
    In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now