We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PDF: DrawImage function stopped working

Thread ID:





131093 Jun 20,2017 09:08 AM UTC Jun 22,2017 11:26 AM UTC UWP 4
Tags: Pdf
Wolfgang Brucker
Asked On June 20, 2017 09:08 AM UTC

I had code that simply writes an Image to a PDF page.
Worked for weeks. All of a sudden, the working code suddenly stopped working.
PdfBitmapimage=newPdfBitmap(newMemoryStream(sub.TheImage));				//validimagedata
graphics.DrawImage(image,0,0,page.Graphics.ClientSize.Width,page.Graphics.ClientSize.Height);	//<==suddenlyraisesexception	

The problem is with
graphics.DrawImage(image,0,0,page.Graphics.ClientSize.Width,page.Graphics.ClientSize.Height);		//<==suddenlyraisesexception

This raises a NullReferenceException - although NOTHING in here has a null value: not the sub.TheImage object, not the graphics object, not the image object, neither the ClientSize.
This once working code just all of a sudden stopped working. There mus be a problem with the .DrawImage() function with one of the latest windows updates. I see no other explanation.

Wolfgang Brucker
Replied On June 20, 2017 09:09 AM UTC

Exception is:

+  ex {System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.Pdf.Graphics.PdfBitmap.SetColorSpace()
   at Syncfusion.Pdf.Graphics.PdfBitmap.Save()
   at Syncfusion.Pdf.Graphics.PdfGraphics.DrawImage(PdfImage image, Single x, Single y, Single width, Single height)
   at Scan10.Views.MainPage.<ExportAsPDF>d__23.MoveNext()} System.Exception {System.NullReferenceException}

Surya Kumar [Syncfusion]
Replied On June 21, 2017 02:04 PM UTC

Hi Wolfgang, 
Thank you for using Syncfusion products, 
We have tried to reproduce the issue which you have mentioned, with the code snippet which you have given, but we are unable to reproduce the same. 
Please find the sample in which we tried to reproduce the issue from the below link, if you can still reproduce the issue, please modify the code in sample attached and share the image file with which the issue is reproduced. 
Sample Link: 
Surya Kumar 

Wolfgang Brucker
Replied On June 21, 2017 02:29 PM UTC

The problem seems to be related to BMP images only.  Some BMP images do work while some others DO NOT WORK and raise a NullReference exception. The exception above is real, not from a dream.  So as a workaround I now convert every BMP to a PNG and load that tmp PNG from stream to PdfBitmap.  That does work where the original BMP failed.  But this doesn't speed up my app, you know...   Nevertheless I would consider this to be a bug because according to your documentation BMPs should do fine which is not true in any case.  Maybe the problem has to do with the image dimensions?  I am not using little images like 320x240 but very large ones (2700 x 1900).

Surya Kumar [Syncfusion]
Replied On June 22, 2017 11:26 AM UTC

Hi Wolfgang,  
We have created separate incident to follow up the issue with” Null reference exception occurs while drawing the BMP image to PDF in UWP platform” which can be tracked from below link: 
Surya Kumar 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon