Migration guides/Apryse (PDFTron)

Migrate from Apryse to PDFluent

A step-by-step guide for replacing Apryse (PDFTron) with PDFluent. Covers dependency setup, license initialization, text extraction, form filling, and saving.

Migrating from Apryse (PDFTron) to PDFluent. Install with cargo add pdfluent

Migration steps

1

Remove the Apryse NuGet package and DLL dependency

Apryse ships a native C++ DLL (PDFNetC.dll on Windows, libPDFNetC.so on Linux) alongside the managed wrapper. Remove both and add pdfluent to Cargo.toml.

Apryse (PDFTron) (before)
<!-- .csproj -->
<PackageReference Include="PDFTron.NET" Version="10.4.0" />
<!-- Also requires PDFNetC.dll in your output directory -->
PDFluent (after)
# Cargo.toml
[dependencies]
pdfluent = "0.9"
2

Remove license initialization

Apryse requires calling PDFNet.Initialize() with a license key before any API use. PDFluent reads the license from an environment variable or config file.

Apryse (PDFTron) (before)
using Apryse;

// Must call before any Apryse API
PDFNet.Initialize("YOUR_LICENSE_KEY_HERE");
PDFluent (after)
// Set PDFLUENT_LICENSE env var, or configure in pdfluent.toml
// No explicit initialization call required
3

Open a document and extract text

Apryse uses PDFDoc plus TextExtractor. PDFluent uses Document::open and page.extract_text().

Apryse (PDFTron) (before)
using Apryse;

using var doc = new PDFDoc("invoice.pdf");
doc.InitSecurityHandler();

var page = doc.GetPage(1);
var extractor = new TextExtractor();
extractor.Begin(page);
string text = extractor.GetAsText();
Console.WriteLine(text);
PDFluent (after)
use pdfluent::Document;

let doc = Document::open("invoice.pdf")?;
let text = doc.page(0)?.extract_text()?;
println!("{}", text);
4

Fill form fields

Apryse uses doc.GetField() to retrieve and set individual field values. PDFluent uses an acroform handle.

Apryse (PDFTron) (before)
using var doc = new PDFDoc("form.pdf");
doc.InitSecurityHandler();

var field = doc.GetField("company_name");
field.SetValue("Acme Corp");

var dateField = doc.GetField("contract_date");
dateField.SetValue("2024-04-14");

doc.Save("form_filled.pdf", SDFDoc.SaveOptions.e_linearized);
PDFNet.Terminate();
PDFluent (after)
let mut doc = Document::open("form.pdf")?;

let mut form = doc.acroform()?;
form.set_field("company_name", "Acme Corp")?;
form.set_field("contract_date", "2024-04-14")?;

doc.save("form_filled.pdf")?;
5

Save the document

Apryse Save() takes a SaveOptions flags enum. PDFluent save() writes to the output path with sane defaults.

Apryse (PDFTron) (before)
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
PDFNet.Terminate(); // must clean up
PDFluent (after)
doc.save("output.pdf")?;
// Rust drops doc automatically

Things to watch out for

  • !Apryse uses 1-based page indexing (GetPage(1) is page 1). PDFluent uses 0-based indexing (page(0) is page 1).
  • !Apryse requires PDFNet.Initialize() before any call. Forgetting this causes a runtime panic. PDFluent has no equivalent requirement.
  • !Apryse's WebViewer (JavaScript viewer product) has no direct PDFluent equivalent. PDFluent WASM can power a custom viewer.

Frequently asked questions