PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

XImage.Fromfile
http://forum.pdfsharp.de/viewtopic.php?f=2&t=1593
Page 1 of 1

Author:  terry2025 [ Wed Mar 23, 2011 7:43 pm ]
Post subject:  XImage.Fromfile

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

Author:  Thomas Hoevel [ Thu Mar 24, 2011 7:57 am ]
Post subject:  Re: XImage.Fromfile

It works with some images, it doesn't work with your image.

How can we investigate this issue without your image?

You've got the complete PDFsharp source.

Maybe this error comes from the Framework or the Operating System. Can you open the image with e. g. MS Paint?
Have you tried both GDI+ and WPF builds? Have you tried different operating systems (XP, Vista, Windows 7)?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/