我正在ASP.NET和PdfSharp PDF库中使用WebSite。我有一个包含3页的tiff文档图像,我想将所有3个tiff页转换为1个具有3页的PDF文件。
请告诉我该怎么办?
PdfDocument doc = new PdfDocument();
System.Drawing.Image img2 = System.Drawing.Image.FromFile(@"C:\File\0.tiff");
Guid objGuid = img2.FrameDimensionsList[0];
FrameDimension objDimension = new FrameDimension(objGuid);
int pageCount = (img2.GetFrameCount(objDimension));
pageCount--;
for (int i = 0; i <= pageCount; i++)
{
PdfPage page = doc.AddPage();
XGraphics xgr = XGraphics.FromPdfPage(page);
img2.SelectActiveFrame(objDimension, i);
XImage img = XImage.FromGdiPlusImage(img2);
page.Width = img.PointWidth;
page.Height = img.PointHeight;
xgr.DrawImage(img, 0, 0);
}
img2.Dispose();
doc.Save(@"C:\File\0.pdf");
doc.Close();