using iTextSharp.text;
using iTextSharp.text.pdf;
string appPath = AppDomain.CurrentDomain.BaseDirectory;
Document doc = new Document(new Rectangle(390, 400), 0, 0, 0, 0); //纸张宽390 高400
PdfWriter.GetInstance(doc, new FileStream(appPath + "/DPD_15505984238198.pdf", FileMode.Create));
doc.Open();
//给pdf添加图片
string filesPath = appPath + (appPath.EndsWith("\\") ? "" : "\\") + "GzImage\\";
string gzImage = ReportPage.GetSession("gzImage");
Image image = Image.GetInstance(filesPath + gzImage);
float percentage = 1;
//这里都是图片最原始的宽度与高度
float resizedWidht = image.Width;
float resizedHeight = image.Height;
//这里用计算出来的百分比来缩小图片
image.ScalePercent(percentage * 100);
//gzX居左的距离 gzY居底的距离
int gzX = Int32.Parse(ReportPage.GetSession("gzX"));
int gzY = Int32.Parse(ReportPage.GetSession("gzY"));
image.SetAbsolutePosition(gzX, gzY);
document.Add(image);