Thanks for the response and offer.  I have attached the code in a text file.  
I'm not sure if it is a Java to C# to Vb.Net problem or a possible difference 
between the iText and the iTextSharp port.  Since I'm pretty new to the whole 
iText scene, I'm still chasing my tale little bit with the differences.

Thanks again.

-----Original Message-----
From: Keith O [mailto:kuujinbo.mail.l...@googlemail.com] 
Sent: Wednesday, December 14, 2011 10:01 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Antwort: Re: Converting Fax Tiff to PDF

On Wed, Dec 14, 2011 at 2:20 PM, Hugh McLaughlin <h...@kmcnetwork.com> wrote:
> Yeah, it looks like it.  So any idea where I'm jumping the track on my Vb.Net 
>  and iTextSharp implementation?

Since this seems to be a problem with a C#  => vb.net conversion, send me an 
attachment with what you have. But please only the part relevant to **this** 
question. If it's not too long, I can take a look at it.

What version of iTextSharp are you running?

> -----Original Message-----
> From: Keith O [mailto:kuujinbo.mail.l...@googlemail.com]
> Sent: Wednesday, December 14, 2011 1:45 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Antwort: Re: Converting Fax Tiff to PDF
>
> On Wed, Dec 14, 2011 at 2:57 AM, Hugh McLaughlin <h...@kmcnetwork.com> wrote:
>> Thanks for the response.  I tried changing over to Vb.Net which is 
>> what I am using in this project. However it is still not scaling 
>> correctly.  Attached is the tiff and the resulting pdf.
>
> Benjamin's code works for me (iTextSharp 5.1.3):
>
> Image img = Image.GetInstance(imagePath); if (img != null) { // scale 
> if too big to fit on page
>  if (img.ScaledWidth > PageSize.A4.Width
>    || img.ScaledHeight > PageSize.A4.Height
>  )
>  {
> // if images have a different resolution (dpi value) for x and y the 
> scaling considers it
>    if(img.DpiX != 0
>      && img.DpiY != 0
>      && img.DpiX != img.DpiY
>    )
>    {
>      img.ScalePercent(100);
>      float percentX = (PageSize.A4.Width * 100) / img.ScaledWidth;
>      float percentY = ( (PageSize.A4.Height * 100) / img.ScaledHeight 
> );
>      img.ScalePercent(percentX, percentY);
>      img.WidthPercentage = 0;
>    }
>    else{
> // scaling the image if DPI values for x and y are the same // no 
> customized scaling i.e. different values for x and y necessary
>      img.ScaleToFit(PageSize.A4.Width, PageSize.A4.Height);
>    }
>  }
>  document.Add(img);
> }
>
> See attached PDF.
>
> ----------------------------------------------------------------------
> -------- Cloud Computing - Latest Buzzword or a Glimpse of the Future?
> This paper surveys cloud computing today: What are the benefits?
> Why are businesses embracing it? What are its payoffs and pitfalls?
> http://www.accelacomm.com/jaw/sdnl/114/51425149/
> _______________________________________________
> 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

------------------------------------------------------------------------------
Cloud Computing - Latest Buzzword or a Glimpse of the Future?
This paper surveys cloud computing today: What are the benefits? 
Why are businesses embracing it? What are its payoffs and pitfalls?
http://www.accelacomm.com/jaw/sdnl/114/51425149/
_______________________________________________
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
    Private Sub CreatePDF3(ByVal SourceFile As String, ByVal DestinationFile As 
String)

        Dim doc As iTextSharp.text.Document = New iTextSharp.text.Document(New 
iTextSharp.text.Rectangle(0, 0, 1700, 2200))

        Dim out As New IO.FileStream(DestinationFile, IO.FileMode.Create)

        Dim writer = iTextSharp.text.pdf.PdfWriter.GetInstance(doc, out)

        doc.Open()

        Dim content = writer.DirectContent

        Dim tifArray As iTextSharp.text.pdf.RandomAccessFileOrArray = New 
iTextSharp.text.pdf.RandomAccessFileOrArray(SourceFile)

        Dim pages = 
iTextSharp.text.pdf.codec.TiffImage.GetNumberOfPages(tifArray)

        For pageno As Integer = 1 To pages

            doc.Add(New iTextSharp.text.Paragraph())

            Dim img = 
iTextSharp.text.pdf.codec.TiffImage.GetTiffImage(tifArray, pageno)

            'Scale the Image

            'img.ScaleToFit(1700, 2200)

            If Not IsDBNull(img) Then
                ' If image is not null

                If (img.Width > PageSize.A4.Width) Or (img.Height > 
PageSize.A4.Height()) Then

                    'if images have a different resolution (dpi value) for x 
and y the scaling considers it 
                    If img.DpiX <> 0 And img.DpiY <> 0 And img.DpiX <> img.DpiY 
Then

                        img.ScalePercent(100)

                        Dim percentX As Integer = (PageSize.A4.Width * 100) / 
img.Width
                        Dim percentY As Integer = (PageSize.A4.Height() * 100) 
/ img.Height()
                        'img.setWidthPercentage(0)
                        img.WidthPercentage = 0

                    Else
                        'scaling the image if DPI values for x and y are the 
same 
                        'no customized scaling i.e. different values for x and 
y necessary
                        img.ScaleToFit(PageSize.A4.Width, PageSize.A4.Height)

                    End If

                End If

            End If

            img.SetAbsolutePosition(0, 0)

            content.AddImage(img)

            doc.NewPage()

        Next

        doc.Close()

        out.Dispose()

    End Sub
------------------------------------------------------------------------------
Cloud Computing - Latest Buzzword or a Glimpse of the Future?
This paper surveys cloud computing today: What are the benefits? 
Why are businesses embracing it? What are its payoffs and pitfalls?
http://www.accelacomm.com/jaw/sdnl/114/51425149/
_______________________________________________
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