PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jun 25, 2024 8:18 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: XImage.Fromfile
PostPosted: Wed Mar 23, 2011 7:43 pm 
Offline

Joined: Wed Mar 23, 2011 7:35 pm
Posts: 1
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


Top
 Profile  
Reply with quote  
 Post subject: Re: XImage.Fromfile
PostPosted: Thu Mar 24, 2011 7:57 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
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)?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group