MAUI PDF Generation Library

PSPDFKit for MAUI is a library for generating PDF documents in an app without using a server. Newly created PDFs can be rendered in our viewer for signing, editing, form filling, and more.

Generating a PDF with a PDF Form

The following sections outline how to generate a PDF using a PDF form.

Filling PDF Form Fields Programmatically

PSPDFKit’s MAUI PDF library offers multiple options for filling form fields programmatically using the exposed JavaScript APIs, each with a different set of tradeoffs.

  • XFDF — For exporting to or importing from other readers.

  • Instant JSON — For the most efficient way to export or import changes made.

These APIs will be translated to native APIs in subsequent releases, so stay tuned for updates.

For more information on filling PDF form fields programmatically using JavaScript APIs, refer to our form filling guide.

Flattening Form Fields

The process of flattening form fields consists of rendering them over the background of a page with their current value and removing their data from the document.

For more information on flattening form fields, refer to our flattening guide.

Generating a PDF with Images

To generate a PDF using images, follow the steps below.

  1. While loading a document, you can pass an asset path, a local path, a URL, a byte array, or a Base64 string of an image into the loading function:

var documentFromAsset = 
    await PSPDFKitController.LoadDocumentFromAssetsAsync(imageAssetPath);

var documentFromLocalStorage = 
    await PSPDFKitController.LoadDocument(imagePath);

var documentFromBuffer = 
    await PSPDFKitController.LoadDocumentFromBufferAsync(imageBuffer);

var documentFromBase64String = 
    await PSPDFKitController.LoadDocumentFromBase64StringAsync(imageAsBase64String);
var documentFromRemoteUrl = 
    await PSPDFKitController.LoadDocumentFromURLAsync(remoteImageURL);
  1. Optionally, make changes to the image. For example, add an annotation.

  2. To export a loaded image as a PDF, use the ExportDocumentAsync function:

var exportConfiguration = _document.CreateExportConfiguration();
var exportedDocumentAsPDF = await _document.ExportDocumentAsync(exportConfiguration);

When exporting a document, you have several options. Refer to our export configuration guide for more details.

  1. Save the output. The export method returns a byte array, which can be saved to a file or sent to a server.