Use Acrobat API to change default JPEG Resolution with JSObject "SaveAs"

Posted on 2009-02-09
Last Modified: 2012-05-06
I'm using the JSObject w/ in order to extract a page to a JPG image.  However, I need the Default Resolution (DPI) to be at least 300.  How do I do this before I do the SaveAs?

I'm currently using the below code (but obviously am lacking the DPI change part).
Dim oDoc As New Acrobat.AcroPDDoc

		Dim oApp As New Acrobat.AcroApp


		If oDoc.Open("test2.pdf") Then

			Dim oJS As Object = oDoc.GetJSObject()


			Dim oPage As Acrobat.AcroPDPage

			oPage = oDoc.AcquirePage(0)




			oJS.SaveAs("c:\temp\test.jpg", "com.adobe.acrobat.jpeg", True)


		End If



Open in new window

Question by:MarkWThompson
    LVL 44

    Accepted Solution

    You cannot change the resolution via JavaScript. That information is set in the Acrobat preferences (in the Convert From PDF section, then select the JPEG format from the list and click on the "Edit Settings" button). If you want to render complete documents to JPEG (which, depending on the page content, may not be such a good idea: JPEG is a format that is designed for photographic images, and it will create more or less severe compression artifacts with any other source data), you may want to look at a renderer that gives you easy access to the output resolution. Take a look at Ghostscript, it comes with a command line interface that allows you to specify exactly what you want. Just make sure that you can stay within the Ghostscript license. Another option is the rasterizer from Glyph&Cog -

    Author Comment

    Now I realize I didn't word my question entirely correctly.

    Is there an API that can do this?  I realize it's on the Application level, and thought there might be either a property/method exposed on the Acrobat.AcroApp object or a true API that makes it adjustable.

    I currently use the PDF2Image com object (which is probably very much like the one that you suggested).  But, if these object can specify the DPI used, and they just are a wrapper to the APIs/Com objects available, then I *should* be able to do it the same way they do.  Correct?
    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    Only the Acrobat plug-in API gives you access to that functionality. You cannot access it via any of the other APIs. A plug-in is a completely different beast than just calling a function from your application. For this to work for a VB program, you would have to write a plug-in that provides the functionality to save the image and also provides an interface so that your program can use that functionality (e.g. COM server).

    PDF2Image (or Ghostscript or Xpdf) are not based on Acrobat, so they are not just wrappers for the APIs that Acrobat supports. I don't know what PDF2Image is using internally, but both Ghostscript and Xpdf have their own renderers.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    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…
    *Adobe Acrobat 9 was used for this article.  Particular steps may vary depending on software versions. Adobe Acrobat has many, many variables that my be utilized to customize your forms for clarity and ease of use. The Form Editing Tool will be y…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    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