Hello,
I have encountered two bugs using the Syncfusion Flutter PDF package.
This is the link of the PDF file: https://drive.google.com/file/d/1Ki7i6JdCrzc4XJbbOlv94mGIkvRqRmU3/view?usp=share_link
This PDF has both of the issues. When I encountered the first issue I removed the code for getting the font name, by returning an empty string at the start of the getFontName() method.
My code is:
The error is:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'PdfReferenceHolder' is not a subtype of type 'PdfName?' in type
cast
#0 FontStructure.getFontName (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/font_structure.dart:1130:60)
#1 FontStructure.fontName (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/font_structure.dart:234:41)#2 PdfPageResources.isSameFont.<anonymous closure>.<anonymous closure> (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/page_resource_loader.dart:228:30)
#3 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#4 PdfPageResources.isSameFont.<anonymous closure> (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/page_resource_loader.dart:227:22)
#5 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#6 PdfPageResources.isSameFont (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/page_resource_loader.dart:226:20)
#7 ImageRenderer._renderTextElementWithLeading (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/image_renderer.dart:618:42)
#8 ImageRenderer.renderAsImage (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/image_renderer.dart:373:17)
#9 PdfTextExtractor._getTextLine (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/pdf_text_extractor.dart:317:14)
#10 PdfTextExtractor._extractTextLines (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/pdf_text_extractor.dart:207:14)
#11 PdfTextExtractor.extractTextLines (package:syncfusion_flutter_pdf/src/pdf/implementation/exporting/pdf_text_extractor/pdf_text_extractor.dart:126:12)
#12 loadDocument (package:summary_ai/load_document.dart:45:19)
<asynchronous suspension>
So the code that generates the error is:
We confirmed the issue ”Unhandled exception while extracting text from the PDF document” as a defect in our product and defect and we will include the fix in our upcoming weekly NuGet release, which will be available on April 18th, 2023.
Please use the below feedback link to track the status of the reported bug. https://www.syncfusion.com/feedback/42760/unhandled-exception-while-extracting-text-from-the-pdf-document
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
The fix for the reported issue ”Unhandled exception while extracting text from the PDF document” " has been included in our weekly release v21.1.41.
Kindly use the following link to refer our latest package,
https://pub.dev/packages/syncfusion_flutter_pdf/versions/21.1.41