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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

118851 Apr 15,2015 01:57 PM Apr 17,2015 02:43 AM WinRT 3
loading
Tags: PDF
Ric Silva
Asked On April 15, 2015 01:57 PM

I worked on a project some time ago, that used Syncfusion for WinRT version 12.2.0.36
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 (13.1.0.21) 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 12:41 AM

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.

http://www.syncfusion.com/downloads/support/forum/118851/InsertingImage613405857.zip



With Regards,
Praveen

Ric Silva
Replied On April 16, 2015 09:46 AM

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 12.2.0.36

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

Exception

Attachment: signature_5a49fbc8.zip

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

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.
http://www.syncfusion.com/downloads/support/forum/118851/InsertingImage-1941656111.zip

With Regards,
Praveen

CONFIRMATION

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.

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.

;