here i am trying to convert jpg formatted images files to single pdf by appending one by one.. here is the code
//Create a new document
iTextSharp.text.Document Doc = new iTextSharp.text.Document(PageSize.A4);
//Store the document on the desktop
string PDFOutput = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Output2.pdf");
PdfWriter writer = PdfWriter.GetInstance(Doc, new FileStream(PDFOutput, FileMode.Create, FileAccess.Write, FileShare.Read));
//Open the PDF for writing
Doc.Open();
//give folder from your local system that contains images
string Folder = System.Web.Configuration.WebConfigurationManager.AppSettings["path"].ToString();
foreach (string F in System.IO.Directory.GetFiles(Folder, "*.jpg"))
{
Image image1 = Image.GetInstance(F);
//image1.SetAbsolutePosition(10f, 10f);
image1.ScaleAbsolute(100, 300);
//Insert a page
Doc.NewPage();
//Add image
Doc.Add(image1);
}
//Close the PDF
Doc.Close();
but in output the image is not fitted into page but exceeds the page size..
help me out how to the set image size to fit without loss of quality... thank you