flutter_native_html_to_pdf 3.0.0 copy "flutter_native_html_to_pdf: ^3.0.0" to clipboard
flutter_native_html_to_pdf: ^3.0.0 copied to clipboard

A Flutter plugin that uses native WebView (Android WebView / iOS WKWebView) to render HTML and convert it to a high-quality PDF file.

3.0.0 BREAKING CHANGE #

Major Changes #

  • Migrated to Native WebView Rendering: The package now uses native platform WebView (Android WebView / iOS WKWebView) for HTML rendering and PDF generation
  • Architecture Change: Reverted from pure Dart implementation (v2.x) back to native code for improved rendering quality and CSS support
  • Removed Dependencies: No longer depends on pdf and html packages
  • Enhanced Platform Support: Better leverages native capabilities for more accurate HTML-to-PDF conversion

Implementation Details #

  • Added native Android implementation using Android WebView
  • Added native iOS implementation using WKWebView
  • Updated HtmlToPdfConverter to use platform channels for native PDF generation
  • Removed custom HTML parser (html_parser.dart) in favor of native WebView rendering

Tests #

  • Updated unit tests to mock native method calls
  • Maintained test coverage for PDF generation functionality

Migration Notes #

Version 3.0.0 returns to using native platform code, which provides better rendering quality and CSS support compared to the pure Dart implementation in v2.x. The API remains largely the same, but the underlying implementation now requires Android and iOS platforms.


2.0.3 #

  • Fixed incorrect percentage value parsing in _parseDimension method
  • Percentage values (e.g., width: 70%, border-radius: 50%) were being converted to incorrect fixed pixel values
  • Now returns null for percentage values since they require layout context that's not available at parse time
  • Prevents incorrect rendering of elements with percentage-based styling

2.0.2 #

  • Add support for border-radius, width, height, and min-height CSS properties

Bug Fix (2.0.2 Patch):

2.0.1 #

Bug Fixes #

  • Fixed PDF rendering width: Block-level elements (<div> and <p>) with background colors or borders now span the full page width in generated PDFs, matching browser behavior
    • Previously, elements with background-color CSS property only wrapped their content width
    • Now containers expand to full available width when background colors or borders are present
    • Fixes issue where yellow highlighted sections and bordered elements appeared narrow in PDFs

Tests #

  • Added comprehensive test coverage for full-width background and border rendering

2.0.0 BREAKING CHANGE #

Major Changes #

  • Migrated to Pure Dart: The package no longer uses native code (iOS, Android, etc.) and is now 100% Dart
  • New Main Class: Use HtmlToPdfConverter instead of FlutterNativeHtmlToPdf
  • No Flutter Dependency: Package can now be used in pure Dart applications
  • Cross-platform: Now supports all platforms including macOS and web

New Features #

  • Added PdfPageSize.fromMillimeters() factory for creating page sizes from millimeter values
  • Added PdfPageSize.fromInches() factory for creating page sizes from inch values
  • Added PdfPageSize.landscape and PdfPageSize.portrait getters for orientation conversion
  • Added PdfPageSize.b5 and PdfPageSize.executive predefined page sizes
  • Return types are now non-nullable (File and Uint8List instead of File? and Uint8List?)

Migration Guide #

// Old (v1.x)
final plugin = FlutterNativeHtmlToPdf();
final pdfFile = await plugin.convertHtmlToPdf(...);

// New (v2.x)
final converter = HtmlToPdfConverter();
final pdfFile = await converter.convertHtmlToPdf(...);

Deprecated #

  • FlutterNativeHtmlToPdf class is deprecated. Use HtmlToPdfConverter instead.

1.1.6 #

  • Refactor iOS code to support scene-based root view controller retrieval and update Info.plist for scene configuration
  • Enhance PDF sharing functionality with improved metadata and file handling

1.1.5 #

  • Refactor code for improved readability by removing unnecessary blank lines and formatting adjustments across multiple files

1.1.4 #

  • Refactor PDF generation code by removing debug print statements and improving file path construction

1.1.3 #

  • Fix PDF generation null return by adding early return after failure callback

1.1.2 #

  • Fix iOS 26 compatibility: Fixed crash on iOS 26 caused by missing WKNavigationDelegate policy methods
  • Added decidePolicyForNavigationAction and decidePolicyForNavigationResponse delegate methods
  • These methods are now required by WebKit in iOS 26 to properly load HTML
  • Fixed issue sharing file cannot share in example project (Found in iOS 26)

1.1.1 #

  • Fix iOS color and font rendering: HTML to PDF conversion on iOS now properly renders CSS colors and custom fonts
  • Changed base URL in iOS from Bundle.main.bundleURL to "https://" to match Android behavior
  • Added PDF context attributes for better color rendering in iOS
  • Configured WKWebView with isOpaque = false and clear background for improved CSS support
  • Updated example app with enhanced HTML demonstrating colors and font styles

1.1.0 #

  • Add convertHtmlToPdfBytes method to convert HTML to PDF as Uint8List without saving to a file
  • Improved performance for use cases that don't require saving PDF to disk
  • Added support for direct PDF bytes manipulation in Android and iOS native implementations
  • Updated example app to demonstrate both file-based and bytes-based conversion

1.0.0 #

  • Initial release.
15
likes
150
points
5.58k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin that uses native WebView (Android WebView / iOS WKWebView) to render HTML and convert it to a high-quality PDF file.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_native_html_to_pdf

Packages that implement flutter_native_html_to_pdf