嗨我一直在dot.net中使用itextSharp所有pdf相关项目。 我遇到了需要将PDF页面转换为图像的需求。 我找不到任何这样的事情。我发现另一个工具ghostscript能够做到这一点的问题是我在一个共享的托管&我不认为ghostscript将运行在服务器上,因为在我的本地机器我不得不手动将ghost script dll复制到system32文件夹在共享主机中是不可能的。是否可以使用itextSharp将PDF页面转换为图像?
6
A
回答
11
好的,我搜遍了,发现有一个Ghost Script的nuget软件包,所以对我来说问题是通过打包管理器控制台并将ghost脚本添加到新项目中解决的(我创建了一个新的项目,一个有各种各样的参考win32 ghostscript dlls)通过“PM>安装包Ghostscript.NET”。 所以我的问题的答案是: 1.> itextSharp 不能直接将PDF页面转换为图像。 2.>“Ghostscript.NET 1.2.0”很容易做到。以下是一个代码示例。
public void LoadImage(string InputPDFFile,int PageNumber)
{
string outImageName = Path.GetFileNameWithoutExtension(InputPDFFile);
outImageName = outImageName+"_"+PageNumber.ToString() + "_.png";
GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png256);
dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
dev.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
dev.ResolutionXY = new GhostscriptImageDeviceResolution(290, 290);
dev.InputFiles.Add(InputPDFFile);
dev.Pdf.FirstPage = PageNumber;
dev.Pdf.LastPage = PageNumber;
dev.CustomSwitches.Add("-dDOINTERPOLATE");
dev.OutputPath = Server.MapPath(@"~/tempImages/" + outImageName);
dev.Process();
}
+0
这仍然需要在服务器上安装Ghostscript。 –
+0
从Ghostscript.NET 1.2.1开始,这在Linux上不会出现。 – sunside
相关问题
- 1. 使用itextsharp将多个图像转换为多页PDF使用itextsharp
- 2. 我可以使用itextsharp将图像转换为PDF/A文档吗?
- 3. 使用itextsharp将图像转换为PDF时出错
- 4. 使用带间距的itextsharp将图像转换为PDF
- 5. 使用iTextSharp将图像转换为PDF保留剪切路径
- 6. 使用iTextSharp将Gridview Templatefield转换为PDF
- 7. 使用iTextSharp将PDF转换为PDFA1-A
- 8. 使用itextsharp将HTML转换为PDF
- 9. iTextSharp将System.Web.UI.DataVisualization.Charting转换为pdf
- 10. 将pdf页面转换为1000以上的图像
- 11. 使用Itextsharp(XMLWorker)将Asp.net页面转换为pdf返回已损坏/空白pdf
- 12. ubuntu - 使用imagemagick转换utlity将图像转换为多页pdf
- 13. 使用dompdf将页面转换为PDF
- 14. 使用iTextSharp控制将PNG图像转换为PDF时的图像分辨率
- 15. 是否可以使用Zend_Pdf将HTML转换为pdf?
- 16. 是否可以使用ColdFusion将Microsoft Word文档转换为PDF?
- 17. 是否有可能将图像转换为PDF在android中
- 18. 将多页PDF转换为多图像
- 19. Pdfbox1.8.12将PDF转换为白页图像
- 20. 将网页转换为PDF或图像
- 21. 使用iTextSharp将图像追加到PDF页面
- 22. 使用ImageMagick将PDF转换为图像
- 23. ImageMagick:将图像转换为PDF,A4页面大小和图像适合页面
- 24. 将PDF转换为图像
- 25. 使用iTextSharp将Kendo图表转换为PDF
- 26. 如何使用itextsharp将html页面转换为PDF格式的css文件?
- 27. 使用iTextSharp的转换HTML为PDF
- 28. 将多页PDF转换为单页PDF并提取图像
- 29. Fine-Uploader可以将PDF页面解析为缩略图图像
- 30. 将所有PDF页面转换为java中的单个图像
这是不可能的使用iTextSharp的..你需要使用一些Java脚本库PDF页面转换为图像......你可以给用Phantomjs一试..这是很好的用于此目的,因为我已经使用它。 – immirza
这个问题还不清楚,所以我建议将它改写成实际可以回答的问题。 如果您只需要GhostScript DLL,您可能会发现将它们复制到'bin'文件夹就足以让您在托管系统上访问其功能。 –
请参考以下链接 http://stackoverflow.com/questions/23905169/how-to-convert-pdf-files-to-image – JDK