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.

Attachment: addFaxTif.pdf
Description: Adobe PDF document

------------------------------------------------------------------------------
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