0

I’m using WebSite in ASP.NET and PdfSharp PDF library. I have a tiff document image that contains 3 pages, I would want to convert all those 3 tiff pages into 1 PDF file with 3 pages.

Please tell me what should I do?

    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();
  • Did you check [this possibly duplicate question](https://stackoverflow.com/questions/35208731/convert-tif-document-to-pdf-with-pdfsharp)? It shows how to open a multi-page TIFF file and add each image as a page in the PDF document – Panagiotis Kanavos Jun 12 '19 at 14:01
  • Possible duplicate of [Converting multiple Images to pdf using pdfsharp](https://stackoverflow.com/questions/8479022/converting-multiple-images-to-pdf-using-pdfsharp) –  Jun 12 '19 at 14:06

0 Answers0