convert tif to pdf

Last post 07-02-2009 3:28 AM by santhosh Vojjala. 0 replies.

Sort Posts:

  • convert tif to pdf

    07-02-2009, 3:28 AM

     Hi all

    i have one requirement argent ,i.e i am converting multiple tif files to pdf files  in C# web applications,now iam using the following code,with this code converting successfully,but converted pdf file takes more size compare with tif file size,but i want less size pdf file than tif file,any one knows solution for this please help me

     

    the using code is

     

    iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4, 50, 50, 50, 50);
            PdfWriter writer = PdfWriter.GetInstance(document, new
            System.IO.FileStream(pdfFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write));
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(tiffFileName);
            numberOfPages = bitmap.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
            document.Open();
            PdfContentByte cb = writer.DirectContent;
            for (int page = 0; page < numberOfPages; page++)
            {
                bitmap.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, page);
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                iTextSharp.text.Image img =
                iTextSharp.text.Image.GetInstance(stream.ToArray());
                stream.Close();
                img.ScalePercent(72f / bitmap.HorizontalResolution * 100);
                img.SetAbsolutePosition(0, 0);
                cb.AddImage(img);
                document.NewPage();
            }
            document.Close();

     

    thanks

     

     

     

     

    santhosh vojjala
Page 1 of 1 (1 items)