How can I convert each pages of a PDF's file in C#开发者_C百科, using free command line or free library?
Thank you
Example commandlines for Ghostscript converting multipage PDF to images (1 image per page):
gswin32c ^
-o gray_page_%03d.png ^
-sDEVICE=pnggray ^
input.pdf
.
gswin32c ^
-o page_%03d.png ^
-sDEVICE=png256 ^
input.pdf
.
gswin32c ^
-o page_with_alphachannel_%03d.png ^
-sDEVICE=pngalpha ^
input.pdf
.
gswin32c ^
-o cmyk_page_%03d.jpeg ^
-sDEVICE=jpegcmyk ^
-dJPEGQ=80 ^
input.pdf
.
gswin32c ^
-o rgb_page_%03d.jpeg ^
-sDEVICE=jpeg ^
-dJPEGQ=100 ^
input.pdf
.
gswin32c ^
-o tiffg4_page_%03d.tiff ^
-sDEVICE=tiffg4 ^
input.pdf
.
gswin32c ^
-o tiffg32nc_page_%03d.tiff ^
-sDEVICE=tiff32nc ^
-sCompression=lzw ^
input.pdf
...and many more are possible....
If you need to control resolutions and page sizes (and not rely on Ghostscript's defaults) add these parameters:
-r600x600
gives you a horizontal and vertical resolution of 600 dpi.
-g5950x8420
applies a widths of 5950 "devicepoints" and a height of 8420 "devicepoints". Depending on the resolution used at the same time, the devicepoints will end up on paper in different sizes. In case of a resolution -r720x720
above example of -g5950x8420
will become the same as media size of DIN A4 ISO
(which is in PostScript points 595
by 842
.
ImageMagick.NET, a .NET wrapper for the ImageMagick libraries, is your friend.
ImageMagick offers a variety of image manipulation and conversion tools. For converting PDF documents, it is using GhostScript under the hood.
精彩评论