Best Way To Convert a PDF to JPG Image On Windows?

I know there are several solutions available, but all of them come with a lot of extra overhead that I don’t really want to deal with. (license GhostScript, buy DynaPDF plugin, etc). All I need to do is convert a 1 page PDF to a single .jpg image for use in my app.

How have you cracked this nut in the past?

I take it this is a dynamic need not one you can do once & be done with it ?

If so you need “something” that can do this on the fly like a plugin, imagemagick as a helper app, some other helper that can do the conversion, etc

You mean to do it manually, not in a Xojo Program?
That’s an easy one.
Open your PDF on adobe or other reader, make it fullscreen view, if it is portrait rotate it 90 degrees, then magic: do a screen capture!

Depending on the computer, the print screen key is different. My laptop PC is fnkey+prtscr on the mac it is command-shift-3.
On a PC the screen capture is copied to the clipboard. On a mac it is saved as a png on the desktop.

Then, paste the screen capture in paint (windows) and save it as jpg.
On a mac, open the saved png and save it as jpg.

Correct. I’m currently looking at trying to include just the convert.exe from the ImageMagick library, as it has a very open (and free as in beer) license. Just looking into what dependencies it requires.

Hi @Julio Debroy - thanks for the info, but no, I need to allow the user specify a PDF file in my xojo app and have my app transmogrify it into a .jpg under the hood.

Man, after a few hours of research into this, there do not appear to be any really good options. Does anyone know which license level of DynaPDF is required just to convert an existing PDF to a JPG? I don’t need any pdf creation abilities at all, just output an existing pdf as a jpg. @Christian Schmitz?

Oh there are good options - just not on Windows :stuck_out_tongue:

[quote=220662:@Kimball Larsen]I know there are several solutions available, but all of them come with a lot of extra overhead that I don’t really want to deal with. (license GhostScript, buy DynaPDF plugin, etc). All I need to do is convert a 1 page PDF to a single .jpg image for use in my app.

How have you cracked this nut in the past?[/quote]
Have you considered selling your software for $999 bucks? Included is a FREE Mac Mini?

Believe it or not, the idea has been floated in years past - only with a free low-end macbook. Windows has been a nightmare for us with respect to technical support and general idiocy of the end user. We rarely have any issues with our mac userbase. /-:

Maybe have a look here:
http://sodapdf.com/

for DynaPDF, you need Pro to raster.

Maybe you ask me directly if you want to order a license.

Kimball, a crazy idea…
Yesterday I was thinking about your request, and indeed verified that you need to purchase a license one way or another, for one of the available pdf libraries. But it seemed to me an interesting challenge.

One of the options I think is good, is to get the MBS Xojo plugin for imagemagick. Since imagemagick needs ghostscript anyway to open the pdf, you can avoid distribution problems making by the final user download and install ghostscript. In that way you are not violating any license and your app can use the functionality.

The other option is DynaPDF, but I think that if you get the MBS Xojo plugin you also have to pay a license to DynaPDF. Am not sure, maybe Christian can confirm that.

Now my crazy idea. I was fiddling last night and found a javascript library that can indeed load and render a pdf in a HTMLView window, both in mac and in Windows. For windows the native renderer is IE, and for Mac is Webkit as far as I know.
In any case, you can download the pdf into the htmlview and then there is another library that can render (print or save) to an image whatever you have in the htmlview. Once you have the pdf rendered into a HTML5 canvas, you can save it using some techniques.
This approach will need you to get the pdf via javascript or similar.

Another approach is to make the user install adobe acrobat reader, and use the functionality embedded in the COM activeX object (only for Windows) to read the pdf and render it to a canvas that you can later save to an image file. In this case you have to link the COM interface.

https://mozillalabs.com/en-US/pdfjs/
http://www.codediesel.com/javascript/rendering-pdf-in-html5-canvas/
http://stackoverflow.com/questions/12796513/html5-canvas-to-png-file
http://www.permadi.com/tutorial/save-canvas/test-save-html5-canvas.html

http://www.codeproject.com/Articles/32274/How-To-Convert-PDF-to-Image-Using-Ghostscript-API
http://www.codeproject.com/Articles/57100/Simple-and-Free-PDF-to-Image-Conversion

The license fee for our DynaPDF plugin is so high, because it includes the license fee for DynaPDF itself already.

I suppose that if I decided to buy a Mac, I would instantly become brilliant? Heck, why did I not think of that before? Oh yes, I am an idiot. That’s why.

Wow… I was happy to announce that I solved the problem, but the quoted comment is not only offensive but also highly inaccurate.

Code can be fixed. Not bigotry…

These are all interesting approaches, and I may consider one or more of them. Still debating whether the cost of the DynaPDF plugin is worth it for this small slice of functionality.

Thanks for putting in all the thought!

– Kimball

[quote=220848:@Julio Debroy]Kimball, a crazy idea…
Yesterday I was thinking about your request, and indeed verified that you need to purchase a license one way or another, for one of the available pdf libraries. But it seemed to me an interesting challenge.

One of the options I think is good, is to get the MBS Xojo plugin for imagemagick. Since imagemagick needs ghostscript anyway to open the pdf, you can avoid distribution problems making by the final user download and install ghostscript. In that way you are not violating any license and your app can use the functionality.

The other option is DynaPDF, but I think that if you get the MBS Xojo plugin you also have to pay a license to DynaPDF. Am not sure, maybe Christian can confirm that.

Now my crazy idea. I was fiddling last night and found a javascript library that can indeed load and render a pdf in a HTMLView window, both in mac and in Windows. For windows the native renderer is IE, and for Mac is Webkit as far as I know.
In any case, you can download the pdf into the htmlview and then there is another library that can render (print or save) to an image whatever you have in the htmlview. Once you have the pdf rendered into a HTML5 canvas, you can save it using some techniques.
This approach will need you to get the pdf via javascript or similar.

Another approach is to make the user install adobe acrobat reader, and use the functionality embedded in the COM activeX object (only for Windows) to read the pdf and render it to a canvas that you can later save to an image file. In this case you have to link the COM interface.

https://mozillalabs.com/en-US/pdfjs/
http://www.codediesel.com/javascript/rendering-pdf-in-html5-canvas/
http://stackoverflow.com/questions/12796513/html5-canvas-to-png-file
http://www.permadi.com/tutorial/save-canvas/test-save-html5-canvas.html

http://www.codeproject.com/Articles/32274/How-To-Convert-PDF-to-Image-Using-Ghostscript-API
http://www.codeproject.com/Articles/57100/Simple-and-Free-PDF-to-Image-Conversion[/quote]

I apologize if that came across as bigoted. Allow me to rephrase in a slightly more politically correct way:

We have thousands of users all over the world. Our install base is roughly 50/50 mac/windows. I handle nearly all the technical support from our users, and based on my actual experience, the vast majority who need help are Windows users, many of whom struggle with basic computer concepts such as “download”, “install”, “double-click” and the like. I apologize for insinuating that all windows users are less intelligent than users of other OS’s - I know this is simply not true in general, but my specific experience could easily lead one to such a conclusion.

We actually seriously have considered bundling a macbook or mac mini with our products in the past, as @Sam Rowlands suggested, simply because there are far fewer technical challenges on the Mac OS with respect to both our programming efforts and the end user experience.

IBM is finding the same thing with their own work force

Hmm… I would rather say the fault is by the “The developer” and not the user… Don’t forget the mac is made by Developers. :slight_smile: