How to Convert Multipage TIFF image to PDF with C#?

Some times we need to convert the tiff image to PDF file as requirement demands. There are a few for .NET including iTextSharp, PDFsharp and PDF Clown. Here we will use iTextSharp sample that was showing how to create a PDF file from a multipage TIFF image

// creation of the document with a certain size and certain margins
iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);


// Creation of the different writers
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(Server.MapPath("~/PDF/Output.pdf"), System.IO.FileMode.Create));

// Load the tiff image and count the total number of pages
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Server.MapPath("~/FolderLocation/file.tif"));

int total = bmp.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);

document.Open();
iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;
for (int k = 0; k < total; ++k)
{
        bmp.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, k);
        iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bm, System.Drawing.Imaging.ImageFormat.Bmp);


       // Scale the image to fit in the page
       img.ScalePercent(72f / img.DpiX * 100);
       img.SetAbsolutePosition(0, 0);
       cb.AddImage(img);
       document.NewPage();
}

document.Close();

Comments

  1. You can achieve this with Aspose.Imaging for .NET Library also and this library offers many other features which .net developers can use in their API.

    ReplyDelete
    Replies
    1. Questions on c# abby fine reader pdf to word converter is expected to relate to programming within the rasteredge page. Consider editing the question or leaving comments for improvement if you believe the question can be answered on page http://www.rasteredge.com/how-to/csharp-imaging/pdf-html5-feature-convert-pdf/

      Delete
  2. Anonymous2/27/2014

    Do you know how convert a searchable Tiff to a searchable PDF?

    ReplyDelete
    Replies
    1. Hi,
      Any solution? Even i am struck with the same issue.

      Delete
  3. Thanks a lot for making this available. I really appreciate that.
    ExtraTorrent UK proxy

    ReplyDelete
  4. thank you this helps a lot! Are there any examples how to exact a particular page of a multipage tiff?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Questions on c# abby fine reader pdf to word converter is expected to relate to programming within the rasteredge page. Consider editing the question or leaving comments for improvement if you believe the question can be answered on page http://www.rasteredge.com/how-to/csharp-imaging/pdf-html5-feature-convert-pdf/

      Delete
  5. Very impressive !! I also got a solution from Spire.PDF ,here is an example which demonstrates the whole process ,check - Convert multipage image to PDF in C#..hope this can be helpful either..

    ReplyDelete
    Replies
    1. online best pdf to tiff converter c# for you can be download and pdf to tiff converter c# for your product, try this online best pdf to tiff converter c# for free on http://www.tagpdf.com/online/convert-pdf-to-tiff/.

      Delete
  6. Anonymous4/03/2015

    friends... this code create a pdf file from a specified image "file.tiff", can anyone tell me how to convert unlimited number of images to pdf, for example if i have a folder that contain 5 images convert to a 5 page pdf every image in a page of pdf?

    ReplyDelete
    Replies
    1. You can try http://www.rasteredge.com/online/pdf/convert-pdf-to-tiff/ for high quality create tiff from pdf. Even there is 10% discount on the first order.

      Delete
  7. You can try this free online pdf to image converter to convert pdf to multipage tiff online.

    ReplyDelete
  8. c# add and delete pages in pdf online on page http://www.rasteredge.com/how-to/csharp-imaging/pdf-delete/

    ReplyDelete
  9. c# add and remove pages from pdf file online
    http://www.rasteredge.com/how-to/csharp-imaging/pdf-extract-pages/

    ReplyDelete

  10. You can download and try this interesting high quality page for c# how to remove watermark from pdf image on http://www.rasteredge.com/how-to/csharp-imaging/pdf-image-remove/

    ReplyDelete
  11. The first and easiest way to c# .net convert tiff to pdf is to use the rasteredage page http://www.rasteredge.com/how-to/csharp-imaging/pdf-convert-tiff/. The c# batch convert tiff to pdf function is not static, so you'll need to create an instance of the class.

    ReplyDelete
  12. Here is the link for you to vb.net .net convert tiff to pdf. Hope this gives you a start on rasteredge page http://www.rasteredge.com/how-to/vb-net-imaging/pdf-convert-tiff-to-pdf/

    ReplyDelete
  13. The first and easiest way to vb.net .txt to .pdf converter online is to use the rasteredage page http://www.rasteredge.com/how-to/vb-net-imaging/pdf-convert-text-to-pdf/. The

    vb.net .txt to pdf converter is not static, so you'll need to create an instance of the class.

    ReplyDelete
  14. The first and easiest way to Create PDF from Tiff is to use the rasteredage page http://www.rasteredge.com/how-to/csharp-imaging/pdf-convert-tiff-to-pdf/

    ReplyDelete
  15. Try the convert multiple page tiff to pdf directly and easily with high quality on pdfcoding page http://www.pdfcoding.com/online/pdf/convert-tiff-to-pdf/.

    ReplyDelete
  16. The first and easiest way for convert tiff to searchable pdf is to use the http://www.pdfcomponent.com/online/convert-tiff-to-pdf/

    ReplyDelete
  17. Here is the link for convert multipage pdf to tiff. Hope this gives you a start for you convert multipage pdf to tiff on pdfcomponent page http://www.pdfcomponent.com/online/convert-pdf-to-tiff/.

    ReplyDelete
  18. You can try http://www.pdfcoding.com/online/pdf/convert-pdf-to-tiff/ for high quality convert multipage tiff to pdf c#. Even there is 10% discount on the first order.

    ReplyDelete
  19. Try the multi page tiff to pdf conversion directly and easily with high quality on rasteredge.com page http://www.rasteredge.com/online/pdf/convert-pdf-to-tiff/..

    ReplyDelete
  20. You will need to download the free how to convert tiff to pdf online. download this new how to convert tiff to pdf online with high quality on page http://www.rasteredge.com/online/pdf/convert-tiff-to-pdf/.

    ReplyDelete
  21. Questions on best multipage pdf to multipage tiff online single click tagpdf.com. can leaving comments for multipage pdf to multipage tiff online and be answered on tagpdf.com http://www.tagpdf.com/online/convert-pdf-to-tiff/.

    ReplyDelete
  22. Anonymous5/03/2017

    it works perfectly, thanks

    ReplyDelete
  23. design and quality

    ReplyDelete
  24. great article, I usually convert pdf to jpg image in c# language using this library: http://www.xspdf.com/guide/pdf-jpg-converting/

    ReplyDelete

Post a Comment

Popular posts from this blog

Auto Scroll in Common Controls

Convert typed library (.tlb) to .net assembly?

Disable close button on form - C#