PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Feb 26, 2020 12:49 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Apr 03, 2009 8:50 am 
Offline

Joined: Thu Aug 21, 2008 7:23 am
Posts: 5
Hi.

I wrote a small free application that converts image files to PDF documents. When using it on a BMP file, one user encountered this error:

Code:
NotImplementedException: Image format not supported.
at PdfSharp.Pdf.Advanced.PdfImage.InitializeNonJpeg()
at PdfSharp.Pdf.Advanced.PdfImage..ctor(PdfDocument document, XImage image)
at PdfSharp.Pdf.Advanced.PdfImageTable.GetImage(XImage image)
at PdfSharp.Pdf.PdfPage.GetImageName(XImage image)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.GetImageName(XImage image)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.Realize(XImage image)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawImage(XImage image, Double x, Double y, Double width, Double height)
at PdfSharp.Drawing.XGraphics.DrawImage(XImage image, Double x, Double y)
at PdfSharp.Drawing.XGraphics.DrawImage(XImage image, Int32 x, Int32 y)


I was skeptic at first, but he sent me the file and it is correct and accurate. It's a BMP file, which can even be displayed by the basic viewer of TotalCommander, pressing F3.

Debugging the application I found the LOC where the exception is thrown.
It's the one where "DrawImage" is called:

Code:
PdfDocument doc = new PdfDocument();
                doc.Pages.Add(new PdfPage());
                XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
                XImage img = XImage.FromFile(source);

                //adjust page size to fit image
                if (doc.Pages[0].Width < XUnit.FromPoint(img.Size.Width))
                    doc.Pages[0].Width = XUnit.FromPoint(img.Size.Width);

                if (doc.Pages[0].Height < XUnit.FromPoint(img.Size.Height))
                    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();


I tested with PDFSharp versions 1 and 1.20 beta and the result is the same. If needed I can provide the BMP file that causes this.

Thanks for your time and effort and keep up the good work!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 07, 2009 8:06 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3023
Location: Cologne, Germany
Hi!

We need the BMP to investigate this.

I sent you a PM.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 07, 2009 9:06 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3023
Location: Cologne, Germany
The image format is: Format16bppRgb555
(Specifies that the format is 16 bits per pixel; 5 bits each are used for the red, green, and blue components. The remaining bit is not used.)

I knew there was such a format but didn't know how to create it.

I'll let you know when it's implemented.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Apr 09, 2009 11:45 am 
Offline

Joined: Thu Aug 21, 2008 7:23 am
Posts: 5
Thanks for looking into it.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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