I'm using window form .net and would like to convert scanned images to PDF, thus generating PDF images. I'm using PDFSharp. I have the following code but it only generates a page. What commands should I use to generate grab the images and generate the PDF with pages. at first I think of loading a DataTable and after that read each of the lines and generate but I do not know how to do it .... Could you give me a tip?
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
try
{
string source = (e.Argument as string[])[0];
string destinaton = (e.Argument as string[])[1];
PdfDocument doc = new PdfDocument();
doc.Pages.Add(new PdfPage());
XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
XImage img = XImage.FromFile(source);
doc.Pages[0].Width = XUnit.FromPoint(img.Size.Width);
doc.Pages[0].Height = XUnit.FromPoint(img.Size.Height);
xgr.DrawImage(img, 0, 0, img.Size.Width, img.Size.Height);
doc.Save(destinaton);
doc.Close();
success = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}