We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

Medium Priority
1,754 Views
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)
 
''HOW DO I CHANGE THE RESOLUTION (DPI) BEFORE EXTACTION?
 
			oJS.SaveAs("c:\temp\test.jpg", "com.adobe.acrobat.jpeg", True)
			oJS.console.show()
			oJS.console.clear()
		End If
 
		oDoc.Close()

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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?
CERTIFIED EXPERT

Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.