App crashes on print after successfully saving encrypted pdf in SfPdfViewer

My app crashes with NullReferenceException at "Syncfusion.Pdf.Portable" source. StackTrace is below:

 at Syncfusion.Pdf.Primitives.PdfStream.get_Data () [0x00000] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Primitives.PdfStream.Decrypt (Syncfusion.Pdf.Security.PdfEncryptor encryptor, System.Int64 currObjNumber) [0x00012] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.Decrypt (Syncfusion.Pdf.Security.IPdfDecryptable obj) [0x00053] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.Decrypt (Syncfusion.Pdf.Primitives.IPdfPrimitive obj) [0x0004f] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.GetObject (Syncfusion.Pdf.Primitives.IPdfPrimitive pointer) [0x00139] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Parsing.PdfLoadedStateField.GetItemValue (Syncfusion.Pdf.Primitives.PdfDictionary dictionary, Syncfusion.Pdf.IO.PdfCrossTable crossTable) [0x000a7] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Parsing.PdfLoadedStateField.ApplyAppearance (Syncfusion.Pdf.Primitives.PdfDictionary widget, Syncfusion.Pdf.Parsing.PdfLoadedStateItem item) [0x0005d] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Parsing.PdfLoadedRadioButtonListField.BeginSave () [0x00039] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Parsing.PdfLoadedForm.Dictionary_BeginSave (System.Object sender, Syncfusion.Pdf.Primitives.SavePdfPrimitiveEventArgs ars) [0x001a5] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_SavePdfPrimitiveEventArgs(object,Syncfusion.Pdf.Primitives.SavePdfPrimitiveEventArgs)
  at Syncfusion.Pdf.Primitives.PdfDictionary.OnBeginSave (Syncfusion.Pdf.Primitives.SavePdfPrimitiveEventArgs args) [0x00018] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Primitives.PdfDictionary.Save (Syncfusion.Pdf.IO.IPdfWriter writer, System.Boolean bRaiseEvent) [0x0002c] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Primitives.PdfDictionary.Save (Syncfusion.Pdf.IO.IPdfWriter writer) [0x0001e] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.DoSaveObject (Syncfusion.Pdf.Primitives.IPdfPrimitive obj, Syncfusion.Pdf.Primitives.PdfReference reference, Syncfusion.Pdf.IO.PdfWriter writer) [0x000ae] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.SaveIndirectObject (Syncfusion.Pdf.Primitives.IPdfPrimitive obj, Syncfusion.Pdf.IO.PdfWriter writer) [0x001d7] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.SavePrimitive (Syncfusion.Pdf.Primitives.IPdfPrimitive obj, Syncfusion.Pdf.IO.PdfWriter writer) [0x0010e] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.SaveObjects (Syncfusion.Pdf.IO.PdfWriter writer) [0x00139] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.IO.PdfCrossTable.Save (Syncfusion.Pdf.IO.PdfWriter writer) [0x00367] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Parsing.PdfLoadedDocument.AppendDocument (Syncfusion.Pdf.IO.PdfWriter writer) [0x00083] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.Pdf.Parsing.PdfLoadedDocument.Save (System.IO.Stream stream) [0x004ff] in <684a4c2bcdbe48cc88eb5eed3eee485c>:0 
  at Syncfusion.SfPdfViewer.XForms.iOS.PrintService..ctor (Syncfusion.SfPdfViewer.XForms.iOS.ScrollViewEx scrollView, System.String fileName) [0x0001e] in <6c50c09a36844761b415ded21575c807>:0 
  at Syncfusion.SfPdfViewer.XForms.iOS.ScrollViewEx.Print (System.String fileName) [0x00058] in <6c50c09a36844761b415ded21575c807>:0 
  at Syncfusion.SfPdfViewer.XForms.iOS.PdfViewerDependencyService.Print (System.String fileName, System.Object nativeObject) [0x00003] in <6c50c09a36844761b415ded21575c807>:0 
  at Syncfusion.SfPdfViewer.XForms.SfPdfViewer.Print () [0x0001a] in <84ffbbdf7f22454d97d808939f778078>:0 
  at Saki.SamsTrack.Views.CompletedPdfView.AirPrint_Clicked (System.Object sender, System.EventArgs e) [0x00001] in /Users/Admin/Desktop/SamsTrack 3/src/Saki.SamsTrack.Mobile.Shared/Views/CompletedPdfView.xaml.cs:42 
  at Xamarin.Forms.Button.Xamarin.Forms.Internals.IButtonElement.PropagateUpClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:187 
  at Xamarin.Forms.ButtonElement.ElementClicked (Xamarin.Forms.VisualElement visualElement, Xamarin.Forms.Internals.IButtonElement ButtonElementManager) [0x0001f] in D:\a\1\s\Xamarin.Forms.Core\ButtonElement.cs:61 
  at Xamarin.Forms.Button.SendClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:173 
  at Xamarin.Forms.Platform.iOS.ButtonElementManager.OnButtonTouchUpInside (Xamarin.Forms.IButtonController element) [0x00009] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ButtonElementManager.cs:86 
  at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (System.Object sender, System.EventArgs eventArgs) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ButtonRenderer.cs:189 
  at UIKit.UIControlEventProxy.Activated () [0x00004] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIControl.cs:38 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65 
  at Saki.SamsTrack.Application.Main (System.String[] args) [0x0001b] in /Users/Admin/Desktop/SamsTrack 3/src/Saki.SamsTrack.Mobile.iOS/Main.cs:20 

I use the Annotation tool on the SfPdfViewer and then click on Save from the top toolbar in the viewer and the encrypted pdf gets overwritten. Then I click on the AirPrint button and my app crashes.

I have attached the necessary files. Please let me know if you need more info.
Thank you!

Attachment: attach_6abc867f.zip

1 Reply 1 reply marked as answer

MK Muralitharan Karikalan Syncfusion Team March 26, 2021 11:21 AM UTC

Hi Madhu Ganesh,  
  
Greetings from Syncfusion support,  
  
We were unable to reproduce the issue, “Application Crashes with exception while printing the encrypted document after save” and it is working as expected. Could you please try the below-provided sample and let us know whether we have missed out anything while replicating the issue.  
   
Please find the sample in the below link, which we have used to reproduce the issue in our end  
  
Kindly share the following details to analyze more on this issue and assist you with the better solution    
1.Simple sample/ modify the above sample to reproduce the issue.   
2.Replication video/procedure to reproduce the issue.  
3.PDF document   
  
Regards,  
Muralitharan K  


Marked as answer
Loader.
Up arrow icon