flutter_native_html_to_pdf
3.1.0, released 6 months ago by an unverified publisher
Render HTML content to high-quality PDF files or bytes using native WebViews.
What it does
Converts HTML and CSS content into PDF files or raw byte arrays using native platform components (Android WebView and iOS WKWebView). Provides full support for modern CSS properties, images, and custom page sizes.
AI-written summary of version 3.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to generate professional PDFs from HTML and CSS templates.
- You require accurate rendering with full CSS support including flexbox, grids, and custom fonts.
- You want to convert HTML directly to Uint8List bytes without saving to a file.
Skip it when
- You are targeting platforms other than Android and iOS.
- You need a pure Dart HTML-to-PDF rendering solution without native platform dependencies.
Strengths
- Full CSS3 and modern layout support via native WebViews.
- Supports both file saving and direct byte array conversion.
- Configurable page sizes including A4, Letter, and custom dimensions.
Weaknesses
- Limited to Android and iOS platforms.
- Requires platform-specific configuration for external resources like images (such as internet permissions).
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Requires adding INTERNET permission on Android and AppTransportSecurity configurations on iOS if loading external images.
import 'package:flutter_native_html_to_pdf/flutter_native_html_to_pdf.dart';
import 'package:path_provider/path_provider.dart';
final converter = HtmlToPdfConverter();
const htmlContent = """
<!DOCTYPE html>
<html>
<head><title>Sample PDF</title></head>
<body>
<h1>Hello World!</h1>
<p>This is a sample PDF.</p>
</body>
</html>
""";
Directory appDocDir = await getApplicationDocumentsDirectory();
final pdfFile = await converter.convertHtmlToPdf(
html: htmlContent,
targetDirectory: appDocDir.path,
targetName: "my_document",
);Alternatives
Packages that do the same job and could replace flutter_native_html_to_pdf.
- native_pdf_view
Flutter plugin to render and display PDF files across Web, macOS, Windows, Android, and iOS.
50Compare - htmltopdfwidgets
Converts HTML and Markdown content into high-quality PDF widgets.
81Compare - file_selector_macos
macOS implementation of the file_selector plugin
82Compare - syncfusion_flutter_pdf
Native Dart library for creating, reading, editing, and securing PDF files.
89Compare