Generate a blank PDF in Flutter
PDF generation is available only on the legacy method-channel API (package:nutrient_flutter/nutrient_flutter.dart), which is deprecated in Nutrient Flutter SDK 6. The APIs on this page aren’t part of the bindings API yet. They still work in SDK 6; import the legacy library to use them alongside bindings.dart if you use both. Nutrient plans to add a bindings equivalent. In the meantime, refer to the platform adapters guide to use native processors. For details, refer to the Flutter SDK 6 migration guide.
Use Nutrient(opens in a new tab) to create blank PDF documents.
The following example creates a new one-page blank PDF document from a NewPage object(opens in a new tab). A NewPage object can define the page size, colors, patterns, images, and pages from other documents. After processing, Nutrient saves the new blank document to outputPath:
// Location where to save the generated PDF.String outputPath = '<writable-output-path>';
List<NewPage> pages = [ // `NewPage` from blank PDF pattern. NewPage.fromPattern( PagePattern.blank, pageSize: PageSize.a5),];
// Generate blank PDF document.var filePath = await Nutrient.generatePdf(pages, outputPath);For more information about generating PDF files from HTML strings and URLs, refer to the Nutrient(opens in a new tab) API reference and the PDF generation example(opens in a new tab) from the Catalog app(opens in a new tab).