syncfusion/flutter-examples

Unhandled Exception: type 'PdfReferenceHolder' is not a subtype of type 'PdfDictionary?' in type cast

ndubbaka opened this issue · 3 comments

Tried to run https://www.syncfusion.com/downloads/support/directtrac/general/ze/textmarkup_annotation-1766537037 with attached PDF file: X Physics EM Title Free.pmd.pdf. The sample PDF file at https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf works nice. Only the attached PDF file throwing this error.

I tried to use highlight option with attached PDF using https://support.syncfusion.com/kb/article/11033/how-to-add-text-markup-annotation-in-flutter-pdf-viewer-using-syncfusion-pdf-package and I see below error.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'PdfReferenceHolder' is not a subtype of type 'PdfDictionary?' in type cast
E/flutter ( 6552): #0      PdfResources.add (package:syncfusion_flutter_pdf/src/pdf/implementation/graphics/pdf_resources.dart:115:58)
E/flutter ( 6552): #1      PdfResources.getName (package:syncfusion_flutter_pdf/src/pdf/implementation/graphics/pdf_resources.dart:70:9)
E/flutter ( 6552): #2      PdfGraphics._drawTemplate (package:syncfusion_flutter_pdf/src/pdf/implementation/graphics/pdf_graphics.dart:943:36)
E/flutter ( 6552): #3      PdfGraphics.drawPdfTemplate (package:syncfusion_flutter_pdf/src/pdf/implementation/graphics/pdf_graphics.dart:398:5)
E/flutter ( 6552): #4      PdfLineAnnotationHelper._flattenAnnotation (package:syncfusion_flutter_pdf/src/pdf/implementation/annotations/pdf_line_annotation.dart:489:21)
E/flutter ( 6552): #5      PdfLineAnnotationHelper.save (package:syncfusion_flutter_pdf/src/pdf/implementation/annotations/pdf_line_annotation.dart:361:13)
E/flutter ( 6552): #6      PdfAnnotationHelper.save (package:syncfusion_flutter_pdf/src/pdf/implementation/annotations/pdf_annotation.dart:1873:53)
E/flutter ( 6552): #7      PdfAnnotationHelper.dictionaryBeginSave (package:syncfusion_flutter_pdf/src/pdf/implementation/annotations/pdf_annotation.dart:587:29)
E/flutter ( 6552): #8      PdfDictionary.onBeginSave (package:syncfusion_flutter_pdf/src/pdf/implementation/primitives/pdf_dictionary.dart:543:26)
E/flutter ( 6552): #9      PdfDictionary.saveDictionary (package:syncfusion_flutter_pdf/src/pdf/implementation/primitives/pdf_dictionary.dart:210:7)
E/flutter ( 6552): #10     PdfDictionary.save (package:syncfusion_flutter_pdf/src/pdf/implementation/primitives/pdf_dictionary.dart:507:5)
E/flutter ( 6552): #11     PdfCrossTable._doSaveObject (package:syncfusion_flutter_pdf/src/pdf/implementation/io/pdf_cross_table.dart:859:12)
E/flutter ( 6552): #12     PdfCrossTable._saveIndirectObject (package:syncfusion_flutter_pdf/src/pdf/implementation/io/pdf_cross_table.dart:481:7)
E/flutter ( 6552): #13     PdfCrossTable._saveObjects (package:syncfusion_flutter_pdf/src/pdf/implementation/io/pdf_cross_table.dart:356:9)
E/flutter ( 6552): #14     PdfCrossTable.save (package:syncfusion_flutter_pdf/src/pdf/implementation/io/pdf_cross_table.dart:215:5)
E/flutter ( 6552): #15     PdfDocument._appendDocument (package:syncfusion_flutter_pdf/src/pdf/implementation/pdf_document/pdf_document.dart:823:24)
E/flutter ( 6552): #16     PdfDocument.saveSync (package:syncfusion_flutter_pdf/src/pdf/implementation/pdf_document/pdf_document.dart:583:7)
E/flutter ( 6552): #17     _HomePage._drawAnnotation (package:textmarkup_annotation/main.dart:131:44)
E/flutter ( 6552): #18     _HomePage._addAnnotation.<anonymous closure> (package:textmarkup_annotation/main.dart:62:11)
E/flutter ( 6552): <asynchronous suspension>

X Physics EM Title Free.pmd.pdf

We tried to replicate the reported issue with provided details, but the text markup annotation KB sample works fine on our side. For your reference, we have attached the sample and included a screen recording of the output, which can be downloaded from the attachment. Please review the shared sample. If the issue still occurs on your end, kindly provide us with the steps or a video demonstrating how to reproduce the issue. This will be helpful for us to provide prompt solution at earliest.
Sample.zip

nice. I tried the sample you sent and it's working nice. Is there a github repo for this new sample code? I got the old code from https://www.syncfusion.com/downloads/support/directtrac/general/ze/textmarkup_annotation-1766537037

Thank you for the update. Please let us know if you need any further assistance and we will update the new sample in the KB documentation.