Converting pdf to jpg (or flat pdf)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Precision999
Posts: 4
Joined: 2019-03-29T09:07:10-07:00
Authentication code: 1152

Converting pdf to jpg (or flat pdf)

Post by Precision999 »

Hi

I've done a fait bit of googling and trying out different options, but I can't seem to achieve what I need.

I need to be able to take a pdf, convert to a 1200dpi jpg, and then produce a new pdf from there (effectively flattening the pdf). The quality needs to be high.

If convert.exe can do this in one go, great, but I'm happy if I can just get a good quality jpg and then worry about converting to pdf afterwards.

Can someone help me with the convert command line needed for this? - I've tried playing with -resize, -density, -flatten, -geometry, -resize etc etc and I get varying results, but not the nice high-res jpg I'm looking for, so I'm obviously not understanding them properly.

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting pdf to jpg (or flat pdf)

Post by snibgo »

What version of IM, on what platform. I'll assume IM v7. If you use v6, use "convert" instead of "magick".

How about:

Code: Select all

magick -density 1200 in.pdf out.pdf
If you want just the first page:

Code: Select all

magick -density 1200 in.pdf[0] out.pdf
snibgo's IM pages: im.snibgo.com
Precision999
Posts: 4
Joined: 2019-03-29T09:07:10-07:00
Authentication code: 1152

Re: Converting pdf to jpg (or flat pdf)

Post by Precision999 »

Thanks for your reply - I'm using IM7 by the way.

Your examples seem simple enough, but when I try it with either convert or magick, I get this:

Image

I'll try re-installing and see if that helps.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting pdf to jpg (or flat pdf)

Post by snibgo »

How are you running the program? I showed you commands that you can type at the command line. This means in a command window, aka command prompt, aka terminal, aka console, aka cmd.exe.

Check that these commands work:

Code: Select all

magick rose: r.png

magick r.png r.jpg
snibgo's IM pages: im.snibgo.com
Precision999
Posts: 4
Joined: 2019-03-29T09:07:10-07:00
Authentication code: 1152

Re: Converting pdf to jpg (or flat pdf)

Post by Precision999 »

I'm running via command line.

I uninstalled and then re-installed. I installed 'Win64 dynamic at 16 bits-per-pixel component' this time, so maybe I got the wrong install file previously?

In any case, it works fine now - thanks!
Post Reply