├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ ├── feature_request.md │ └── support.md └── workflows │ ├── dart.yaml │ └── stale.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── demo ├── .gitignore ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── net │ │ │ │ │ └── nfet │ │ │ │ │ └── printing_demo │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── assets │ ├── app-logo.svg │ ├── calendar.svg │ ├── document.svg │ ├── garland.svg │ ├── invoice.svg │ ├── logo.svg │ ├── medail.svg │ ├── profile.jpg │ ├── resume.svg │ ├── swirls.svg │ ├── swirls1.svg │ ├── swirls2.svg │ └── swirls3.svg ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-50x50@1x.png │ │ │ ├── Icon-App-50x50@2x.png │ │ │ ├── Icon-App-57x57@1x.png │ │ │ ├── Icon-App-57x57@2x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-72x72@1x.png │ │ │ ├── Icon-App-72x72@2x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ ├── app.dart │ ├── data.dart │ ├── examples.dart │ ├── examples │ │ ├── calendar.dart │ │ ├── certificate.dart │ │ ├── document.dart │ │ ├── invoice.dart │ │ ├── report.dart │ │ └── resume.dart │ └── main.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ ├── main.cc │ ├── my_application.cc │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ └── Flutter-Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ └── MainMenu.xib │ │ ├── Configs │ │ ├── AppInfo.xcconfig │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements ├── pubspec.yaml ├── test │ └── printing_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── pdf ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example.jpg ├── example │ └── main.dart ├── lib │ ├── pdf.dart │ ├── src │ │ ├── pdf │ │ │ ├── color.dart │ │ │ ├── colors.dart │ │ │ ├── document.dart │ │ │ ├── document_parser.dart │ │ │ ├── exif.dart │ │ │ ├── font │ │ │ │ ├── arabic.dart │ │ │ │ ├── bidi_utils.dart │ │ │ │ ├── font_metrics.dart │ │ │ │ ├── ttf_parser.dart │ │ │ │ ├── ttf_writer.dart │ │ │ │ └── type1_fonts.dart │ │ │ ├── format │ │ │ │ ├── array.dart │ │ │ │ ├── ascii85.dart │ │ │ │ ├── base.dart │ │ │ │ ├── bool.dart │ │ │ │ ├── diagnostic.dart │ │ │ │ ├── dict.dart │ │ │ │ ├── dict_stream.dart │ │ │ │ ├── indirect.dart │ │ │ │ ├── name.dart │ │ │ │ ├── null_value.dart │ │ │ │ ├── num.dart │ │ │ │ ├── object_base.dart │ │ │ │ ├── stream.dart │ │ │ │ ├── string.dart │ │ │ │ └── xref.dart │ │ │ ├── graphic_state.dart │ │ │ ├── graphics.dart │ │ │ ├── io │ │ │ │ ├── js.dart │ │ │ │ ├── na.dart │ │ │ │ └── vm.dart │ │ │ ├── obj │ │ │ │ ├── annotation.dart │ │ │ │ ├── array.dart │ │ │ │ ├── border.dart │ │ │ │ ├── catalog.dart │ │ │ │ ├── encryption.dart │ │ │ │ ├── font.dart │ │ │ │ ├── font_descriptor.dart │ │ │ │ ├── formxobject.dart │ │ │ │ ├── function.dart │ │ │ │ ├── graphic_stream.dart │ │ │ │ ├── image.dart │ │ │ │ ├── info.dart │ │ │ │ ├── metadata.dart │ │ │ │ ├── names.dart │ │ │ │ ├── object.dart │ │ │ │ ├── object_dict.dart │ │ │ │ ├── object_stream.dart │ │ │ │ ├── outline.dart │ │ │ │ ├── page.dart │ │ │ │ ├── page_label.dart │ │ │ │ ├── page_list.dart │ │ │ │ ├── pattern.dart │ │ │ │ ├── pdfa │ │ │ │ │ ├── README.md │ │ │ │ │ ├── pdfa_attached_files.dart │ │ │ │ │ ├── pdfa_color_profile.dart │ │ │ │ │ ├── pdfa_date_format.dart │ │ │ │ │ ├── pdfa_facturx_rdf.dart │ │ │ │ │ ├── pdfa_rdf.dart │ │ │ │ │ └── sRGB2014.icc │ │ │ │ ├── shading.dart │ │ │ │ ├── signature.dart │ │ │ │ ├── smask.dart │ │ │ │ ├── ttffont.dart │ │ │ │ ├── type1_font.dart │ │ │ │ ├── unicode_cmap.dart │ │ │ │ └── xobject.dart │ │ │ ├── options.dart │ │ │ ├── page_format.dart │ │ │ ├── point.dart │ │ │ ├── raster.dart │ │ │ └── rect.dart │ │ ├── priv.dart │ │ ├── svg │ │ │ ├── brush.dart │ │ │ ├── clip_path.dart │ │ │ ├── color.dart │ │ │ ├── colors.dart │ │ │ ├── gradient.dart │ │ │ ├── group.dart │ │ │ ├── image.dart │ │ │ ├── mask_path.dart │ │ │ ├── operation.dart │ │ │ ├── painter.dart │ │ │ ├── parser.dart │ │ │ ├── path.dart │ │ │ ├── symbol.dart │ │ │ ├── text.dart │ │ │ ├── transform.dart │ │ │ └── use.dart │ │ └── widgets │ │ │ ├── annotations.dart │ │ │ ├── barcode.dart │ │ │ ├── basic.dart │ │ │ ├── border_radius.dart │ │ │ ├── box_border.dart │ │ │ ├── chart │ │ │ ├── bar_chart.dart │ │ │ ├── chart.dart │ │ │ ├── grid_axis.dart │ │ │ ├── grid_cartesian.dart │ │ │ ├── grid_radial.dart │ │ │ ├── legend.dart │ │ │ ├── line_chart.dart │ │ │ ├── pie_chart.dart │ │ │ └── point_chart.dart │ │ │ ├── clip.dart │ │ │ ├── container.dart │ │ │ ├── content.dart │ │ │ ├── decoration.dart │ │ │ ├── document.dart │ │ │ ├── flex.dart │ │ │ ├── font.dart │ │ │ ├── forms.dart │ │ │ ├── geometry.dart │ │ │ ├── grid_paper.dart │ │ │ ├── grid_view.dart │ │ │ ├── icon.dart │ │ │ ├── image.dart │ │ │ ├── image_provider.dart │ │ │ ├── multi_page.dart │ │ │ ├── page.dart │ │ │ ├── page_theme.dart │ │ │ ├── partitions.dart │ │ │ ├── placeholders.dart │ │ │ ├── progress.dart │ │ │ ├── shape.dart │ │ │ ├── stack.dart │ │ │ ├── svg.dart │ │ │ ├── table.dart │ │ │ ├── table_helper.dart │ │ │ ├── text.dart │ │ │ ├── text_style.dart │ │ │ ├── theme.dart │ │ │ ├── widget.dart │ │ │ └── wrap.dart │ └── widgets.dart ├── pubspec.yaml └── test │ ├── annotations_test.dart │ ├── arabic_test.dart │ ├── colors_test.dart │ ├── complex_test.dart │ ├── data_types_test.dart │ ├── image_test.dart │ ├── isolate_test.dart │ ├── jpeg_test.dart │ ├── metrics_test.dart │ ├── minimal_test.dart │ ├── orientation_test.dart │ ├── page_labels_test.dart │ ├── roll_paper_test.dart │ ├── rtl_layout_test.dart │ ├── ttf_test.dart │ ├── type1_test.dart │ ├── utils.dart │ ├── widget_barcode_test.dart │ ├── widget_basic_test.dart │ ├── widget_chart_test.dart │ ├── widget_clip_test.dart │ ├── widget_container_test.dart │ ├── widget_flex_test.dart │ ├── widget_form_test.dart │ ├── widget_grid_view_test.dart │ ├── widget_icon_test.dart │ ├── widget_multipage_test.dart │ ├── widget_newpage_test.dart │ ├── widget_opacity_test.dart │ ├── widget_outline_test.dart │ ├── widget_partitions_test.dart │ ├── widget_svg_test.dart │ ├── widget_table_test.dart │ ├── widget_test.dart │ ├── widget_text_test.dart │ ├── widget_theme_test.dart │ ├── widget_toc_test.dart │ ├── widget_watermark_test.dart │ └── widget_wrap_test.dart ├── printing ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android │ ├── build.gradle │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ ├── android │ │ │ └── print │ │ │ │ └── PdfConvert.java │ │ └── net │ │ │ └── nfet │ │ │ └── flutter │ │ │ └── printing │ │ │ ├── PrintFileProvider.java │ │ │ ├── PrintingHandler.java │ │ │ ├── PrintingJob.java │ │ │ └── PrintingPlugin.java │ │ └── res │ │ └── xml │ │ └── flutter_printing_file_paths.xml ├── example.png ├── example │ ├── .gitignore │ ├── lib │ │ └── main.dart │ └── pubspec.yaml ├── ios │ ├── Classes │ │ ├── CustomPrintPaper.swift │ │ ├── PrintJob.swift │ │ ├── PrintingPlugin.m │ │ └── PrintingPlugin.swift │ └── printing.podspec ├── lib │ ├── printing.dart │ ├── printing_web.dart │ └── src │ │ ├── asset_utils.dart │ │ ├── cache.dart │ │ ├── callback.dart │ │ ├── fonts │ │ ├── font.dart │ │ ├── gfonts.dart │ │ └── manifest.dart │ │ ├── interface.dart │ │ ├── method_channel.dart │ │ ├── method_channel_ffi.dart │ │ ├── method_channel_js.dart │ │ ├── mutex.dart │ │ ├── output_type.dart │ │ ├── pdfjs.dart │ │ ├── platform_js.dart │ │ ├── platform_os.dart │ │ ├── preview │ │ ├── action_bar_theme.dart │ │ ├── actions.dart │ │ ├── controller.dart │ │ ├── custom.dart │ │ ├── page.dart │ │ ├── pdf_preview.dart │ │ └── raster.dart │ │ ├── print_job.dart │ │ ├── printer.dart │ │ ├── printing.dart │ │ ├── printing_info.dart │ │ └── raster.dart ├── linux │ ├── CMakeLists.txt │ ├── include │ │ └── printing │ │ │ └── printing_plugin.h │ ├── print_job.cc │ ├── print_job.h │ └── printing_plugin.cc ├── macos │ ├── Classes │ │ ├── PrintJob.swift │ │ ├── PrintingPlugin.m │ │ └── PrintingPlugin.swift │ └── printing.podspec ├── pubspec.yaml ├── test │ ├── document_test.dart │ ├── info_test.dart │ ├── printing_test.dart │ └── raster_test.dart └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── DownloadProject.CMakeLists.cmake.in │ ├── DownloadProject.cmake │ ├── include │ └── printing │ │ └── printing_plugin.h │ ├── print_job.cpp │ ├── print_job.h │ ├── printing.cpp │ ├── printing.h │ └── printing_plugin.cpp ├── test ├── build_gfonts.dart ├── compare-pdf.sh ├── extract_readme.dart ├── github_social_preview.dart ├── golden │ ├── annotations.pdf │ ├── arabic.pdf │ ├── colors.pdf │ ├── complex.pdf │ ├── example.pdf │ ├── isolate.pdf │ ├── jpeg.pdf │ ├── metrics.pdf │ ├── minimal.pdf │ ├── orientation.pdf │ ├── roll-paper.pdf │ ├── rtl-layout.pdf │ ├── ttf.pdf │ ├── type1.pdf │ ├── widgets-barcode.pdf │ ├── widgets-basic.pdf │ ├── widgets-chart.pdf │ ├── widgets-clip.pdf │ ├── widgets-container.pdf │ ├── widgets-flex.pdf │ ├── widgets-form.pdf │ ├── widgets-gridview.pdf │ ├── widgets-icons.pdf │ ├── widgets-monopage-1.pdf │ ├── widgets-monopage.pdf │ ├── widgets-multipage-1.pdf │ ├── widgets-multipage.pdf │ ├── widgets-newpage.pdf │ ├── widgets-opacity.pdf │ ├── widgets-outline.pdf │ ├── widgets-partitions.pdf │ ├── widgets-svg.pdf │ ├── widgets-table.pdf │ ├── widgets-text.pdf │ ├── widgets-theme.pdf │ ├── widgets-toc.pdf │ ├── widgets-watermark.pdf │ ├── widgets-wrap.pdf │ └── widgets.pdf └── pubspec.yaml └── widget_wrapper ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── lib ├── pdf_widget_wrapper.dart └── src │ └── widget_wrapper.dart └── pubspec.yaml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | custom: 4 | - https://www.buymeacoffee.com/JORBmbw9h 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug, needs triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | 13 | **To Reproduce** 14 | Code snippet to reproduce the behavior: 15 | ```dart 16 | // your code 17 | ``` 18 | 19 | **Expected behavior** 20 | 21 | 22 | **Screenshots** 23 | 24 | 25 | **Flutter Doctor** 26 | 27 | 28 | ``` 29 | ``` 30 | 31 | **Desktop (please complete the following information):** 32 | - [ ] iOS 33 | - [ ] Android 34 | - [ ] Browser 35 | - [ ] Windows 36 | - [ ] Linux 37 | 38 | **Smartphone (please complete the following information):** 39 | - Device: [e.g. iPhone6] 40 | - OS: [e.g. iOS8.1] 41 | - Browser [e.g. stock browser, safari] 42 | - Version [e.g. 22] 43 | 44 | **Additional context** 45 | 46 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement, needs triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | 12 | 13 | **Describe the solution you'd like** 14 | 15 | 16 | **Describe alternatives you've considered** 17 | 18 | 19 | **Additional context** 20 | 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: I want help writing my application 3 | about: You have a question for how to achieve a particular effect, or you need help 4 | with using a particular API. 5 | title: '' 6 | labels: support, needs triage 7 | assignees: '' 8 | 9 | --- 10 | 11 | 25 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: "Close stale issues" 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/stale@v3 12 | with: 13 | repo-token: ${{ secrets.GITHUB_TOKEN }} 14 | stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days" 15 | close-issue-message: "Closing this stale issue because it has no activity." 16 | days-before-stale: 20 17 | days-before-close: 5 18 | exempt-issue-labels: "needs triage" 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | .pub/ 5 | build/ 6 | # If you're building an application, you may want to check-in your pubspec.lock 7 | pubspec.lock 8 | 9 | # Directory created by dartdoc 10 | # If you don't generate documentation locally you can remove this line. 11 | doc/api/ 12 | 13 | *.pdf 14 | *.ttf 15 | .DS_Store 16 | .dart_tool/ 17 | 18 | .packages 19 | .pub/ 20 | pubspec.lock 21 | 22 | build/ 23 | printing/android/local.properties 24 | .idea 25 | *.iml 26 | .flutter-plugins 27 | 28 | printing/*.log 29 | printing/ios/Flutter 30 | printing/ios/Runner 31 | printing/android/.gradle 32 | 33 | .pana 34 | pedantic_analyis_options_*.yaml 35 | .dartfix 36 | node_modules 37 | lcov.info 38 | coverage.json 39 | .coverage 40 | package-lock.json 41 | lcov.info 42 | 43 | test/readme*.dart 44 | test/android 45 | test/ios 46 | test/diff 47 | 48 | ref 49 | !test/golden/*.pdf 50 | .flutter-plugins-dependencies 51 | 52 | cache_* 53 | 54 | .vscode 55 | package.json 56 | 57 | GeneratedPluginRegistrant.* 58 | test/social_preview.png 59 | test/fonts.json 60 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Update the README.md with details of changes to the interface, this includes new environment 13 | variables, exposed ports, useful file locations and container parameters. 14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this 15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). 16 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you 17 | do not have permission to do that, you may request the second reviewer to merge it for you. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pdf for Dart and Flutter 2 | 3 | ![Dart CI](https://github.com/DavBfr/dart_pdf/workflows/Dart%20CI/badge.svg) [![pub package](https://img.shields.io/pub/v/pdf.svg)](https://pub.dartlang.org/packages/pdf) [![pub package](https://img.shields.io/pub/v/printing.svg)](https://pub.dartlang.org/packages/printing) [![codecov](https://codecov.io/gh/DavBfr/dart_pdf/branch/master/graph/badge.svg)](https://codecov.io/gh/DavBfr/dart_pdf) 4 | 5 | This set of plugins allows Flutter apps to generate and print pdf files to the device printer. This plugin works for iOS and Android. 6 | 7 | - dart pdf: 8 | - flutter printing: 9 | - Live Demo: 10 | 11 | [![Buy Me A Coffee](https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png "Buy Me A Coffee")](https://www.buymeacoffee.com/JORBmbw9h "Buy Me A Coffee") 12 | 13 | ## Contributing 14 | 15 | Follow the instructions here: [contributing](CONTRIBUTING.md). 16 | 17 | A Makefile is available on the project root directory to download and prepare the dependencies. 18 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /demo/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | analyzer: 4 | errors: 5 | missing_required_param: warning 6 | missing_return: warning 7 | public_member_api_docs: ignore 8 | todo: ignore 9 | constant_identifier_names: ignore 10 | avoid_print: ignore 11 | 12 | linter: 13 | rules: 14 | - always_put_control_body_on_new_line 15 | - avoid_bool_literals_in_conditional_expressions 16 | - avoid_classes_with_only_static_members 17 | - avoid_field_initializers_in_const_classes 18 | - avoid_slow_async_io 19 | - avoid_unused_constructor_parameters 20 | - avoid_void_async 21 | - cancel_subscriptions 22 | - directives_ordering 23 | - flutter_style_todos 24 | - no_adjacent_strings_in_list 25 | - omit_local_variable_types 26 | - prefer_asserts_in_initializer_lists 27 | - prefer_final_locals 28 | - prefer_foreach 29 | - prefer_if_elements_to_conditional_expressions 30 | - prefer_relative_imports 31 | - prefer_single_quotes 32 | - public_member_api_docs 33 | - sort_constructors_first 34 | - sort_pub_dependencies 35 | - sort_unnamed_constructors_first 36 | - test_types_in_equals 37 | - throw_in_finally 38 | - unnecessary_statements 39 | -------------------------------------------------------------------------------- /demo/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /demo/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | namespace 'net.nfet.printing_demo' 30 | compileSdkVersion flutter.compileSdkVersion 31 | ndkVersion flutter.ndkVersion 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | 38 | defaultConfig { 39 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 40 | applicationId "net.nfet.printing_demo" 41 | // You can update the following values to match your application needs. 42 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 43 | minSdkVersion flutter.minSdkVersion 44 | targetSdkVersion flutter.targetSdkVersion 45 | versionCode flutterVersionCode.toInteger() 46 | versionName flutterVersionName 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | -------------------------------------------------------------------------------- /demo/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /demo/android/app/src/main/java/net/nfet/printing_demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package net.nfet.printing_demo; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | -------------------------------------------------------------------------------- /demo/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /demo/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /demo/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /demo/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /demo/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /demo/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 6 | -------------------------------------------------------------------------------- /demo/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /demo/assets/document.svg: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /demo/assets/invoice.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demo/assets/medail.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /demo/assets/profile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/assets/profile.jpg -------------------------------------------------------------------------------- /demo/assets/resume.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /demo/assets/swirls.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | 36 | Podfile.lock 37 | -------------------------------------------------------------------------------- /demo/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /demo/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /demo/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /demo/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /demo/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demo/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /demo/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /demo/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter PDF Demo 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | Pdf Printing Demo 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIFileSharingEnabled 32 | 33 | LSSupportsOpeningDocumentsInPlace 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | UIViewControllerBasedStatusBarAppearance 49 | 50 | CADisableMinimumFrameDurationOnPhone 51 | 52 | UIApplicationSupportsIndirectInputEvents 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /demo/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /demo/lib/data.dart: -------------------------------------------------------------------------------- 1 | class CustomData { 2 | const CustomData({ 3 | this.name = '[your name]', 4 | this.testing = false, 5 | }); 6 | 7 | final String name; 8 | 9 | final bool testing; 10 | } 11 | -------------------------------------------------------------------------------- /demo/lib/examples.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:typed_data'; 3 | 4 | import 'package:pdf/pdf.dart'; 5 | 6 | import 'data.dart'; 7 | import 'examples/calendar.dart'; 8 | import 'examples/certificate.dart'; 9 | import 'examples/document.dart'; 10 | import 'examples/invoice.dart'; 11 | import 'examples/report.dart'; 12 | import 'examples/resume.dart'; 13 | 14 | const examples = [ 15 | Example('RÉSUMÉ', 'resume.dart', generateResume), 16 | Example('DOCUMENT', 'document.dart', generateDocument), 17 | Example('INVOICE', 'invoice.dart', generateInvoice), 18 | Example('REPORT', 'report.dart', generateReport), 19 | Example('CALENDAR', 'calendar.dart', generateCalendar), 20 | Example('CERTIFICATE', 'certificate.dart', generateCertificate, true), 21 | ]; 22 | 23 | typedef LayoutCallbackWithData = Future Function( 24 | PdfPageFormat pageFormat, CustomData data); 25 | 26 | class Example { 27 | const Example(this.name, this.file, this.builder, [this.needsData = false]); 28 | 29 | final String name; 30 | 31 | final String file; 32 | 33 | final LayoutCallbackWithData builder; 34 | 35 | final bool needsData; 36 | } 37 | -------------------------------------------------------------------------------- /demo/lib/main.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:flutter/material.dart'; 18 | 19 | import 'app.dart'; 20 | 21 | void main() { 22 | runApp(const App()); 23 | } 24 | 25 | class App extends StatelessWidget { 26 | const App({Key? key}) : super(key: key); 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | final scrollbarTheme = ScrollbarThemeData( 31 | thumbVisibility: WidgetStateProperty.all(true), 32 | ); 33 | 34 | return MaterialApp( 35 | theme: ThemeData.light().copyWith(scrollbarTheme: scrollbarTheme), 36 | darkTheme: ThemeData.dark().copyWith(scrollbarTheme: scrollbarTheme), 37 | title: 'Flutter PDF Demo', 38 | home: const MyApp(), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /demo/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /demo/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | void fl_register_plugins(FlPluginRegistry* registry) { 14 | g_autoptr(FlPluginRegistrar) open_file_linux_registrar = 15 | fl_plugin_registry_get_registrar_for_plugin(registry, "OpenFileLinuxPlugin"); 16 | open_file_linux_plugin_register_with_registrar(open_file_linux_registrar); 17 | g_autoptr(FlPluginRegistrar) printing_registrar = 18 | fl_plugin_registry_get_registrar_for_plugin(registry, "PrintingPlugin"); 19 | printing_plugin_register_with_registrar(printing_registrar); 20 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 21 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 22 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 23 | } 24 | -------------------------------------------------------------------------------- /demo/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /demo/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | open_file_linux 7 | printing 8 | url_launcher_linux 9 | ) 10 | 11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 12 | ) 13 | 14 | set(PLUGIN_BUNDLED_LIBRARIES) 15 | 16 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 21 | endforeach(plugin) 22 | 23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 26 | endforeach(ffi_plugin) 27 | -------------------------------------------------------------------------------- /demo/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /demo/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /demo/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | 9 | Flutter/GeneratedPluginRegistrant.swift 10 | 11 | Podfile.lock 12 | -------------------------------------------------------------------------------- /demo/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /demo/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /demo/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /demo/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demo/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /demo/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = Pdf Printing Demo 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = net.nfet.printingDemo 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 net.nfet. All rights reserved. 15 | -------------------------------------------------------------------------------- /demo/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /demo/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /demo/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /demo/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.client 10 | 11 | com.apple.security.network.server 12 | 13 | com.apple.security.print 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /demo/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSApplicationCategoryType 6 | public.app-category.utilities 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | $(FLUTTER_BUILD_NAME) 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | $(PRODUCT_COPYRIGHT) 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /demo/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /demo/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | com.apple.security.print 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: printing_demo 2 | description: Pdf Printing Demo 3 | publish_to: "none" 4 | version: 1.0.0+1 5 | 6 | environment: 7 | sdk: ">=2.12.0 <4.0.0" 8 | flutter: ">=1.16.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | intl: ^0.19.0 14 | open_file: ^3.2.1 15 | path_provider: ^2.0.12 16 | pdf: 17 | printing: 18 | url_launcher: ^6.1.8 19 | vector_math: ^2.1.4 20 | 21 | dev_dependencies: 22 | # flutter_launcher_icons: ^0.10.0 23 | flutter_lints: ^5.0.0 24 | flutter_test: 25 | sdk: flutter 26 | test: 27 | 28 | dependency_overrides: 29 | pdf: 30 | path: ../pdf 31 | printing: 32 | path: ../printing 33 | 34 | flutter: 35 | uses-material-design: true 36 | assets: 37 | - assets/ 38 | 39 | flutter_icons: 40 | image_path: "app-logo.png" 41 | remove_alpha_ios: true 42 | android: 43 | generate: true 44 | ios: 45 | generate: true 46 | web: 47 | generate: true 48 | windows: 49 | generate: true 50 | -------------------------------------------------------------------------------- /demo/test/printing_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:pdf/pdf.dart'; 5 | import 'package:printing_demo/data.dart'; 6 | import 'package:printing_demo/examples/document.dart'; 7 | 8 | void main() { 9 | testWidgets('Pdf Generate the document', (WidgetTester tester) async { 10 | const data = CustomData(testing: true); 11 | final doc = await generateDocument(PdfPageFormat.a4, data); 12 | 13 | final file = File('document.pdf'); 14 | file.writeAsBytesSync(doc); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /demo/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/web/favicon.png -------------------------------------------------------------------------------- /demo/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/web/icons/Icon-192.png -------------------------------------------------------------------------------- /demo/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/web/icons/Icon-512.png -------------------------------------------------------------------------------- /demo/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /demo/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /demo/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Flutter PDF Demo", 3 | "short_name": "Flutter PDF Demo", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Flutter PDF Demo", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /demo/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /demo/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | PrintingPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("PrintingPlugin")); 15 | UrlLauncherWindowsRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 17 | } 18 | -------------------------------------------------------------------------------- /demo/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /demo/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | printing 7 | url_launcher_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /demo/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 37 | 38 | # Run the Flutter tool portions of the build. This must not be removed. 39 | add_dependencies(${BINARY_NAME} flutter_assemble) 40 | -------------------------------------------------------------------------------- /demo/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /demo/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /demo/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"Flutter PDF Demo", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /demo/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /demo/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/demo/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /demo/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /demo/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /demo/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /pdf/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | analyzer: 4 | errors: 5 | missing_required_param: warning 6 | missing_return: warning 7 | public_member_api_docs: ignore 8 | todo: ignore 9 | avoid_print: ignore 10 | no_leading_underscores_for_local_identifiers: ignore 11 | use_super_parameters: ignore 12 | 13 | linter: 14 | rules: 15 | - always_put_control_body_on_new_line 16 | - avoid_bool_literals_in_conditional_expressions 17 | - avoid_classes_with_only_static_members 18 | - avoid_field_initializers_in_const_classes 19 | - avoid_slow_async_io 20 | - avoid_unused_constructor_parameters 21 | - avoid_void_async 22 | - cancel_subscriptions 23 | - directives_ordering 24 | - flutter_style_todos 25 | - no_adjacent_strings_in_list 26 | - omit_local_variable_types 27 | - prefer_asserts_in_initializer_lists 28 | - prefer_final_locals 29 | - prefer_foreach 30 | - prefer_if_elements_to_conditional_expressions 31 | - prefer_relative_imports 32 | - prefer_single_quotes 33 | - public_member_api_docs 34 | - sort_constructors_first 35 | - sort_pub_dependencies 36 | - sort_unnamed_constructors_first 37 | - test_types_in_equals 38 | - throw_in_finally 39 | - unnecessary_statements 40 | -------------------------------------------------------------------------------- /pdf/example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/pdf/example.jpg -------------------------------------------------------------------------------- /pdf/example/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:pdf/widgets.dart' as pw; 4 | 5 | Future main() async { 6 | final pdf = pw.Document(); 7 | 8 | pdf.addPage( 9 | pw.Page( 10 | build: (pw.Context context) => pw.Center( 11 | child: pw.Text('Hello World!'), 12 | ), 13 | ), 14 | ); 15 | 16 | final file = File('example.pdf'); 17 | await file.writeAsBytes(await pdf.save()); 18 | } 19 | -------------------------------------------------------------------------------- /pdf/lib/pdf.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export 'src/pdf/color.dart'; 18 | export 'src/pdf/colors.dart'; 19 | export 'src/pdf/document.dart'; 20 | export 'src/pdf/document_parser.dart'; 21 | export 'src/pdf/exif.dart'; 22 | export 'src/pdf/font/font_metrics.dart'; 23 | export 'src/pdf/font/ttf_parser.dart'; 24 | export 'src/pdf/format/name.dart'; 25 | export 'src/pdf/format/object_base.dart' show DeflateCallback, PdfVersion; 26 | export 'src/pdf/graphic_state.dart'; 27 | export 'src/pdf/graphics.dart'; 28 | export 'src/pdf/obj/annotation.dart'; 29 | export 'src/pdf/obj/border.dart'; 30 | export 'src/pdf/obj/encryption.dart'; 31 | export 'src/pdf/obj/font.dart'; 32 | export 'src/pdf/obj/function.dart'; 33 | export 'src/pdf/obj/image.dart'; 34 | export 'src/pdf/obj/info.dart'; 35 | export 'src/pdf/obj/metadata.dart'; 36 | export 'src/pdf/obj/outline.dart'; 37 | export 'src/pdf/obj/page.dart'; 38 | export 'src/pdf/obj/page_label.dart'; 39 | export 'src/pdf/obj/pattern.dart'; 40 | export 'src/pdf/obj/pdfa/pdfa_attached_files.dart'; 41 | export 'src/pdf/obj/pdfa/pdfa_color_profile.dart'; 42 | export 'src/pdf/obj/pdfa/pdfa_facturx_rdf.dart'; 43 | export 'src/pdf/obj/pdfa/pdfa_rdf.dart'; 44 | export 'src/pdf/obj/shading.dart'; 45 | export 'src/pdf/obj/signature.dart'; 46 | export 'src/pdf/obj/smask.dart'; 47 | export 'src/pdf/obj/ttffont.dart'; 48 | export 'src/pdf/page_format.dart'; 49 | export 'src/pdf/point.dart'; 50 | export 'src/pdf/raster.dart'; 51 | export 'src/pdf/rect.dart'; 52 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/document_parser.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:typed_data'; 18 | 19 | import 'document.dart'; 20 | import 'format/object_base.dart'; 21 | 22 | /// Base class for loading an existing PDF document. 23 | abstract class PdfDocumentParserBase { 24 | /// Create a Document loader instance 25 | PdfDocumentParserBase(this.bytes); 26 | 27 | /// The existing PDF document content 28 | final Uint8List bytes; 29 | 30 | /// The objects size of the existing PDF document 31 | int get size; 32 | 33 | /// The offset of the previous cross reference table 34 | int get xrefOffset; 35 | 36 | PdfVersion get version => PdfVersion.pdf_1_4; 37 | 38 | /// Import the existing objects into the new PDF document 39 | void mergeDocument(PdfDocument pdfDocument); 40 | } 41 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/format/base.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:typed_data'; 18 | 19 | import 'package:meta/meta.dart'; 20 | 21 | import 'object_base.dart'; 22 | import 'stream.dart'; 23 | 24 | const kIndentSize = 2; 25 | 26 | abstract class PdfDataType { 27 | const PdfDataType(); 28 | 29 | void output(PdfObjectBase o, PdfStream s, [int? indent]); 30 | 31 | PdfStream _toStream([int? indent]) { 32 | final s = PdfStream(); 33 | output( 34 | PdfObjectBase( 35 | objser: 0, 36 | params: this, 37 | settings: const PdfSettings(), 38 | ), 39 | s, 40 | indent, 41 | ); 42 | return s; 43 | } 44 | 45 | @override 46 | String toString([int? indent]) { 47 | return String.fromCharCodes(_toStream(indent).output()); 48 | } 49 | 50 | @visibleForTesting 51 | Uint8List toList() { 52 | return _toStream().output(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/format/bool.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'base.dart'; 18 | import 'object_base.dart'; 19 | import 'stream.dart'; 20 | 21 | class PdfBool extends PdfDataType { 22 | const PdfBool(this.value); 23 | 24 | final bool value; 25 | 26 | @override 27 | void output(PdfObjectBase o, PdfStream s, [int? indent]) { 28 | s.putString(value ? 'true' : 'false'); 29 | } 30 | 31 | @override 32 | bool operator ==(Object other) { 33 | if (other is PdfBool) { 34 | return value == other.value; 35 | } 36 | 37 | return false; 38 | } 39 | 40 | @override 41 | int get hashCode => value.hashCode; 42 | } 43 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/format/diagnostic.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:meta/meta.dart'; 4 | 5 | import 'stream.dart'; 6 | 7 | mixin PdfDiagnostic { 8 | static const _maxSize = 300; 9 | 10 | final _properties = []; 11 | 12 | int? _offset; 13 | 14 | Stopwatch? _stopwatch; 15 | 16 | int get elapsedStopwatch => _stopwatch?.elapsedMicroseconds ?? 0; 17 | 18 | int size = 0; 19 | 20 | @protected 21 | @mustCallSuper 22 | void debugFill(String value) { 23 | assert(() { 24 | if (_properties.isEmpty) { 25 | _properties.add(''); 26 | _properties.add('-' * 78); 27 | _properties.add('$runtimeType'); 28 | } 29 | _properties.add(value); 30 | return true; 31 | }()); 32 | } 33 | 34 | void setInsertion(PdfStream os, [int size = _maxSize]) { 35 | assert(() { 36 | this.size = size; 37 | _offset = os.offset; 38 | os.putComment(' ' * size); 39 | return true; 40 | }()); 41 | } 42 | 43 | void writeDebug(PdfStream os) { 44 | assert(() { 45 | if (_offset != null) { 46 | final o = PdfStream(); 47 | _properties.forEach(o.putComment); 48 | final b = o.output(); 49 | os.setBytes( 50 | _offset!, 51 | b.sublist(0, math.min(size + 2, b.lengthInBytes - 1)), 52 | ); 53 | } 54 | return true; 55 | }()); 56 | } 57 | 58 | void startStopwatch() { 59 | _stopwatch ??= Stopwatch(); 60 | _stopwatch!.start(); 61 | } 62 | 63 | void stopStopwatch() { 64 | _stopwatch?.stop(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/format/indirect.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'base.dart'; 18 | import 'object_base.dart'; 19 | import 'stream.dart'; 20 | 21 | class PdfIndirect extends PdfDataType { 22 | const PdfIndirect(this.ser, this.gen); 23 | 24 | final int ser; 25 | 26 | final int gen; 27 | 28 | @override 29 | void output(PdfObjectBase o, PdfStream s, [int? indent]) { 30 | s.putString('$ser $gen R'); 31 | } 32 | 33 | @override 34 | bool operator ==(Object other) { 35 | if (other is PdfIndirect) { 36 | return ser == other.ser && gen == other.gen; 37 | } 38 | 39 | return false; 40 | } 41 | 42 | @override 43 | int get hashCode => ser.hashCode + gen.hashCode; 44 | } 45 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/format/name.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'base.dart'; 18 | import 'object_base.dart'; 19 | import 'stream.dart'; 20 | 21 | class PdfName extends PdfDataType { 22 | const PdfName(this.value); 23 | 24 | final String value; 25 | 26 | @override 27 | void output(PdfObjectBase o, PdfStream s, [int? indent]) { 28 | assert(value[0] == '/'); 29 | final bytes = []; 30 | for (final c in value.codeUnits) { 31 | assert(c < 0xff && c > 0x00); 32 | 33 | if (c < 0x21 || 34 | c > 0x7E || 35 | c == 0x23 || 36 | (c == 0x2f && bytes.isNotEmpty) || 37 | c == 0x5b || 38 | c == 0x5d || 39 | c == 0x28 || 40 | c == 0x3c || 41 | c == 0x3e) { 42 | bytes.add(0x23); 43 | final x = c.toRadixString(16).padLeft(2, '0'); 44 | bytes.addAll(x.codeUnits); 45 | } else { 46 | bytes.add(c); 47 | } 48 | } 49 | s.putBytes(bytes); 50 | } 51 | 52 | @override 53 | bool operator ==(Object other) { 54 | if (other is PdfName) { 55 | return value == other.value; 56 | } 57 | 58 | return false; 59 | } 60 | 61 | @override 62 | int get hashCode => value.hashCode; 63 | } 64 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/format/null_value.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'base.dart'; 18 | import 'object_base.dart'; 19 | import 'stream.dart'; 20 | 21 | class PdfNull extends PdfDataType { 22 | const PdfNull(); 23 | 24 | @override 25 | void output(PdfObjectBase o, PdfStream s, [int? indent]) { 26 | s.putString('null'); 27 | } 28 | 29 | @override 30 | bool operator ==(Object other) { 31 | return other is PdfNull; 32 | } 33 | 34 | @override 35 | int get hashCode => null.hashCode; 36 | } 37 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/format/stream.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:typed_data'; 18 | 19 | class PdfStream { 20 | static const int _grow = 65536; 21 | 22 | Uint8List _stream = Uint8List(_grow); 23 | 24 | int _offset = 0; 25 | 26 | void _ensureCapacity(int size) { 27 | if (_stream.length - _offset >= size) { 28 | return; 29 | } 30 | 31 | final newSize = _offset + size + _grow; 32 | final newBuffer = Uint8List(newSize); 33 | newBuffer.setAll(0, _stream); 34 | _stream = newBuffer; 35 | } 36 | 37 | void putByte(int s) { 38 | _ensureCapacity(1); 39 | _stream[_offset++] = s; 40 | } 41 | 42 | void putBytes(List s) { 43 | _ensureCapacity(s.length); 44 | _stream.setAll(_offset, s); 45 | _offset += s.length; 46 | } 47 | 48 | void setBytes(int offset, Iterable iterable) { 49 | _stream.setAll(offset, iterable); 50 | } 51 | 52 | void putStream(PdfStream s) { 53 | putBytes(s._stream); 54 | } 55 | 56 | int get offset => _offset; 57 | 58 | Uint8List output() => _stream.sublist(0, _offset); 59 | 60 | void putString(String? s) { 61 | assert(() { 62 | for (final codeUnit in s!.codeUnits) { 63 | if (codeUnit > 0x7f) { 64 | return false; 65 | } 66 | } 67 | return true; 68 | }()); 69 | putBytes(s!.codeUnits); 70 | } 71 | 72 | void putComment(String s) { 73 | if (s.isEmpty) { 74 | putByte(0x0a); 75 | } else { 76 | for (final l in s.split('\n')) { 77 | if (l.isNotEmpty) { 78 | putBytes('% $l\n'.codeUnits); 79 | } 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/io/js.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:archive/archive.dart'; 18 | 19 | import '../format/object_base.dart'; 20 | 21 | /// Zip compression function 22 | DeflateCallback defaultDeflate = const ZLibEncoder().encode; 23 | 24 | /// The dart:html implementation of [pdfCompute]. 25 | @pragma('dart2js:tryInline') 26 | Future pdfCompute(Future Function() computation) async { 27 | await null; 28 | return computation(); 29 | } 30 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/io/na.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../format/object_base.dart'; 18 | 19 | /// Zip compression function 20 | DeflateCallback defaultDeflate = (List a) => a; 21 | 22 | /// Computation function 23 | Future pdfCompute(Future Function() computation) async { 24 | await null; 25 | return computation(); 26 | } 27 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/io/vm.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | import 'dart:isolate'; 19 | 20 | import '../format/object_base.dart'; 21 | 22 | /// Zip compression function 23 | DeflateCallback defaultDeflate = zlib.encode; 24 | 25 | /// The dart:io implementation of [pdfCompute]. 26 | @pragma('vm:prefer-inline') 27 | Future pdfCompute(Future Function() computation) async { 28 | if (Platform.environment.containsKey('FLUTTER_TEST')) { 29 | return computation(); 30 | } 31 | return Isolate.run(computation, debugName: 'dart_pdf'); 32 | } 33 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/array.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../document.dart'; 18 | import '../format/array.dart'; 19 | import 'object.dart'; 20 | 21 | /// An array object 22 | @Deprecated('Use PdfObject instead') 23 | class PdfArrayObject extends PdfObject { 24 | /// Creates an array object 25 | PdfArrayObject( 26 | PdfDocument pdfDocument, 27 | PdfArray array, 28 | ) : super(pdfDocument, params: array); 29 | 30 | /// The array 31 | PdfArray get array => params; 32 | } 33 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/encryption.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:typed_data'; 18 | 19 | import '../document.dart'; 20 | import '../format/dict.dart'; 21 | import '../format/object_base.dart'; 22 | import 'object.dart'; 23 | 24 | /// Encryption object 25 | abstract class PdfEncryption extends PdfObject { 26 | /// Creates an encryption object 27 | PdfEncryption(PdfDocument pdfDocument) 28 | : super(pdfDocument, params: PdfDict()); 29 | 30 | /// Encrypt some data 31 | Uint8List encrypt(Uint8List input, PdfObjectBase object); 32 | } 33 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/font_descriptor.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../format/array.dart'; 18 | import '../format/dict.dart'; 19 | import '../format/name.dart'; 20 | import '../format/num.dart'; 21 | import 'object.dart'; 22 | import 'object_stream.dart'; 23 | import 'ttffont.dart'; 24 | 25 | /// Font descriptor object 26 | class PdfFontDescriptor extends PdfObject { 27 | /// Create a Font descriptor object 28 | PdfFontDescriptor( 29 | this.ttfFont, 30 | this.file, 31 | ) : super( 32 | ttfFont.pdfDocument, 33 | params: PdfDict.values({ 34 | '/Type': const PdfName('/FontDescriptor'), 35 | }), 36 | ); 37 | 38 | /// File data 39 | final PdfObjectStream file; 40 | 41 | /// TrueType font 42 | final PdfTtfFont ttfFont; 43 | 44 | @override 45 | void prepare() { 46 | super.prepare(); 47 | 48 | params['/FontName'] = PdfName('/${ttfFont.fontName}'); 49 | params['/FontFile2'] = file.ref(); 50 | params['/Flags'] = PdfNum(ttfFont.font.unicode ? 4 : 32); 51 | params['/FontBBox'] = PdfArray.fromNum([ 52 | (ttfFont.font.xMin / ttfFont.font.unitsPerEm * 1000).toInt(), 53 | (ttfFont.font.yMin / ttfFont.font.unitsPerEm * 1000).toInt(), 54 | (ttfFont.font.xMax / ttfFont.font.unitsPerEm * 1000).toInt(), 55 | (ttfFont.font.yMax / ttfFont.font.unitsPerEm * 1000).toInt() 56 | ]); 57 | params['/Ascent'] = PdfNum((ttfFont.ascent * 1000).toInt()); 58 | params['/Descent'] = PdfNum((ttfFont.descent * 1000).toInt()); 59 | params['/ItalicAngle'] = const PdfNum(0); 60 | params['/CapHeight'] = const PdfNum(10); 61 | params['/StemV'] = const PdfNum(79); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/formxobject.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:vector_math/vector_math_64.dart'; 18 | 19 | import '../document.dart'; 20 | import '../format/array.dart'; 21 | import '../format/dict.dart'; 22 | import '../format/num.dart'; 23 | import 'font.dart'; 24 | import 'xobject.dart'; 25 | 26 | /// Form XObject 27 | class PdfFormXObject extends PdfXObject { 28 | /// Create a Form XObject 29 | PdfFormXObject(PdfDocument pdfDocument) : super(pdfDocument, '/Form') { 30 | params['/FormType'] = const PdfNum(1); 31 | params['/BBox'] = PdfArray.fromNum(const [0, 0, 1000, 1000]); 32 | } 33 | 34 | /// The fonts associated with this page 35 | final Map fonts = {}; 36 | 37 | /// The xobjects or other images in the pdf 38 | final Map xobjects = {}; 39 | 40 | /// Transformation matrix 41 | void setMatrix(Matrix4 t) { 42 | final s = t.storage; 43 | params['/Matrix'] = 44 | PdfArray.fromNum([s[0], s[1], s[4], s[5], s[12], s[13]]); 45 | } 46 | 47 | @override 48 | void prepare() { 49 | super.prepare(); 50 | 51 | // This holds any resources for this FormXObject 52 | final resources = PdfDict(); 53 | 54 | // fonts 55 | if (fonts.isNotEmpty) { 56 | resources['/Font'] = PdfDict.fromObjectMap(fonts); 57 | } 58 | 59 | // Now the XObjects 60 | if (xobjects.isNotEmpty) { 61 | resources['/XObject'] = PdfDict.fromObjectMap(xobjects); 62 | } 63 | 64 | if (resources.isNotEmpty) { 65 | params['/Resources'] = resources; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/metadata.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:convert'; 18 | import 'dart:typed_data'; 19 | 20 | import 'package:xml/xml.dart'; 21 | 22 | import '../document.dart'; 23 | import '../format/dict_stream.dart'; 24 | import '../format/name.dart'; 25 | import 'object.dart'; 26 | 27 | /// Pdf Metadata 28 | class PdfMetadata extends PdfObject { 29 | /// Store an Xml object 30 | PdfMetadata( 31 | PdfDocument pdfDocument, 32 | this.metadata, 33 | ) : super( 34 | pdfDocument, 35 | params: PdfDictStream( 36 | compress: false, 37 | encrypt: false, 38 | ), 39 | ) { 40 | pdfDocument.catalog.metadata = this; 41 | } 42 | 43 | final XmlDocument metadata; 44 | 45 | @override 46 | void prepare() { 47 | super.prepare(); 48 | params['/Type'] = const PdfName('/Metadata'); 49 | params['/Subtype'] = const PdfName('/XML'); 50 | params.data = Uint8List.fromList(utf8.encode(metadata.toString())); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/object.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:meta/meta.dart'; 18 | 19 | import '../document.dart'; 20 | import '../format/base.dart'; 21 | import '../format/object_base.dart'; 22 | 23 | /// Base Object used in the PDF file 24 | class PdfObject extends PdfObjectBase { 25 | /// Create a base Object used in the PDF file 26 | PdfObject( 27 | this.pdfDocument, { 28 | required T params, 29 | int objgen = 0, 30 | int? objser, 31 | }) : super( 32 | objser: objser ?? pdfDocument.genSerial(), 33 | objgen: objgen, 34 | params: params, 35 | settings: pdfDocument.settings, 36 | ) { 37 | pdfDocument.objects.add(this); 38 | } 39 | 40 | /// This allows any Pdf object to refer to the document being constructed. 41 | final PdfDocument pdfDocument; 42 | 43 | var inUse = true; 44 | 45 | /// Prepare the object to be written to the stream 46 | @mustCallSuper 47 | void prepare() {} 48 | 49 | @override 50 | String toString() => '$runtimeType $params'; 51 | } 52 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/object_dict.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../document.dart'; 18 | import '../format/dict.dart'; 19 | import '../format/name.dart'; 20 | import '../format/stream.dart'; 21 | import 'object.dart'; 22 | 23 | /// Object with a PdfDict used in the PDF file 24 | @Deprecated('Use PdfObject instead') 25 | class PdfObjectDict extends PdfObject { 26 | /// This is usually called by extensors to this class, and sets the 27 | /// Pdf Object Type 28 | PdfObjectDict( 29 | PdfDocument pdfDocument, { 30 | String? type, 31 | int objgen = 0, 32 | int? objser, 33 | }) : super(pdfDocument, params: PdfDict(), objgen: objgen, objser: objser) { 34 | if (type != null) { 35 | params['/Type'] = PdfName(type); 36 | } 37 | } 38 | 39 | @override 40 | void writeContent(PdfStream s) { 41 | if (params.isNotEmpty) { 42 | params.output(this, s, settings.verbose ? 0 : null); 43 | s.putByte(0x0a); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/object_stream.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../document.dart'; 18 | import '../format/dict.dart'; 19 | import '../format/dict_stream.dart'; 20 | import '../format/name.dart'; 21 | import '../format/stream.dart'; 22 | import 'object.dart'; 23 | 24 | /// Stream Object 25 | class PdfObjectStream extends PdfObject { 26 | /// Constructs a stream object to store some data 27 | PdfObjectStream( 28 | PdfDocument pdfDocument, { 29 | String? type, 30 | this.isBinary = false, 31 | }) : super( 32 | pdfDocument, 33 | params: PdfDict.values({ 34 | if (type != null) '/Type': PdfName(type), 35 | }), 36 | ); 37 | 38 | /// This holds the stream's content. 39 | final PdfStream buf = PdfStream(); 40 | 41 | /// defines if the stream needs to be converted to ascii85 42 | final bool isBinary; 43 | 44 | @override 45 | void writeContent(PdfStream s) { 46 | PdfDictStream( 47 | isBinary: isBinary, 48 | values: params.values, 49 | data: buf.output(), 50 | ).output(this, s, settings.verbose ? 0 : null); 51 | s.putByte(0x0a); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/page_list.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../document.dart'; 18 | import '../format/array.dart'; 19 | import '../format/dict.dart'; 20 | import '../format/name.dart'; 21 | import '../format/num.dart'; 22 | import 'object.dart'; 23 | import 'page.dart'; 24 | 25 | /// PdfPageList object 26 | class PdfPageList extends PdfObject { 27 | /// This constructs a [PdfPageList] object. 28 | PdfPageList( 29 | PdfDocument pdfDocument, { 30 | int objgen = 0, 31 | int? objser, 32 | }) : super( 33 | pdfDocument, 34 | params: PdfDict.values({ 35 | '/Type': const PdfName('/Pages'), 36 | }), 37 | objgen: objgen, 38 | objser: objser, 39 | ); 40 | 41 | /// This holds the pages 42 | final pages = []; 43 | 44 | @override 45 | void prepare() { 46 | super.prepare(); 47 | 48 | params['/Kids'] = PdfArray.fromObjects(pages); 49 | params['/Count'] = PdfNum(pages.length); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/pattern.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:vector_math/vector_math_64.dart'; 18 | 19 | import '../document.dart'; 20 | import '../format/array.dart'; 21 | import '../format/dict.dart'; 22 | import '../format/num.dart'; 23 | import '../graphic_state.dart'; 24 | import 'object.dart'; 25 | import 'shading.dart'; 26 | 27 | abstract class PdfPattern extends PdfObject { 28 | PdfPattern(PdfDocument pdfDocument, this.patternType, this.matrix) 29 | : super(pdfDocument, params: PdfDict()); 30 | 31 | /// Name of the Pattern object 32 | String get name => '/P$objser'; 33 | 34 | final int patternType; 35 | 36 | final Matrix4? matrix; 37 | 38 | @override 39 | void prepare() { 40 | super.prepare(); 41 | 42 | params['/PatternType'] = PdfNum(patternType); 43 | 44 | if (matrix != null) { 45 | final s = matrix!.storage; 46 | params['/Matrix'] = 47 | PdfArray.fromNum([s[0], s[1], s[4], s[5], s[12], s[13]]); 48 | } 49 | } 50 | } 51 | 52 | class PdfShadingPattern extends PdfPattern { 53 | PdfShadingPattern( 54 | PdfDocument pdfDocument, { 55 | required this.shading, 56 | Matrix4? matrix, 57 | this.graphicState, 58 | }) : super(pdfDocument, 2, matrix); 59 | 60 | final PdfShading shading; 61 | 62 | final PdfGraphicState? graphicState; 63 | 64 | @override 65 | void prepare() { 66 | super.prepare(); 67 | 68 | params['/Shading'] = shading.ref(); 69 | 70 | if (graphicState != null) { 71 | params['/ExtGState'] = graphicState!.output(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/pdfa/README.md: -------------------------------------------------------------------------------- 1 | Here are some classes to help you creating PDF/A compliant PDFs 2 | plus embedding Facturx invoices. 3 | 4 | ### Rules 5 | 6 | 1. Your PDF must only use embedded Fonts, 7 | 2. For now you cannot use any Annotations in your PDF 8 | 3. You must include a special Meta-XML, use below "PdfaRdf" and put the reuslting XML document into your documents metadata 9 | 4. You must include a Colorprofile, use the below "PdfaColorProfile" and embed the contents of "sRGB2014.icc" 10 | 5. Optionally attach an InvoiceXML using "PdfaFacturxRdf" and "PdfaAttachedFiles" 11 | 12 | ### Example 13 | 14 | ``` 15 | pw.Document pdf = pw.Document( 16 | ... 17 | metadata: PdfaRdf( 18 | ... 19 | invoiceRdf: PdfaFacturxRdf().create() 20 | ).create(), 21 | ); 22 | 23 | PdfaColorProfile( 24 | pdf.document, 25 | File('sRGB2014.icc').readAsBytesSync(), 26 | ); 27 | 28 | PdfaAttachedFiles( 29 | pdf.document, 30 | { 31 | 'factur-x.xml': myInvoiceXmlDocument, 32 | }, 33 | ); 34 | ``` 35 | 36 | ### Validating 37 | 38 | https://demo.verapdf.org 39 | https://avepdf.com/pdfa-validation 40 | https://www.mustangproject.org 41 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/pdfa/pdfa_color_profile.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import '../../document.dart'; 4 | import '../../format/array.dart'; 5 | import '../../format/dict.dart'; 6 | import '../../format/dict_stream.dart'; 7 | import '../../format/name.dart'; 8 | import '../../format/num.dart'; 9 | import '../../format/string.dart'; 10 | import '../object.dart'; 11 | 12 | class PdfaColorProfile extends PdfObject { 13 | PdfaColorProfile( 14 | PdfDocument pdfDocument, 15 | this.icc, 16 | ) : super( 17 | pdfDocument, 18 | params: PdfDictStream( 19 | compress: false, 20 | encrypt: false, 21 | ), 22 | ) { 23 | pdfDocument.catalog.colorProfile = this; 24 | } 25 | 26 | final Uint8List icc; 27 | 28 | @override 29 | void prepare() { 30 | super.prepare(); 31 | params['/N'] = const PdfNum(3); 32 | params.data = icc; 33 | } 34 | 35 | PdfArray outputIntents() { 36 | return PdfArray([ 37 | PdfDict({ 38 | '/Type': const PdfName('/OutputIntent'), 39 | '/S': const PdfName('/GTS_PDFA1'), 40 | '/OutputConditionIdentifier': 41 | PdfString(Uint8List.fromList('sRGB2014.icc'.codeUnits)), 42 | '/Info': PdfString(Uint8List.fromList('sRGB2014.icc'.codeUnits)), 43 | '/RegistryName': 44 | PdfString(Uint8List.fromList('http://www.color.org'.codeUnits)), 45 | '/DestOutputProfile': ref(), 46 | }), 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/pdfa/pdfa_date_format.dart: -------------------------------------------------------------------------------- 1 | class PdfaDateFormat { 2 | String format({ 3 | required DateTime dt, 4 | bool asIso = false, 5 | }) { 6 | final year = dt.year.toString().padLeft(4, '0'); 7 | final month = dt.month.toString().padLeft(2, '0'); 8 | final day = dt.day.toString().padLeft(2, '0'); 9 | final hour = dt.hour.toString().padLeft(2, '0'); 10 | final minute = dt.minute.toString().padLeft(2, '0'); 11 | final second = dt.second.toString().padLeft(2, '0'); 12 | 13 | if (asIso) { 14 | // "yyyy-MM-dd'T'HH:mm:ss" 15 | return '$year-$month-${day}T$hour:$minute:$second'; 16 | } 17 | // "yyyyMMddHHmmss" 18 | return '$year$month$day$hour$minute$second'; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/pdfa/sRGB2014.icc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/pdf/lib/src/pdf/obj/pdfa/sRGB2014.icc -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/smask.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../document.dart'; 18 | import '../format/array.dart'; 19 | import '../format/bool.dart'; 20 | import '../format/dict.dart'; 21 | import '../format/name.dart'; 22 | import '../graphics.dart'; 23 | import '../rect.dart'; 24 | import 'function.dart'; 25 | import 'graphic_stream.dart'; 26 | 27 | class PdfSoftMask { 28 | PdfSoftMask(this.document, 29 | {required PdfRect boundingBox, 30 | bool isolated = false, 31 | bool knockout = false, 32 | bool invert = false}) { 33 | _mask = PdfGraphicXObject(document, '/Form'); 34 | _mask.params['/BBox'] = PdfArray.fromNum([ 35 | boundingBox.x, 36 | boundingBox.y, 37 | boundingBox.width, 38 | boundingBox.height, 39 | ]); 40 | if (isolated) { 41 | _mask.params['/I'] = const PdfBool(true); 42 | } 43 | if (knockout) { 44 | _mask.params['/K'] = const PdfBool(true); 45 | } 46 | _graphics = PdfGraphics(_mask, _mask.buf); 47 | 48 | if (invert) { 49 | _tr = PdfFunction( 50 | document, 51 | data: [255, 0], 52 | ); 53 | } 54 | } 55 | 56 | final PdfDocument document; 57 | 58 | late PdfGraphicXObject _mask; 59 | 60 | PdfGraphics? _graphics; 61 | 62 | PdfGraphics? getGraphics() => _graphics; 63 | 64 | PdfBaseFunction? _tr; 65 | 66 | @override 67 | String toString() => '$runtimeType'; 68 | 69 | PdfDict output() { 70 | final params = PdfDict.values({ 71 | '/S': const PdfName('/Luminosity'), 72 | '/G': _mask.ref(), 73 | }); 74 | 75 | if (_tr != null) { 76 | params['/TR'] = _tr!.ref(); 77 | } 78 | 79 | return params; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/unicode_cmap.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../document.dart'; 18 | import 'object_stream.dart'; 19 | 20 | /// Unicode character map object 21 | class PdfUnicodeCmap extends PdfObjectStream { 22 | /// Create a Unicode character map object 23 | PdfUnicodeCmap(PdfDocument pdfDocument, this.protect) : super(pdfDocument); 24 | 25 | /// List of characters 26 | final cmap = [0]; 27 | 28 | /// Protects the text from being "seen" by the PDF reader. 29 | final bool protect; 30 | 31 | @override 32 | void prepare() { 33 | if (protect) { 34 | cmap.fillRange(1, cmap.length, 0x20); 35 | } 36 | 37 | buf.putString('/CIDInit/ProcSet\nfindresource begin\n' 38 | '12 dict begin\n' 39 | 'begincmap\n' 40 | '/CIDSystemInfo<<\n' 41 | '/Registry (Adobe)\n' 42 | '/Ordering (UCS)\n' 43 | '/Supplement 0\n' 44 | '>> def\n' 45 | '/CMapName/Adobe-Identity-UCS def\n' 46 | '/CMapType 2 def\n' 47 | '1 begincodespacerange\n' 48 | '<0000> \n' 49 | 'endcodespacerange\n' 50 | '${cmap.length} beginbfchar\n'); 51 | 52 | for (var key = 0; key < cmap.length; key++) { 53 | final value = cmap[key]; 54 | buf.putString( 55 | '<${key.toRadixString(16).toUpperCase().padLeft(4, '0')}> <${value.toRadixString(16).toUpperCase().padLeft(4, '0')}>\n'); 56 | } 57 | 58 | buf.putString('endbfchar\n' 59 | 'endcmap\n' 60 | 'CMapName currentdict /CMap defineresource pop\n' 61 | 'end\n' 62 | 'end'); 63 | super.prepare(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/obj/xobject.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import '../document.dart'; 18 | import '../format/name.dart'; 19 | import 'object_stream.dart'; 20 | 21 | class PdfXObject extends PdfObjectStream { 22 | PdfXObject(PdfDocument pdfDocument, String? subtype, {bool isBinary = false}) 23 | : super(pdfDocument, type: '/XObject', isBinary: isBinary) { 24 | if (subtype != null) { 25 | params['/Subtype'] = PdfName(subtype); 26 | } 27 | } 28 | 29 | String get name => 'X$objser'; 30 | } 31 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/options.dart: -------------------------------------------------------------------------------- 1 | /// Whether to use the Bidi algorithm to detect RTL text. 2 | const bool useBidi = bool.fromEnvironment('use_bidi', defaultValue: true); 3 | 4 | /// Whether to use the Arabic algorithm. 5 | const bool useArabic = 6 | bool.fromEnvironment('use_arabic', defaultValue: !useBidi); 7 | -------------------------------------------------------------------------------- /pdf/lib/src/pdf/point.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:meta/meta.dart'; 18 | 19 | @immutable 20 | class PdfPoint { 21 | const PdfPoint(this.x, this.y); 22 | 23 | final double x, y; 24 | 25 | static const PdfPoint zero = PdfPoint(0.0, 0.0); 26 | 27 | @override 28 | String toString() => 'PdfPoint($x, $y)'; 29 | 30 | PdfPoint translate(double offsetX, double offsetY) => 31 | PdfPoint(x + offsetX, y + offsetY); 32 | } 33 | -------------------------------------------------------------------------------- /pdf/lib/src/priv.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export 'pdf/format/array.dart'; 18 | export 'pdf/format/ascii85.dart'; 19 | export 'pdf/format/base.dart'; 20 | export 'pdf/format/bool.dart'; 21 | export 'pdf/format/diagnostic.dart'; 22 | export 'pdf/format/dict.dart'; 23 | export 'pdf/format/dict_stream.dart'; 24 | export 'pdf/format/indirect.dart'; 25 | export 'pdf/format/name.dart'; 26 | export 'pdf/format/null_value.dart'; 27 | export 'pdf/format/num.dart'; 28 | export 'pdf/format/object_base.dart' hide DeflateCallback, PdfVersion; 29 | export 'pdf/format/stream.dart'; 30 | export 'pdf/format/string.dart'; 31 | export 'pdf/format/xref.dart'; 32 | export 'pdf/obj/catalog.dart'; 33 | export 'pdf/obj/graphic_stream.dart'; 34 | export 'pdf/obj/object.dart'; 35 | export 'pdf/obj/object_stream.dart'; 36 | export 'pdf/obj/page_list.dart'; 37 | -------------------------------------------------------------------------------- /pdf/lib/src/svg/clip_path.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:meta/meta.dart'; 18 | import 'package:xml/xml.dart'; 19 | 20 | import '../../pdf.dart'; 21 | import 'brush.dart'; 22 | import 'operation.dart'; 23 | import 'painter.dart'; 24 | 25 | @immutable 26 | class SvgClipPath { 27 | const SvgClipPath(this.children, this.isEmpty, this.painter); 28 | 29 | factory SvgClipPath.fromXml( 30 | XmlElement element, SvgPainter painter, SvgBrush brush) { 31 | final clipPathAttr = element.getAttribute('clip-path'); 32 | if (clipPathAttr == null) { 33 | return const SvgClipPath(null, true, null); 34 | } 35 | 36 | Iterable children; 37 | 38 | if (clipPathAttr.startsWith('url(#')) { 39 | final id = clipPathAttr.substring(5, clipPathAttr.lastIndexOf(')')); 40 | final clipPath = painter.parser.findById(id); 41 | if (clipPath != null) { 42 | children = clipPath.children 43 | .whereType() 44 | .map((c) => SvgOperation.fromXml(c, painter, brush)); 45 | return SvgClipPath(children, false, painter); 46 | } 47 | } 48 | 49 | return const SvgClipPath(null, true, null); 50 | } 51 | 52 | final Iterable? children; 53 | 54 | final bool isEmpty; 55 | 56 | final SvgPainter? painter; 57 | 58 | bool get isNotEmpty => !isEmpty; 59 | 60 | void apply(PdfGraphics canvas) { 61 | if (isEmpty) { 62 | return; 63 | } 64 | 65 | for (final child in children!) { 66 | child!.draw(canvas); 67 | } 68 | canvas.clipPath(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /pdf/lib/src/svg/mask_path.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:meta/meta.dart'; 18 | import 'package:xml/xml.dart'; 19 | 20 | import '../../pdf.dart'; 21 | import 'brush.dart'; 22 | import 'operation.dart'; 23 | import 'painter.dart'; 24 | 25 | @immutable 26 | class SvgMaskPath { 27 | const SvgMaskPath(this.children, this.painter); 28 | 29 | static SvgMaskPath? fromXml( 30 | XmlElement element, SvgPainter painter, SvgBrush brush) { 31 | final maskPathAttr = element.getAttribute('mask'); 32 | if (maskPathAttr == null) { 33 | return null; 34 | } 35 | 36 | Iterable children; 37 | 38 | if (maskPathAttr.startsWith('url(#')) { 39 | final id = maskPathAttr.substring(5, maskPathAttr.lastIndexOf(')')); 40 | final maskPath = painter.parser.findById(id); 41 | if (maskPath != null) { 42 | final maskBrush = SvgBrush.fromXml(maskPath, brush, painter); 43 | children = maskPath.children.whereType().map( 44 | (c) => SvgOperation.fromXml(c, painter, maskBrush)); 45 | return SvgMaskPath(children, painter); 46 | } 47 | } 48 | 49 | return null; 50 | } 51 | 52 | final Iterable children; 53 | 54 | final SvgPainter painter; 55 | 56 | void apply(PdfGraphics canvas) { 57 | final mask = PdfSoftMask( 58 | painter.document, 59 | boundingBox: painter.boundingBox, 60 | ); 61 | 62 | final maskCanvas = mask.getGraphics(); 63 | // maskCanvas.setTransform(canvas.getTransform()); 64 | 65 | for (final child in children) { 66 | child!.paint(maskCanvas!); 67 | } 68 | 69 | canvas.setGraphicState(PdfGraphicState(softMask: mask)); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /pdf/lib/src/svg/symbol.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:xml/xml.dart'; 18 | 19 | import '../../pdf.dart'; 20 | import 'brush.dart'; 21 | import 'clip_path.dart'; 22 | import 'group.dart'; 23 | import 'operation.dart'; 24 | import 'painter.dart'; 25 | import 'transform.dart'; 26 | 27 | class SvgSymbol extends SvgGroup { 28 | SvgSymbol( 29 | Iterable children, 30 | SvgBrush brush, 31 | SvgClipPath clip, 32 | SvgTransform transform, 33 | SvgPainter painter, 34 | ) : super(children, brush, clip, transform, painter); 35 | 36 | factory SvgSymbol.fromXml( 37 | XmlElement element, SvgPainter painter, SvgBrush brush) { 38 | final _brush = SvgBrush.fromXml(element, brush, painter); 39 | 40 | final children = element.children 41 | .whereType() 42 | .map( 43 | (child) => SvgOperation.fromXml(child, painter, _brush)) 44 | .whereType(); 45 | 46 | return SvgSymbol( 47 | children, 48 | _brush, 49 | SvgClipPath.fromXml(element, painter, _brush), 50 | SvgTransform.fromXml(element), 51 | painter, 52 | ); 53 | } 54 | 55 | @override 56 | void paintShape(PdfGraphics canvas) { 57 | for (final child in children) { 58 | child.paint(canvas); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /pdf/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pdf 2 | description: A pdf producer for Dart. It can create pdf files for both web or flutter. 3 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf 4 | repository: https://github.com/DavBfr/dart_pdf 5 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues 6 | screenshots: 7 | - description: 'Example of a generated document' 8 | path: example.jpg 9 | topics: 10 | - pdf 11 | - printer 12 | - print 13 | - printing 14 | - report 15 | version: 3.11.3 16 | 17 | environment: 18 | sdk: ">=2.19.0 <4.0.0" 19 | 20 | dependencies: 21 | archive: ">=3.4.0 <4.1.0" 22 | barcode: ">=2.2.3 <3.0.0" 23 | bidi: ^2.0.10 24 | crypto: ^3.0.0 25 | image: ">=4.1.0 <4.6.0" 26 | meta: ">=1.3.0 <2.0.0" 27 | path_parsing: ">=0.2.0 <2.0.0" 28 | vector_math: ^2.1.0 29 | xml: ">=6.3.0 <7.0.0" 30 | 31 | dev_dependencies: 32 | flutter_lints: ^5.0.0 33 | test: ">=1.16.0 <2.0.0" 34 | -------------------------------------------------------------------------------- /pdf/test/isolate_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | import 'dart:isolate'; 19 | 20 | import 'package:pdf/widgets.dart'; 21 | import 'package:test/test.dart'; 22 | 23 | import 'utils.dart'; 24 | 25 | void main() { 26 | test('Pdf Isolate', () async { 27 | print('Download image'); 28 | final imageBytes = await download('https://www.nfet.net/nfet.jpg'); 29 | 30 | print('Generate PDF'); 31 | // ignore: sdk_version_since 32 | final data = await Isolate.run(() async { 33 | final pdf = Document(); 34 | final image = MemoryImage(imageBytes); 35 | pdf.addPage( 36 | Page(build: (Context context) => Center(child: Image(image)))); 37 | return await pdf.save(); 38 | }); 39 | 40 | print('Generated a ${data.length} bytes PDF'); 41 | final file = File('isolate.pdf'); 42 | await file.writeAsBytes(data); 43 | print('File saved'); 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /pdf/test/roll_paper_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | 19 | import 'package:pdf/pdf.dart'; 20 | import 'package:pdf/widgets.dart'; 21 | import 'package:test/test.dart'; 22 | 23 | late Document pdf; 24 | 25 | void main() { 26 | setUpAll(() { 27 | RichText.debug = true; 28 | Document.debug = true; 29 | pdf = Document(); 30 | }); 31 | 32 | test('Pdf Roll Paper', () async { 33 | pdf.addPage(Page( 34 | pageFormat: PdfPageFormat.roll80, 35 | build: (Context context) => Padding( 36 | padding: const EdgeInsets.all(30), 37 | child: Center( 38 | child: Text('Hello World!'), 39 | ), 40 | ), 41 | )); 42 | }); 43 | 44 | test('Pdf Automatic Paper', () async { 45 | pdf.addPage(Page( 46 | pageFormat: PdfPageFormat.undefined, 47 | build: (Context context) => Text('Hello World!'))); 48 | }); 49 | 50 | tearDownAll(() async { 51 | final file = File('roll-paper.pdf'); 52 | await file.writeAsBytes(await pdf.save()); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /pdf/test/widget_clip_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | 19 | import 'package:pdf/pdf.dart'; 20 | import 'package:pdf/widgets.dart'; 21 | import 'package:test/test.dart'; 22 | 23 | late Document pdf; 24 | 25 | void main() { 26 | setUpAll(() { 27 | Document.debug = true; 28 | pdf = Document(); 29 | }); 30 | 31 | test('Clip Widgets ClipRect', () { 32 | pdf.addPage(Page( 33 | build: (Context context) => ClipRect( 34 | child: Transform.rotate( 35 | angle: 0.1, 36 | child: Container( 37 | decoration: const BoxDecoration( 38 | color: PdfColors.blue, 39 | ), 40 | ), 41 | ), 42 | ), 43 | )); 44 | }); 45 | 46 | test('Clip Widgets ClipRRect', () { 47 | pdf.addPage(Page( 48 | build: (Context context) => ClipRRect( 49 | horizontalRadius: 30, 50 | verticalRadius: 30, 51 | child: Container( 52 | decoration: const BoxDecoration( 53 | color: PdfColors.blue, 54 | ), 55 | ), 56 | ), 57 | )); 58 | }); 59 | 60 | test('Clip Widgets ClipOval', () { 61 | pdf.addPage(Page( 62 | build: (Context context) => ClipOval( 63 | child: Container( 64 | decoration: const BoxDecoration( 65 | color: PdfColors.blue, 66 | ), 67 | ), 68 | ), 69 | )); 70 | }); 71 | 72 | tearDownAll(() async { 73 | final file = File('widgets-clip.pdf'); 74 | await file.writeAsBytes(await pdf.save()); 75 | }); 76 | } 77 | -------------------------------------------------------------------------------- /pdf/test/widget_grid_view_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | 19 | import 'package:pdf/widgets.dart'; 20 | import 'package:test/test.dart'; 21 | 22 | late Document pdf; 23 | 24 | void main() { 25 | setUpAll(() { 26 | Document.debug = true; 27 | RichText.debug = true; 28 | pdf = Document(); 29 | }); 30 | 31 | test('Pdf Widgets GridView empty', () { 32 | pdf.addPage(MultiPage( 33 | build: (Context context) => [ 34 | GridView( 35 | crossAxisCount: 1, 36 | childAspectRatio: 1, 37 | ), 38 | ])); 39 | }); 40 | 41 | test('Pdf Widgets GridView Vertical', () { 42 | pdf.addPage(MultiPage( 43 | build: (Context context) => [ 44 | GridView( 45 | crossAxisCount: 3, 46 | childAspectRatio: 1, 47 | direction: Axis.vertical, 48 | children: List.generate( 49 | 20, (int index) => Center(child: Text('$index')))), 50 | ])); 51 | }); 52 | 53 | test('Pdf Widgets GridView Horizontal', () { 54 | pdf.addPage(Page( 55 | build: (Context context) => GridView( 56 | crossAxisCount: 5, 57 | direction: Axis.horizontal, 58 | childAspectRatio: 1, 59 | children: List.generate( 60 | 20, (int index) => Center(child: Text('$index')))), 61 | )); 62 | }); 63 | 64 | tearDownAll(() async { 65 | final file = File('widgets-gridview.pdf'); 66 | await file.writeAsBytes(await pdf.save()); 67 | }); 68 | } 69 | -------------------------------------------------------------------------------- /pdf/test/widget_icon_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | 19 | import 'package:pdf/pdf.dart'; 20 | import 'package:pdf/widgets.dart'; 21 | import 'package:test/test.dart'; 22 | 23 | import 'utils.dart'; 24 | 25 | late Document pdf; 26 | Font? icons; 27 | 28 | void main() { 29 | setUpAll(() { 30 | Document.debug = true; 31 | RichText.debug = true; 32 | pdf = Document(); 33 | icons = loadFont('material.ttf'); 34 | }); 35 | 36 | test('Icon Widgets', () { 37 | pdf.addPage( 38 | MultiPage( 39 | theme: ThemeData.withFont(icons: icons), 40 | build: (Context context) { 41 | final iconList = []; 42 | final pdfFont = icons!.getFont(context); 43 | if (pdfFont is PdfTtfFont) { 44 | iconList.addAll( 45 | pdfFont.font.charToGlyphIndexMap.keys 46 | .where((e) => e > 0x7f && e < 0xe05d) 47 | .map((e) => IconData(e)), 48 | ); 49 | } 50 | 51 | return [ 52 | Wrap( 53 | spacing: 10, 54 | runSpacing: 10, 55 | children: [ 56 | ...iconList.map( 57 | (e) => Column(children: [ 58 | Icon(e, size: 50, color: PdfColors.blueGrey), 59 | Text('0x${e.codePoint.toRadixString(16)}'), 60 | ]), 61 | ), 62 | ], 63 | ), 64 | ]; 65 | }, 66 | ), 67 | ); 68 | }); 69 | 70 | tearDownAll(() async { 71 | final file = File('widgets-icons.pdf'); 72 | await file.writeAsBytes(await pdf.save()); 73 | }); 74 | } 75 | -------------------------------------------------------------------------------- /pdf/test/widget_multipage_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | 19 | import 'package:pdf/widgets.dart'; 20 | import 'package:test/test.dart'; 21 | 22 | List lines = []; 23 | 24 | void main() { 25 | setUpAll(() { 26 | Document.debug = true; 27 | RichText.debug = true; 28 | 29 | for (var i = 0; i < 200; i++) { 30 | lines.add(Text('Line $i')); 31 | } 32 | }); 33 | 34 | test('Pdf Widgets MultiPage', () async { 35 | Document.debug = true; 36 | 37 | final pdf = Document(); 38 | 39 | pdf.addPage(MultiPage(build: (Context context) => lines)); 40 | 41 | final file = File('widgets-multipage.pdf'); 42 | await file.writeAsBytes(await pdf.save()); 43 | 44 | final file1 = File('widgets-multipage-1.pdf'); 45 | await file1.writeAsBytes(await pdf.save()); 46 | }); 47 | 48 | test('Pdf Widgets MonoPage', () async { 49 | Document.debug = true; 50 | 51 | final pdf = Document(); 52 | 53 | pdf.addPage(Page(build: (Context context) => Column(children: lines))); 54 | 55 | final file = File('widgets-monopage.pdf'); 56 | await file.writeAsBytes(await pdf.save()); 57 | 58 | final file1 = File('widgets-monopage-1.pdf'); 59 | await file1.writeAsBytes(await pdf.save()); 60 | }); 61 | } 62 | -------------------------------------------------------------------------------- /pdf/test/widget_opacity_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | 19 | import 'package:pdf/widgets.dart'; 20 | import 'package:test/test.dart'; 21 | 22 | late Document pdf; 23 | 24 | void main() { 25 | setUpAll(() { 26 | Document.debug = true; 27 | RichText.debug = true; 28 | pdf = Document(); 29 | }); 30 | 31 | test('Opacity Widgets', () { 32 | pdf.addPage( 33 | Page( 34 | build: (Context context) => Stack( 35 | alignment: Alignment.center, 36 | children: [ 37 | Text('Background', textScaleFactor: 5), 38 | Opacity( 39 | opacity: .5, 40 | child: PdfLogo(), 41 | ), 42 | ], 43 | ), 44 | ), 45 | ); 46 | }); 47 | 48 | tearDownAll(() async { 49 | final file = File('widgets-opacity.pdf'); 50 | await file.writeAsBytes(await pdf.save()); 51 | }); 52 | } 53 | -------------------------------------------------------------------------------- /pdf/test/widget_partitions_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io'; 18 | 19 | import 'package:pdf/widgets.dart'; 20 | import 'package:test/test.dart'; 21 | 22 | late Document pdf; 23 | 24 | void main() { 25 | setUpAll(() { 26 | Document.debug = true; 27 | RichText.debug = true; 28 | pdf = Document(); 29 | }); 30 | 31 | test('Partitions Widget', () { 32 | pdf.addPage( 33 | MultiPage( 34 | build: (Context context) => [ 35 | Partitions( 36 | children: [ 37 | Partition( 38 | flex: 1618, 39 | child: Column( 40 | children: List.generate(100, (int i) => Text('$i')), 41 | ), 42 | ), 43 | Partition( 44 | flex: 1000, 45 | // width: 100, 46 | child: Column( 47 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 48 | children: List.generate(20, (int i) => Text('$i')), 49 | ), 50 | ), 51 | ], 52 | ), 53 | ], 54 | ), 55 | ); 56 | }); 57 | 58 | tearDownAll(() async { 59 | final file = File('widgets-partitions.pdf'); 60 | await file.writeAsBytes(await pdf.save()); 61 | }); 62 | } 63 | -------------------------------------------------------------------------------- /printing/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | analyzer: 4 | errors: 5 | missing_required_param: warning 6 | missing_return: warning 7 | public_member_api_docs: ignore 8 | todo: ignore 9 | 10 | linter: 11 | rules: 12 | - always_declare_return_types 13 | - always_put_control_body_on_new_line 14 | - avoid_bool_literals_in_conditional_expressions 15 | - avoid_classes_with_only_static_members 16 | - avoid_field_initializers_in_const_classes 17 | - avoid_redundant_argument_values 18 | - avoid_slow_async_io 19 | - avoid_unused_constructor_parameters 20 | - avoid_void_async 21 | - await_only_futures 22 | - cancel_subscriptions 23 | - cast_nullable_to_non_nullable 24 | - directives_ordering 25 | - file_names 26 | - flutter_style_todos 27 | - leading_newlines_in_multiline_strings 28 | - no_adjacent_strings_in_list 29 | - no_default_cases 30 | - omit_local_variable_types 31 | - parameter_assignments 32 | - prefer_asserts_in_initializer_lists 33 | - prefer_const_constructors_in_immutables 34 | - prefer_final_fields 35 | - prefer_final_in_for_each 36 | - prefer_final_locals 37 | - prefer_foreach 38 | - prefer_generic_function_type_aliases 39 | - prefer_if_elements_to_conditional_expressions 40 | - prefer_if_null_operators 41 | - prefer_interpolation_to_compose_strings 42 | - prefer_null_aware_operators 43 | - prefer_relative_imports 44 | - prefer_single_quotes 45 | - prefer_typing_uninitialized_variables 46 | - public_member_api_docs 47 | - require_trailing_commas 48 | - sort_constructors_first 49 | - sort_pub_dependencies 50 | - sort_unnamed_constructors_first 51 | - test_types_in_equals 52 | - throw_in_finally 53 | - unnecessary_brace_in_string_interps 54 | - unnecessary_getters_setters 55 | - unnecessary_lambdas 56 | - unnecessary_null_checks 57 | - unnecessary_nullable_for_final_variable_declarations 58 | - unnecessary_overrides 59 | - unnecessary_parenthesis 60 | - unnecessary_statements 61 | - unnecessary_this 62 | - use_build_context_synchronously 63 | - use_function_type_syntax_for_parameters 64 | - use_late_for_private_fields_and_variables 65 | - use_named_constants 66 | - void_checks 67 | -------------------------------------------------------------------------------- /printing/android/build.gradle: -------------------------------------------------------------------------------- 1 | group "net.nfet.flutter.printing" 2 | version "1.0" 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath "com.android.tools.build:gradle:7.3.0" 12 | } 13 | } 14 | 15 | rootProject.allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | apply plugin: "com.android.library" 23 | 24 | android { 25 | if (project.android.hasProperty("namespace")) { 26 | namespace = "net.nfet.flutter.printing" 27 | } 28 | 29 | compileSdk = 34 30 | 31 | compileOptions { 32 | sourceCompatibility = JavaVersion.VERSION_1_8 33 | targetCompatibility = JavaVersion.VERSION_1_8 34 | } 35 | 36 | defaultConfig { 37 | minSdk = 21 38 | } 39 | 40 | lintOptions { 41 | disable "InvalidPackage" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /printing/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'printing' 2 | -------------------------------------------------------------------------------- /printing/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /printing/android/src/main/java/net/nfet/flutter/printing/PrintFileProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.nfet.flutter.printing; 18 | 19 | import androidx.core.content.FileProvider; 20 | 21 | public class PrintFileProvider extends FileProvider {} 22 | -------------------------------------------------------------------------------- /printing/android/src/main/res/xml/flutter_printing_file_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /printing/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/printing/example.png -------------------------------------------------------------------------------- /printing/example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Exceptions to above rules. 43 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 44 | 45 | android 46 | ios 47 | macos 48 | web 49 | .metadata 50 | README.md 51 | test 52 | windows 53 | linux 54 | analysis_options.yaml 55 | -------------------------------------------------------------------------------- /printing/example/lib/main.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: public_member_api_docs, avoid_redundant_argument_values 2 | 3 | import 'dart:typed_data'; 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:pdf/pdf.dart'; 7 | import 'package:pdf/widgets.dart' as pw; 8 | import 'package:printing/printing.dart'; 9 | 10 | Future main() async { 11 | runApp(const MyApp('Printing Demo')); 12 | } 13 | 14 | class MyApp extends StatelessWidget { 15 | const MyApp(this.title, {super.key}); 16 | 17 | final String title; 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return MaterialApp( 22 | home: Scaffold( 23 | appBar: AppBar(title: Text(title)), 24 | body: PdfPreview( 25 | build: (format) => _generatePdf(format, title), 26 | ), 27 | ), 28 | ); 29 | } 30 | 31 | Future _generatePdf(PdfPageFormat format, String title) async { 32 | final pdf = pw.Document(version: PdfVersion.pdf_1_5, compress: true); 33 | final font = await PdfGoogleFonts.nunitoExtraLight(); 34 | 35 | pdf.addPage( 36 | pw.Page( 37 | pageFormat: format, 38 | build: (context) { 39 | return pw.Column( 40 | children: [ 41 | pw.SizedBox( 42 | width: double.infinity, 43 | child: pw.FittedBox( 44 | child: pw.Text(title, style: pw.TextStyle(font: font)), 45 | ), 46 | ), 47 | pw.SizedBox(height: 20), 48 | pw.Flexible(child: pw.FlutterLogo()), 49 | ], 50 | ); 51 | }, 52 | ), 53 | ); 54 | 55 | return pdf.save(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /printing/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: printing_example 2 | description: Pdf Printing Example 3 | 4 | version: 1.0.0+1 5 | 6 | environment: 7 | sdk: ">=3.3.0 <4.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | pdf: 13 | printing: 14 | vector_math: ^2.1.0 15 | xml: ">=5.1.0 <7.0.0" 16 | 17 | dependency_overrides: 18 | pdf: 19 | path: ../../pdf 20 | printing: 21 | path: ../ 22 | 23 | dev_dependencies: 24 | flutter_lints: 25 | 26 | flutter: 27 | uses-material-design: true 28 | -------------------------------------------------------------------------------- /printing/ios/Classes/CustomPrintPaper.swift: -------------------------------------------------------------------------------- 1 | public class CustomPrintPaper: UIPrintPaper { 2 | private let size: CGSize 3 | 4 | override public var paperSize: CGSize { return size } 5 | override public var printableRect: CGRect { return CGRect(origin: CGPoint.zero, size: size) } 6 | 7 | init(size: CGSize) { 8 | self.size = size 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /printing/ios/Classes/PrintingPlugin.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #if __has_include() 18 | #import 19 | #else 20 | #import "printing-Swift.h" 21 | #endif 22 | 23 | // Dart:ffi API 24 | 25 | void net_nfet_printing_set_document(uint32_t job, 26 | const uint8_t* doc, 27 | uint64_t size) { 28 | [PrintingPlugin setDocumentWithJob:job doc:doc size:size]; 29 | } 30 | 31 | void net_nfet_printing_set_error(uint32_t job, const char* message) { 32 | [PrintingPlugin setErrorWithJob:job message:message]; 33 | } 34 | -------------------------------------------------------------------------------- /printing/ios/printing.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'printing' 6 | s.version = '1.0.0' 7 | s.summary = 'Flutter printing plugin' 8 | s.description = 'Plugin that allows Flutter apps to generate and print documents to iOS compatible printers' 9 | s.homepage = 'https://pub.dev/packages/printing' 10 | s.license = { :type => 'Apache2' } 11 | s.author = { 'David PHAM-VAN' => 'dev.nfet.net@gmail.com' } 12 | s.source = { :git => 'https://github.com/DavBfr/dart_pdf.git', :branch => 'master' } 13 | s.source_files = 'Classes/**/*' 14 | s.dependency 'Flutter' 15 | s.ios.deployment_target = '8.0' 16 | s.swift_version = '4.2' 17 | end 18 | -------------------------------------------------------------------------------- /printing/lib/printing.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:pdf/widgets.dart'; 18 | 19 | import 'src/fonts/gfonts.dart'; 20 | 21 | export 'package:pdf_widget_wrapper/pdf_widget_wrapper.dart'; 22 | 23 | export 'src/asset_utils.dart'; 24 | export 'src/cache.dart'; 25 | export 'src/callback.dart'; 26 | export 'src/fonts/gfonts.dart'; 27 | export 'src/output_type.dart'; 28 | export 'src/preview/action_bar_theme.dart'; 29 | export 'src/preview/actions.dart'; 30 | export 'src/preview/pdf_preview.dart'; 31 | export 'src/printer.dart'; 32 | export 'src/printing.dart'; 33 | export 'src/printing_info.dart'; 34 | export 'src/raster.dart'; 35 | 36 | Future pdfDefaultTheme() async { 37 | if (ThemeData.buildThemeData != null) { 38 | return; 39 | } 40 | 41 | final base = await PdfGoogleFonts.openSansRegular(); 42 | final bold = await PdfGoogleFonts.openSansBold(); 43 | final italic = await PdfGoogleFonts.openSansItalic(); 44 | final boldItalic = await PdfGoogleFonts.openSansBoldItalic(); 45 | final emoji = await PdfGoogleFonts.notoColorEmoji(); 46 | final icons = await PdfGoogleFonts.materialIcons(); 47 | 48 | ThemeData.buildThemeData = () { 49 | return ThemeData.withFont( 50 | base: base, 51 | bold: bold, 52 | italic: italic, 53 | boldItalic: boldItalic, 54 | icons: icons, 55 | fontFallback: [emoji, base], 56 | ); 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /printing/lib/src/callback.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:async'; 18 | import 'dart:typed_data'; 19 | 20 | import 'package:pdf/pdf.dart'; 21 | 22 | /// Callback used to generate the Pdf document dynamically when the user 23 | /// changes the page settings: size and margins 24 | typedef LayoutCallback = FutureOr Function(PdfPageFormat format); 25 | -------------------------------------------------------------------------------- /printing/lib/src/fonts/manifest.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:async'; 18 | import 'dart:convert'; 19 | 20 | import 'package:flutter/services.dart'; 21 | 22 | import '../mutex.dart'; 23 | 24 | /// Application asset manifest. 25 | mixin AssetManifest { 26 | static final _assets = []; 27 | 28 | static final _mutex = Mutex(); 29 | 30 | static bool _ready = false; 31 | static bool _failed = false; 32 | 33 | /// Does is contains this key? 34 | static Future contains(String key) async { 35 | if (_failed) { 36 | return false; 37 | } 38 | 39 | await _mutex.acquire(); 40 | try { 41 | if (!_ready) { 42 | try { 43 | final jsonString = await rootBundle.loadString('AssetManifest.json'); 44 | final jsonData = json.decode(jsonString) as Map; 45 | _assets.addAll(jsonData.keys); 46 | } catch (e) { 47 | assert(() { 48 | // ignore: avoid_print 49 | print( 50 | 'Error loading AssetManifest.json $e Try to call first:\nWidgetsFlutterBinding.ensureInitialized();', 51 | ); 52 | return true; 53 | }()); 54 | 55 | rootBundle.evict('AssetManifest.json'); 56 | _failed = true; 57 | _ready = true; 58 | return false; 59 | } 60 | _ready = true; 61 | } 62 | } finally { 63 | _mutex.release(); 64 | } 65 | 66 | return _assets.contains(key); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /printing/lib/src/method_channel_js.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:typed_data'; 18 | 19 | import 'print_job.dart'; 20 | 21 | /// Set the Pdf document data 22 | void setDocumentFfi(PrintJob job, Uint8List data) { 23 | throw UnimplementedError('Not using FFI'); 24 | } 25 | 26 | /// Set the Pdf Error message 27 | void setErrorFfi(PrintJob job, String message) { 28 | throw UnimplementedError('Not using FFI'); 29 | } 30 | -------------------------------------------------------------------------------- /printing/lib/src/mutex.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:async'; 18 | 19 | /// Simple Mutex 20 | class Mutex { 21 | final _waiting = []; 22 | 23 | bool _locked = false; 24 | 25 | bool get locked => _locked; 26 | 27 | /// Wait for the mutex to be available 28 | Future wait() async { 29 | await acquire(); 30 | release(); 31 | } 32 | 33 | /// Lock the mutex 34 | Future acquire() async { 35 | if (_locked) { 36 | final c = Completer(); 37 | _waiting.add(c); 38 | await c.future; 39 | } 40 | _locked = true; 41 | } 42 | 43 | /// Release the mutex 44 | void release() { 45 | _locked = false; 46 | for (final e in _waiting) { 47 | e.complete(); 48 | } 49 | _waiting.clear(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /printing/lib/src/output_type.dart: -------------------------------------------------------------------------------- 1 | enum OutputType { 2 | generic, 3 | photo, 4 | grayscale, 5 | photoGrayscale, 6 | } 7 | -------------------------------------------------------------------------------- /printing/lib/src/pdfjs.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // ignore_for_file: public_member_api_docs 18 | 19 | @JS('pdfjsLib') 20 | library; 21 | 22 | import 'dart:js_interop'; 23 | 24 | import 'package:web/web.dart'; 25 | 26 | @JS() 27 | external PdfJsDocLoader getDocument(Settings data); 28 | 29 | @anonymous 30 | @JS() 31 | extension type Settings._(JSObject _) implements JSObject { 32 | external factory Settings({JSUint8Array data}); 33 | 34 | external set data(JSUint8Array value); 35 | external set scale(double value); 36 | external set canvasContext(CanvasRenderingContext2D value); 37 | external set viewport(PdfJsViewport value); 38 | external set cMapUrl(String value); 39 | external set cMapPacked(bool value); 40 | } 41 | 42 | @anonymous 43 | @JS() 44 | extension type PdfJsDocLoader._(JSObject _) implements JSObject { 45 | external JSPromise get promise; 46 | external JSPromise destroy(); 47 | } 48 | 49 | @anonymous 50 | @JS() 51 | extension type PdfJsDoc._(JSObject _) implements JSObject { 52 | external JSPromise getPage(int num); 53 | external int get numPages; 54 | } 55 | 56 | @anonymous 57 | @JS() 58 | extension type PdfJsPage._(JSObject _) implements JSObject { 59 | external PdfJsViewport getViewport(Settings data); 60 | external PdfJsRender render(Settings data); 61 | external bool cleanup(); 62 | } 63 | 64 | @anonymous 65 | @JS() 66 | extension type PdfJsViewport._(JSObject _) implements JSObject { 67 | external num get width; 68 | external num get height; 69 | } 70 | 71 | @anonymous 72 | @JS() 73 | extension type PdfJsRender._(JSObject _) implements JSObject { 74 | external JSPromise get promise; 75 | } 76 | -------------------------------------------------------------------------------- /printing/lib/src/platform_js.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const useFFI = false; 18 | const isAndroid = false; 19 | -------------------------------------------------------------------------------- /printing/lib/src/platform_os.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:io' show Platform; 18 | 19 | final useFFI = Platform.isMacOS || Platform.isIOS; 20 | 21 | final isAndroid = Platform.isAndroid; 22 | -------------------------------------------------------------------------------- /printing/lib/src/raster.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:async'; 18 | import 'dart:typed_data'; 19 | import 'dart:ui' as ui; 20 | 21 | import 'package:flutter/painting.dart'; 22 | import 'package:pdf/pdf.dart'; 23 | 24 | /// Represents a bitmap image 25 | class PdfRaster extends PdfRasterBase { 26 | /// Create a bitmap image 27 | PdfRaster( 28 | int width, 29 | int height, 30 | Uint8List pixels, 31 | ) : super(width, height, true, pixels); 32 | 33 | /// Decode RGBA raw image to dart:ui Image 34 | Future toImage() { 35 | final comp = Completer(); 36 | ui.decodeImageFromPixels( 37 | pixels, 38 | width, 39 | height, 40 | ui.PixelFormat.rgba8888, 41 | comp.complete, 42 | ); 43 | return comp.future; 44 | } 45 | 46 | /// Convert to a PNG image 47 | @override 48 | Future toPng() async { 49 | final image = await toImage(); 50 | final data = await image.toByteData(format: ui.ImageByteFormat.png); 51 | return data!.buffer.asUint8List(); 52 | } 53 | } 54 | 55 | /// Image provider for a [PdfRaster] 56 | class PdfRasterImage extends ImageProvider { 57 | /// Create an ImageProvider from a [PdfRaster] 58 | PdfRasterImage(this.raster); 59 | 60 | /// The image source 61 | final PdfRaster raster; 62 | 63 | Future _loadAsync() async { 64 | final uiImage = await raster.toImage(); 65 | return ImageInfo(image: uiImage); 66 | } 67 | 68 | @override 69 | ImageStreamCompleter loadImage(PdfRaster key, ImageDecoderCallback decode) { 70 | return OneFrameImageStreamCompleter(_loadAsync()); 71 | } 72 | 73 | @override 74 | Future obtainKey(ImageConfiguration configuration) async { 75 | return raster; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /printing/linux/include/printing/printing_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLUTTER_PLUGIN_PRINTING_PLUGIN_H_ 18 | #define FLUTTER_PLUGIN_PRINTING_PLUGIN_H_ 19 | 20 | #include 21 | 22 | G_BEGIN_DECLS 23 | 24 | #ifdef FLUTTER_PLUGIN_IMPL 25 | #define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) 26 | #else 27 | #define FLUTTER_PLUGIN_EXPORT 28 | #endif 29 | 30 | typedef struct _PrintingPlugin PrintingPlugin; 31 | typedef struct { 32 | GObjectClass parent_class; 33 | } PrintingPluginClass; 34 | 35 | FLUTTER_PLUGIN_EXPORT GType printing_plugin_get_type(); 36 | 37 | FLUTTER_PLUGIN_EXPORT void printing_plugin_register_with_registrar( 38 | FlPluginRegistrar* registrar); 39 | 40 | G_END_DECLS 41 | 42 | #endif // FLUTTER_PLUGIN_PRINTING_PLUGIN_H_ 43 | -------------------------------------------------------------------------------- /printing/macos/Classes/PrintingPlugin.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | // Dart:ffi API 20 | 21 | void net_nfet_printing_set_document(uint32_t job, 22 | const uint8_t* doc, 23 | uint64_t size) { 24 | [PrintingPlugin setDocumentWithJob:job doc:doc size:size]; 25 | } 26 | 27 | void net_nfet_printing_set_error(uint32_t job, const char* message) { 28 | [PrintingPlugin setErrorWithJob:job message:message]; 29 | } 30 | -------------------------------------------------------------------------------- /printing/macos/printing.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'printing' 6 | s.version = '1.0.0' 7 | s.summary = 'Flutter printing plugin' 8 | s.description = 'Plugin that allows Flutter apps to generate and print documents to macOS compatible printers' 9 | s.homepage = 'https://pub.dev/packages/printing' 10 | s.license = { :type => 'Apache2' } 11 | s.author = { 'David PHAM-VAN' => 'dev.nfet.net@gmail.com' } 12 | s.source = { :git => 'https://github.com/DavBfr/dart_pdf.git', :branch => 'master' } 13 | s.source_files = 'Classes/**/*' 14 | s.dependency 'FlutterMacOS' 15 | s.platform = :osx 16 | s.osx.deployment_target = '10.11' 17 | end 18 | -------------------------------------------------------------------------------- /printing/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: printing 2 | description: > 3 | Plugin that allows Flutter apps to generate and print documents to 4 | compatible printers on Android, iOS, macOS, Windows, and Linux, 5 | as well as web print. 6 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing 7 | repository: https://github.com/DavBfr/dart_pdf 8 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues 9 | screenshots: 10 | - description: 'Printing a document on iOS' 11 | path: example.png 12 | topics: 13 | - pdf 14 | - printer 15 | - print 16 | - printing 17 | - report 18 | version: 5.14.2 19 | 20 | environment: 21 | sdk: ">=3.3.0 <4.0.0" 22 | flutter: ">=3.22.0" 23 | 24 | dependencies: 25 | ffi: ">=1.1.0 <3.0.0" 26 | flutter: 27 | sdk: flutter 28 | flutter_web_plugins: 29 | sdk: flutter 30 | http: ">=0.13.0 <2.0.0" 31 | image: ">=4.1.0 <4.6.0" 32 | meta: ">=1.3.0 <2.0.0" 33 | pdf: ^3.10.0 34 | pdf_widget_wrapper: '>=1.0.4 <2.0.0' 35 | plugin_platform_interface: ^2.1.0 36 | web: ^1.0.0 37 | 38 | dev_dependencies: 39 | flutter_lints: ^5.0.0 40 | flutter_test: 41 | sdk: flutter 42 | mockito: ^5.4.4 43 | 44 | dependency_overrides: 45 | pdf: 46 | path: ../pdf 47 | pdf_widget_wrapper: 48 | path: ../widget_wrapper 49 | 50 | flutter: 51 | plugin: 52 | platforms: 53 | android: 54 | package: net.nfet.flutter.printing 55 | pluginClass: PrintingPlugin 56 | ios: 57 | pluginClass: PrintingPlugin 58 | linux: 59 | pluginClass: PrintingPlugin 60 | macos: 61 | pluginClass: PrintingPlugin 62 | web: 63 | fileName: printing_web.dart 64 | pluginClass: PrintingPlugin 65 | windows: 66 | pluginClass: PrintingPlugin 67 | -------------------------------------------------------------------------------- /printing/test/info_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'package:flutter_test/flutter_test.dart'; 18 | import 'package:printing/printing.dart'; 19 | 20 | void main() { 21 | setUp(TestWidgetsFlutterBinding.ensureInitialized); 22 | 23 | test('PrintingInfo', () async { 24 | const info = PrintingInfo.unavailable; 25 | expect(info.canConvertHtml, false); 26 | expect(info.directPrint, false); 27 | expect(info.dynamicLayout, false); 28 | expect(info.canPrint, false); 29 | expect(info.canConvertHtml, false); 30 | expect(info.canShare, false); 31 | expect(info.canRaster, false); 32 | 33 | expect(info.toString(), isA()); 34 | }); 35 | 36 | test('PrintingInfo.fromMap', () async { 37 | final info = PrintingInfo.fromMap( 38 | { 39 | 'canPrint': true, 40 | }, 41 | ); 42 | 43 | expect(info.canConvertHtml, false); 44 | expect(info.directPrint, false); 45 | expect(info.dynamicLayout, false); 46 | expect(info.canPrint, true); 47 | expect(info.canConvertHtml, false); 48 | expect(info.canShare, false); 49 | expect(info.canRaster, false); 50 | }); 51 | } 52 | -------------------------------------------------------------------------------- /printing/test/raster_test.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'dart:typed_data'; 18 | import 'dart:ui' as ui; 19 | 20 | import 'package:flutter/widgets.dart'; 21 | import 'package:flutter_test/flutter_test.dart'; 22 | import 'package:printing/printing.dart'; 23 | 24 | void main() { 25 | setUp(TestWidgetsFlutterBinding.ensureInitialized); 26 | 27 | test('PdfRaster', () async { 28 | final raster = 29 | PdfRaster(10, 10, Uint8List.fromList(List.filled(10 * 10 * 4, 0))); 30 | expect(raster.toString(), 'Image 10x10 400 bytes'); 31 | expect(await raster.toImage(), isA()); 32 | expect(await raster.toPng(), isA()); 33 | }); 34 | 35 | testWidgets('PdfRasterImage', (WidgetTester tester) async { 36 | final raster = 37 | PdfRaster(10, 10, Uint8List.fromList(List.filled(10 * 10 * 4, 0))); 38 | 39 | await tester.pumpWidget(Image(image: PdfRasterImage(raster))); 40 | await tester.pumpAndSettle(); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /printing/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /printing/windows/DownloadProject.CMakeLists.cmake.in: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved MIT License. See accompanying 2 | # file LICENSE or https://github.com/Crascit/DownloadProject for details. 3 | 4 | cmake_minimum_required(VERSION 3.10) 5 | 6 | project(${DL_ARGS_PROJ}-download NONE) 7 | 8 | include(ExternalProject) 9 | 10 | if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") 11 | cmake_policy(SET CMP0135 NEW) 12 | endif() 13 | 14 | ExternalProject_Add(${DL_ARGS_PROJ}-download 15 | ${DL_ARGS_UNPARSED_ARGUMENTS} 16 | SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" 17 | BINARY_DIR "${DL_ARGS_BINARY_DIR}" 18 | CONFIGURE_COMMAND "" 19 | BUILD_COMMAND "" 20 | INSTALL_COMMAND "" 21 | TEST_COMMAND "" 22 | ) 23 | -------------------------------------------------------------------------------- /printing/windows/include/printing/printing_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLUTTER_PLUGIN_PRINTING_PLUGIN_H_ 18 | #define FLUTTER_PLUGIN_PRINTING_PLUGIN_H_ 19 | 20 | #include 21 | 22 | #ifdef FLUTTER_PLUGIN_IMPL 23 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) 24 | #else 25 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) 26 | #endif 27 | 28 | #if defined(__cplusplus) 29 | extern "C" { 30 | #endif 31 | 32 | FLUTTER_PLUGIN_EXPORT void PrintingPluginRegisterWithRegistrar( 33 | FlutterDesktopPluginRegistrarRef registrar); 34 | 35 | #if defined(__cplusplus) 36 | } // extern "C" 37 | #endif 38 | 39 | #endif // FLUTTER_PLUGIN_PRINTING_PLUGIN_H_ 40 | -------------------------------------------------------------------------------- /printing/windows/printing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017, David PHAM-VAN 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PRINTING_PLUGIN_PRINTING_H_ 18 | #define PRINTING_PLUGIN_PRINTING_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace nfet { 28 | 29 | class PrintJob; 30 | 31 | class Printing { 32 | private: 33 | public: 34 | Printing(); 35 | 36 | virtual ~Printing(); 37 | 38 | void onPageRasterized(std::vector data, 39 | int width, 40 | int height, 41 | PrintJob* job); 42 | 43 | void onPageRasterEnd(PrintJob* job, const std::string& error); 44 | 45 | void onLayout(PrintJob* job, 46 | double pageWidth, 47 | double pageHeight, 48 | double marginLeft, 49 | double marginTop, 50 | double marginRight, 51 | double marginBottom); 52 | 53 | void Printing::onCompleted(PrintJob* job, 54 | bool completed, 55 | const std::string& error); 56 | }; 57 | 58 | } // namespace nfet 59 | 60 | #endif // PRINTING_PLUGIN_PRINTING_H_ 61 | -------------------------------------------------------------------------------- /test/compare-pdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DST=$(dirname "$0")/diff 4 | SRC=$1 5 | GOLD=$2 6 | ERROR=0 7 | DPI=50 8 | COMPARE=$(command -v compare) 9 | 10 | for PDF in "$SRC"/*.pdf; do 11 | echo "Diffing $PDF" 12 | G="$GOLD"/$(basename "$PDF") 13 | if [ ! -f "$G" ]; then 14 | echo " Golden image $G not found" 15 | ERROR=1 16 | continue 17 | fi 18 | 19 | T=$(basename "$PDF" .pdf) 20 | mkdir -p "$DST"/"$T" 21 | pdftocairo "$PDF" -png -r "$DPI" "$DST"/"$T"/src 2> /dev/null 22 | pdftocairo "$G" -png -r "$DPI" "$DST"/"$T"/gold 2> /dev/null 23 | 24 | for PNG in "$DST"/"$T"/gold*.png; do 25 | S="$DST"/"$T"/src-"${PNG##*-}" 26 | RES=$($COMPARE -metric AE "$PNG" "$S" null: 2>&1) 27 | if [ "$RES" != "0" ]; then 28 | D="$DST"/"$T"/diff-"${PNG##*-}" 29 | $COMPARE "$PNG" "$S" -highlight-color red "$D" 30 | echo " Differences in $PNG and $S => $D" 31 | ERROR=1 32 | fi 33 | done 34 | done 35 | 36 | if [ $ERROR -eq 0 ]; then 37 | rm -rf "$DST" 38 | fi 39 | 40 | exit $ERROR 41 | -------------------------------------------------------------------------------- /test/golden/annotations.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/annotations.pdf -------------------------------------------------------------------------------- /test/golden/arabic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/arabic.pdf -------------------------------------------------------------------------------- /test/golden/colors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/colors.pdf -------------------------------------------------------------------------------- /test/golden/complex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/complex.pdf -------------------------------------------------------------------------------- /test/golden/example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/example.pdf -------------------------------------------------------------------------------- /test/golden/isolate.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/isolate.pdf -------------------------------------------------------------------------------- /test/golden/jpeg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/jpeg.pdf -------------------------------------------------------------------------------- /test/golden/metrics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/metrics.pdf -------------------------------------------------------------------------------- /test/golden/minimal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/minimal.pdf -------------------------------------------------------------------------------- /test/golden/orientation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/orientation.pdf -------------------------------------------------------------------------------- /test/golden/roll-paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/roll-paper.pdf -------------------------------------------------------------------------------- /test/golden/rtl-layout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/rtl-layout.pdf -------------------------------------------------------------------------------- /test/golden/ttf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/ttf.pdf -------------------------------------------------------------------------------- /test/golden/type1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/type1.pdf -------------------------------------------------------------------------------- /test/golden/widgets-barcode.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-barcode.pdf -------------------------------------------------------------------------------- /test/golden/widgets-basic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-basic.pdf -------------------------------------------------------------------------------- /test/golden/widgets-chart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-chart.pdf -------------------------------------------------------------------------------- /test/golden/widgets-clip.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-clip.pdf -------------------------------------------------------------------------------- /test/golden/widgets-container.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-container.pdf -------------------------------------------------------------------------------- /test/golden/widgets-flex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-flex.pdf -------------------------------------------------------------------------------- /test/golden/widgets-form.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-form.pdf -------------------------------------------------------------------------------- /test/golden/widgets-gridview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-gridview.pdf -------------------------------------------------------------------------------- /test/golden/widgets-icons.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-icons.pdf -------------------------------------------------------------------------------- /test/golden/widgets-monopage-1.pdf: -------------------------------------------------------------------------------- 1 | widgets-monopage.pdf -------------------------------------------------------------------------------- /test/golden/widgets-monopage.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-monopage.pdf -------------------------------------------------------------------------------- /test/golden/widgets-multipage-1.pdf: -------------------------------------------------------------------------------- 1 | widgets-multipage.pdf -------------------------------------------------------------------------------- /test/golden/widgets-multipage.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-multipage.pdf -------------------------------------------------------------------------------- /test/golden/widgets-newpage.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-newpage.pdf -------------------------------------------------------------------------------- /test/golden/widgets-opacity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-opacity.pdf -------------------------------------------------------------------------------- /test/golden/widgets-outline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-outline.pdf -------------------------------------------------------------------------------- /test/golden/widgets-partitions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-partitions.pdf -------------------------------------------------------------------------------- /test/golden/widgets-svg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-svg.pdf -------------------------------------------------------------------------------- /test/golden/widgets-table.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-table.pdf -------------------------------------------------------------------------------- /test/golden/widgets-text.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-text.pdf -------------------------------------------------------------------------------- /test/golden/widgets-theme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-theme.pdf -------------------------------------------------------------------------------- /test/golden/widgets-toc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-toc.pdf -------------------------------------------------------------------------------- /test/golden/widgets-watermark.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-watermark.pdf -------------------------------------------------------------------------------- /test/golden/widgets-wrap.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets-wrap.pdf -------------------------------------------------------------------------------- /test/golden/widgets.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DavBfr/dart_pdf/e0069ecd280df6cefb887f4f40d929b14f1c7231/test/golden/widgets.pdf -------------------------------------------------------------------------------- /test/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: readme_to_dart 2 | description: Readme Markdown to dart source converter. 3 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/test 4 | repository: https://github.com/DavBfr/dart_pdf 5 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues 6 | version: 1.0.0 7 | 8 | environment: 9 | sdk: ">=2.18.0 <4.0.0" 10 | flutter: ">=3.7.0" 11 | 12 | dependencies: 13 | args: 14 | flutter: 15 | sdk: flutter 16 | htmltopdfwidgets: 17 | markdown: 18 | meta: 19 | string_scanner: 20 | pdf: 21 | printing: 22 | path: 23 | image: 24 | path_provider: 25 | 26 | dependency_overrides: 27 | pdf: 28 | path: ../pdf 29 | printing: 30 | path: ../printing 31 | -------------------------------------------------------------------------------- /widget_wrapper/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | -------------------------------------------------------------------------------- /widget_wrapper/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.4 4 | 5 | - Add compatibility with Flutter 3.20.0-7.0.pre.48 6 | 7 | ## 1.0.3 8 | 9 | - Add compatibility with Flutter 3.19.0 10 | 11 | ## 1.0.2 12 | 13 | - Add compatibility with Flutter 3.18.0-1.0.pre.23 14 | 15 | ## 1.0.1 16 | 17 | - Add compatibility with Flutter 3.10 18 | 19 | ## 1.0.0 20 | 21 | - Initial release. 22 | -------------------------------------------------------------------------------- /widget_wrapper/README.md: -------------------------------------------------------------------------------- 1 | # pdf_widget_wrapper 2 | 3 | Plugin that allows embedding of Flutter Widgets into a PDF document. 4 | -------------------------------------------------------------------------------- /widget_wrapper/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | analyzer: 4 | errors: 5 | missing_required_param: warning 6 | missing_return: warning 7 | public_member_api_docs: ignore 8 | todo: ignore 9 | 10 | linter: 11 | rules: 12 | - always_put_control_body_on_new_line 13 | - avoid_bool_literals_in_conditional_expressions 14 | - avoid_classes_with_only_static_members 15 | - avoid_field_initializers_in_const_classes 16 | - avoid_slow_async_io 17 | - avoid_unused_constructor_parameters 18 | - avoid_void_async 19 | - cancel_subscriptions 20 | - directives_ordering 21 | - flutter_style_todos 22 | - no_adjacent_strings_in_list 23 | - omit_local_variable_types 24 | - prefer_asserts_in_initializer_lists 25 | - prefer_final_locals 26 | - prefer_foreach 27 | - prefer_if_elements_to_conditional_expressions 28 | - prefer_relative_imports 29 | - prefer_single_quotes 30 | - public_member_api_docs 31 | - sort_constructors_first 32 | - sort_pub_dependencies 33 | - sort_unnamed_constructors_first 34 | - test_types_in_equals 35 | - throw_in_finally 36 | - unnecessary_statements 37 | -------------------------------------------------------------------------------- /widget_wrapper/lib/pdf_widget_wrapper.dart: -------------------------------------------------------------------------------- 1 | export 'src/widget_wrapper.dart'; 2 | -------------------------------------------------------------------------------- /widget_wrapper/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pdf_widget_wrapper 2 | description: > 3 | Plugin that allows embedding of Flutter Widgets into a PDF document. 4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/widget_wrapper 5 | repository: https://github.com/DavBfr/dart_pdf 6 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues 7 | version: 1.0.4 8 | 9 | environment: 10 | sdk: ">=2.18.0 <4.0.0" 11 | flutter: ">=3.20.0-7.0.pre.48" 12 | 13 | dependencies: 14 | flutter: 15 | sdk: flutter 16 | pdf: ^3.10.0 17 | 18 | dependency_overrides: 19 | pdf: 20 | path: ../pdf 21 | 22 | dev_dependencies: 23 | flutter_lints: ^5.0.0 24 | flutter_test: 25 | sdk: flutter 26 | 27 | flutter: 28 | --------------------------------------------------------------------------------