DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.42k stars 632 forks source link

[Bad state: No element]: Thrown if text contains a backspace/rubout character #1749

Open rohansohonee1 opened 1 month ago

rohansohonee1 commented 1 month ago

Describe the bug When using the backspace/rubout character in the pdf Text widget. The pdf document is not generated & throws an error.

To Reproduce Run the sample from this project.

Console logs

======== Exception caught by printing ==============================================================
The following StateError was thrown while generating a PDF:
Bad state: No element

When the exception was thrown, this was the stack: 
#0      Iterable.first (dart:core/iterable.dart:643:7)
#1      TtfWriter.withChars (package:pdf/src/pdf/font/ttf_writer.dart:112:67)
#2      PdfTtfFont._buildType0 (package:pdf/src/pdf/obj/ttffont.dart:121:28)
#3      PdfTtfFont.prepare (package:pdf/src/pdf/obj/ttffont.dart:162:7)
#4      PdfDocument._write (package:pdf/src/pdf/document.dart:225:10)
#5      PdfDocument.save.<anonymous closure> (package:pdf/src/pdf/document.dart:259:13)
#6      _RemoteRunner._run (dart:isolate:1090:47)
#7      _RemoteRunner._remoteExecute (dart:isolate:1084:12)
#8      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:300:17)
#9      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
PageFormat: "PdfPageFormat 612.0x792.0 margins:72.0, 72.0, 72.0, 72.0"
====================================================================================================

Expected behavior

The pdf document should be generated with no errors.

Flutter Doctor

[✓] Flutter (Channel stable, 3.22.2, on macOS 12.7.6 21H1320 darwin-x64, locale en-US)
    • Flutter version 3.22.2 on channel stable at /Users/appleapple/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (4 months ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/appleapple/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    ! Flutter recommends a minimum Xcode version of 15.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.93.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.96.0

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 12 (API 31) (emulator)
    • macOS (desktop)              • macos         • darwin-x64     • macOS 12.7.6 21H1320 darwin-x64
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 129.0.6668.71

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Smartphone (please complete the following information):

Additional Context

pdf: 3.11.1
printing: 5.13.2