使用PDF2Image将PDF转换为位图[.png]的性能不佳



让我解释一下,假设我上传的PDF有20页,然后我们将PDF转换为单页,然后转换为.png。因此需要太多时间。现在为20页,此代码需要2分钟

string result = Path.Combine(Server.MapPath("~/TempSplitPDF")) + "/result";
for (int j = 1; j <= pdfReader.NumberOfPages; j++)
{                   
    Bitmap imagelst = new Pdf2Image(result + j + ".pdf").GetImage();
}                                                                        
imageModal = new ImageModel();                                
imageModal.FileName = Guid.NewGuid().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(result + j + ".pdf");
dev.Pdf.FirstPage = 1;
dev.Pdf.LastPage = 1;
dev.PostScript = string.Empty;
dev.OutputPath = Server.MapPath(@"~/TempPDF" + "\" + imageModal.FileName);
dev.Process();

最新更新