Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

i am trying to convert multiple tiff images to single pdf file. i went through this link
atashbahar.com.

i Have done the following coding refering to above link
C#
iTextSharp.text.Document document = new iTextSharp.text.Document(new RectangleReadOnly(842,595), 0, 0, 0, 0);


     iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(DestPath, System.IO.FileMode.Create));

     // load the tiff image and count the total pages
     System.Drawing.Bitmap bm = new System.Drawing.Bitmap(Source);
     int total = bm.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);

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


         img.ScalePercent(50f / img.DpiX * 100);
         img.SetAbsolutePosition(0, 0);
         cb.AddImage(img);
         document.NewPage();
     }
     document.Close();


i Want the page size to be A3. though the above code generates a pdf document, it is not printing the entire image on a page. the image is splitted and part of a image is only visible. i think the problem is with scalling. i googled for A3 scalling but all went in vain..

Any help will be appreceated..

thank you
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900