我正在开发一个网络应用,现在我正尝试使用ImageMagick和Ghostscript将PDF文件转换为PNG图像。我下载了以下文件:[Magick.NET-7.0.0.0007-Q16-x86-net20.zip],解压缩其文件,然后放入我的Visual Studio项目的bin文件夹中。我还为Windows安装了Ghostscript 9.15(32位)。然后我尝试使用ImageMagick文档中的VB.Net示例转换我之前创建的PDF文件作为测试:
Dim settings As New MagickReadSettings()
' Settings the density to 300 dpi will create an image with a better quality
settings.Density = New MagickGeometry(300, 300)
Using images As New MagickImageCollection()
' Add all the pages of the pdf file to the collection
images.Read("C:\MyProject\PDF\MY_PDF.PDF", settings)
' Create new image that appends all the pages horizontally
Using horizontal As MagickImage = images.AppendHorizontally()
' Save result as a png
horizontal.Write("C:\MyProject\PDF\MY_PDF.horizontal.png")
End Using
' Create new image that appends all the pages horizontally
Using vertical As MagickImage = images.AppendVertically()
' Save result as a png
vertical.Write("C:\MyProject\PDF\MY_PDF.vertical.png")
End Using
End Using
我运行了我的项目来测试代码,我收到了这个错误:
ImageMagick.MagickDelegateErrorException: w3wp.exe: PDFDelegateFailed `[ghostscript library]
-q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000
-dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4
-dGraphicsAlphaBits=4 "-r300x300" "-sOutputFile=C:/WINDOWS/TEMP/magick-
3224bC6h8EQ360KA%d" "-fC:/WINDOWS/TEMP/magick-3224IW9rcxT1iXj2" "-fC:/WINDOWS
/TEMP/magick-3224ROCAzr6PEGFK": (null)' @ error/pdf.c/ReadPDFImage/772
(此行发生错误):
images.Read("C:\MyProject\PDF\MY_PDF.PDF", settings)
有谁理解错误是什么?我错过了什么?任何帮助表示赞赏。