AlessioLuciani / flutter-pdf-text

A plugin for Flutter that allows you to read the text content of PDF documents and convert it into strings.
MIT License
18 stars 44 forks source link

Crash in the underlying Android package com.tom_roush.pdfbox #34

Open valorbyte opened 6 months ago

valorbyte commented 6 months ago

Certain offending PDF files may cause this native crash:

E/AndroidRuntime( 7710): FATAL EXCEPTION: Thread-6 E/AndroidRuntime( 7710): Process: com.valorbyte.****, PID: 7710 E/AndroidRuntime( 7710): java.lang.StringIndexOutOfBoundsException: length=2; index=2 E/AndroidRuntime( 7710): at java.lang.String.charAt(Native Method) E/AndroidRuntime( 7710): at com.tom_roush.pdfbox.util.DateConverter.parseDate(DateConverter.java:608) E/AndroidRuntime( 7710): at com.tom_roush.pdfbox.util.DateConverter.toCalendar(DateConverter.java:676) E/AndroidRuntime( 7710): at com.tom_roush.pdfbox.util.DateConverter.toCalendar(DateConverter.java:654) E/AndroidRuntime( 7710): at com.tom_roush.pdfbox.cos.COSDictionary.getDate(COSDictionary.java:816) E/AndroidRuntime( 7710): at com.tom_roush.pdfbox.pdmodel.PDDocumentInformation.getCreationDate(PDDocumentInformation.java:210) E/AndroidRuntime( 7710): at dev.aluc.pdf_text.PdfTextPlugin.initDoc(PdfTextPlugin.kt:93) E/AndroidRuntime( 7710): at dev.aluc.pdf_text.PdfTextPlugin.access$initDoc(PdfTextPlugin.kt:20) E/AndroidRuntime( 7710): at dev.aluc.pdf_text.PdfTextPlugin$onMethodCall$1.invoke(PdfTextPlugin.kt:53) E/AndroidRuntime( 7710): at dev.aluc.pdf_text.PdfTextPlugin$onMethodCall$1.invoke(PdfTextPlugin.kt:47) E/AndroidRuntime( 7710): at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

valorbyte commented 6 months ago

Updating the PDFBox-Android package seems to fix it. Did not test the whole implementation for any breaking changes but works for me. To test use this:

  pdf_text:
    git:
      url: "https://github.com/valorbyte/flutter-pdf-text"
      ref: "c38c46c590ffc4a429f3f3b8fc5cdf8bd572688e"