public static float DrawImg(PDF pdf, Page page, string imgfile, float offsetY) { System.Drawing.Image image = System.Drawing.Image.FromFile(imgfile); double val = (double)pdfUtil.PDFpageeffwidth / (double)image.Width; double val2 = (double)(pdfUtil.PDFpageeffHeight - offsetY) / (double)image.Height; double factor = System.Math.Min(val, val2); PDFjet.NET.Image image2 = new PDFjet.NET.Image(pdf, new System.IO.BufferedStream(new System.IO.FileStream(imgfile, System.IO.FileMode.Open, System.IO.FileAccess.Read)), ImageType.JPG); image2.SetLocation(pdfUtil.PDFleft_margin, pdfUtil.PDFtop_margin + offsetY); image2.ScaleBy(factor); image2.DrawOn(page); return(image2.GetHeight()); }