I'm new to the PDFSharp and to the new PDF convertion process, I'm trying to create a PDF file from a single tiff image but when it comes to the XImage.FromFile I get the message "Out of Memory". I modified the graphics program that you have in your examples and it creates the image into the pdf page, but in my code it just gives that error message. Here is my code: private void tolsbfrmmain_topdf_Click(object sender, EventArgs e) { PdfSharp.Pdf.PdfDocument pdfdoc = null; PdfSharp.Drawing.XGraphics xgr = null; PdfSharp.Drawing.XImage tifimg= null;
pdfdoc = new PdfSharp.Pdf.PdfDocument(); try { foreach (string pathfile in imagenames) { pdfdoc.Pages.Add(new PdfSharp.Pdf.PdfPage()); int pageindex = pdfdoc.Pages.Count - 1; xgr = XGraphics.FromPdfPage(pdfdoc.Pages[pageindex]); tifimg = XImage.FromFile(pathfile); <--- right here is where I get the message.. xgr.DrawImage(tifimg, 0, 0); pdfdoc.Save(@"c:\testimage.pdf"); pdfdoc.Close(); } } catch (Exception error) { MessageBox.Show(error.Message); } }
I'm using VS2010. Any help would be appreciated.
Thank you
|