[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Determine DPI (resolution) used in Acrobat document with API

Posted on 2009-02-09
Medium Priority
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
  • 4
  • 4
LVL 44

Expert Comment

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

ID: 23600111
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
ID: 23600229
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.
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database


Author Comment

ID: 23600382
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
ID: 23600432
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 (http://en.wikipedia.org/wiki/Point_(typography)).

Author Comment

ID: 23600515
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

Karl Heinz Kremer earned 1000 total points
ID: 23600630
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

ID: 23601940
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Suggested Courses

873 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