Are you saying do without the line that scales the image?

 

From: Paulo Soares [mailto:psoa...@glintt.com] 
Sent: Monday, December 12, 2011 12:39 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Converting Fax Tiff to PDF

 

Load the image directly from the tiff or you'll lose the dpi
information.

 

Paulo

         

        
________________________________


        From: Hugh McLaughlin [mailto:h...@kmcnetwork.com] 
        Sent: Monday, December 12, 2011 5:15 PM
        To: itext-questions@lists.sourceforge.net
        Subject: [iText-questions] Converting Fax Tiff to PDF

        Hello Everyone and thanks for your help in advance.  I am
developing an application with iTextSharp to transform inbound faxes to
PDF files.  However, when converted to PDF files, some of the faxes do
not display properly, for example they appear shortened on the page and
out of correct resolution.  All of the text appears, but squashed on the
page.  It appears that my code does not properly account for various dpi
settings of the inbound faxes, but I am unsure how to account for this.
Here is my code:

         

                ' creation of the document with a certain size and
certain margins  

                Dim document As New
iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0)

         

                ' creation of the different writers  

                Dim writer As iTextSharp.text.pdf.PdfWriter =
iTextSharp.text.pdf.PdfWriter.GetInstance(document, New
System.IO.FileStream(DestinationFile, System.IO.FileMode.Create))

         

                ' load the tiff image and count the total pages  

                Dim bm As New System.Drawing.Bitmap(SourceFile)

                Dim total As Integer =
bm.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page)

         

                document.Open()

                Dim cb As iTextSharp.text.pdf.PdfContentByte =
writer.DirectContent

                For k As Integer = 0 To total - 1

        
bm.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, k)

                    Dim img As iTextSharp.text.Image =
iTextSharp.text.Image.GetInstance(bm,
System.Drawing.Imaging.ImageFormat.Bmp)

                    ' scale the image to fit in the page  

                    img.ScalePercent(72.0F / img.DpiX * 100)

                    img.SetAbsolutePosition(0, 0)

                    cb.AddImage(img)

                    document.NewPage()

                Next

                document.Close()

         

        Any help would be greatly appreciated.

------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to