让我解释一下,假设我上传的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";
任何人都可以帮助我!
答案 0 :(得分:0)
此代码对我来说非常快速。
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();