using iTextSharp.text;
using iTextSharp.text.pdf;
string appPath = AppDomain.CurrentDomain.BaseDirectory;
Document doc = new Document(new Rectangle(390, 400), 0, 0, 0, 0); //Paper width 390 height 400
PdfWriter.GetInstance(doc, new FileStream(appPath + "/DPD_15505984238198.pdf", FileMode.Create));
doc.Open();
//Add pictures to pdf
string filesPath = appPath + (appPath.EndsWith("\\") ? "" : "\\") + "GzImage\\";
string gzImage = ReportPage.GetSession("gzImage");
Image image = Image.GetInstance(filesPath + gzImage);
float percentage = 1;
//Here are the original width and height of the picture
float resizedWidht = image.Width;
float resizedHeight = image.Height;
//Here uses the calculated percentage to reduce the picture
image.ScalePercent(percentage * 100);
//The distance from gzX to the left and the distance from gzY to the bottom
int gzX = Int32.Parse(ReportPage.GetSession("gzX"));
int gzY = Int32.Parse(ReportPage.GetSession("gzY"));
image.SetAbsolutePosition(gzX, gzY);
document.Add(image);