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

Posted on 2009-02-09
Medium Priority
Last Modified: 2012-05-06
I'm using the JSObject w/ VB.net 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
  • 2
LVL 44

Accepted Solution

Karl Heinz Kremer earned 2000 total points
ID: 23615983
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 - http://www.glyphandcog.com/XpdfRasterizer.html.

Author Comment

ID: 23621480
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
ID: 23623065
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 VB.net 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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 (http://www.experts-exchange.com/Programming/Installation/Q_28396542.html)…
*Adobe Acrobat 9 was used for this article. Particular steps may vary depending on software versions. 1. Create a framework of your form in Word, leaving space where you’d ultimately like the Adobe fields to appear.  (Note: I use the blank lines …
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Suggested Courses
Course of the Month17 days, 13 hours left to enroll

830 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