13

I'm attempting to convert a PDF into a single image using GhostScript.

Only the first page is converted, while my intention is to generate a horrendously tall PNG/JPG image with all the pages concatenated together.

These are the parameters I'm currently passing to the GhostScript DLL (via a .NET application):

pdf2img \
  -dNOPAUSE \
  -dBATCH \
  -dSAFER \
  -sDEVICE=png256 \
  -dGraphicsAlphaBits=4 \
  -dTextAlphaBits=4 \
  -dDOINTERPOLATE \
  -dAlignToPixels=1 \
  -r300x300 \
  -sOutputFile=GLOSS.png \
   GLOSS.pdf

Is it possible to concatenate all the pages together via GhostScript? Or should I resort to an external method?

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
TheFuzzy
  • 185
  • 1
  • 1
  • 9

5 Answers5

3

Did you have a look at ImageMagick? This free library might have an option to create a single image from a PDF (It actually uses Ghostscript but adds a lot of graphical editing capabilities such as merging images).

Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
  • ImageMagick or GraphicsMagick will handle the merging part handily, but depending on your needs you may want to use ghostscript for the conversion part. Although the 'magicks can do it all in one step there is quite a speed and memory penalty, see http://right-sock.net/linux/better-convert-pdf-to-jpg-using-ghost-script/ – matt wilkie Jan 08 '13 at 21:16
1

After converting multi-page PDF to images (PNG, JPEG, TIFF, etc.) using GS, you'll need to take one step further to merge the output images into a multi-page TIFF image.

Take a look at the source code of VietOCR.NET, which has the functionality but does it in two separate steps. You can modify it to call the two functions back to back.

nguyenq
  • 8,212
  • 1
  • 16
  • 16
-1

You can check this open source project on Code Project

http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx

That show how to call Ghostscript and how to pass the parameters

Cold Star
  • 74
  • 1
  • 1
-1

You will most likely need to render the single pages using GS and then combine them to a single PNG/JPG using some scripting language.

Mark S. Rasmussen
  • 34,696
  • 4
  • 39
  • 58
  • 1
    no need for a scripting language. GraphicMagick's `gm montage` and ImageMagick's `montage` commands can handle the stitching together of different images just fine. Lots of options available (borders, margins, background colors, layouts ins lines, layouts in columns, layouts in grids,...). – Kurt Pfeifle Jul 31 '10 at 20:04
-2

You can look at PDF to Image