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

Exception on code working in version that now doesn't work on version

Thread ID:





118851 Apr 15,2015 05:57 PM UTC Apr 17,2015 06:43 AM UTC WinRT 3
Tags: PDF
Ric Silva
Asked On April 15, 2015 05:57 PM UTC

I worked on a project some time ago, that used Syncfusion for WinRT version
it had some pdf manipulation, such as adding images to the pdf. After some effort it was working and the part of the code was something like this

foreach (var image in this.images)   //image is type Windows.Ui.Xaml.Controls.Image
                    var bitmap = image.Source as ImageSource;
                    var index = bitmaps.IndexOf(bitmap);
                    var signature = signatures.ElementAt(index);
                    var bytes = await signature.Data.EncodePngToJpeg();  //returns bytes of png image converted to jpg

                    PdfImage pdfImage;
                    using (var memoryStream = new MemoryStream(bytes))
                        pdfImage = PdfImage.FromStream(memoryStream);

      var transform = image.RenderTransform as CompositeTransform;

                    var x = (image.Margin.Left + transform.TranslateX + horizontalOffset) * 100 / pdfViewer.Zoom - 10;
                    var y = (image.Margin.Top + transform.TranslateY + verticalOffset) * 100 / pdfViewer.Zoom - 10;

                    var firstPage = pdfDocument.Pages[pdfViewer.PageNumber - 1];
                    var pageHeight = firstPage.Size.Height;
                    var pageWidth = firstPage.Size.Width;

                    var selpage = pdfViewer.PageNumber;

                    var pagn = selpage - 1;
                    if (pagn < 0)
                        pagn = 0;

                    var ss = pdfViewer.GetDescendantsOfType<ScrollViewer>();
                    var hh = ss.ElementAt(3);
                    float VertOff = (float)hh.VerticalOffset;
                    float VertOff2 = (VertOff * 100 / pdfViewer.Zoom) - ((pagn) * (pageHeight * 1.325f));

                    var page = pdfDocument.Pages[pagn];
                    var graphics = page.Graphics;

                    var width = image.Width;
                    var height = image.Height;

                    //float fWidth = (float)width;
                    //float fHeight = (float)height;
                    fWidth = 165f * 0.50f;
                    fHeight = 110f * 0.50f;

                    graphics.ScaleTransform(0.75f, 0.75f);
                    graphics.DrawImage(pdfImage, (float)x, (float)y + VertOff2, fWidth, fHeight);   // <-- exception is here 


then i installed the WinRT trial version ( and i started to get this exception 

A first chance exception of type 'System.NullReferenceException' occurred in Syncfusion.Pdf.WinRT.DLL
System.NullReferenceException' : {"Object reference not set to an instance of an object."}

with this StackTrace:

   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 Gapp_metro.Pages.PdfPage.<OnSaveButtonClick>d__25.MoveNext()

Did anything changed between versions that might be giving me an error?

Praveenkumar H [Syncfusion]
Replied On April 16, 2015 04:41 AM UTC

Hi Ric,

Currently Essential PDF Winrt supports the following image formats.

1. Jpeg
2. PNG
3. Tiff
4. Gif

Please try the PNG image without convert it to jpeg, we have attached the sample project for your reference, Please try this and let us know the result also please send us your input image we will check and let you know the details.


With Regards,

Ric Silva
Replied On April 16, 2015 01:46 PM UTC

I commented the png to jpg conversion and used the bytes of the png file directly and the result was the same.
the image comes from a webservice and they are the same i used when i had version

not quite sure what the problem is.
the image im using is attached.


Attachment: signature_5a49fbc8.zip

Praveenkumar H [Syncfusion]
Replied On April 17, 2015 06:43 AM UTC

Hi Ric,

Thank you for your update,

We are afraid that we are not able to reproduce the issue, we have attached the simplified sample project with the output document.
Can you please modify the sample to reproduce the issue and send back the sample to us, it will help us to investigate further in this.

With Regards,


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