-
-
Notifications
You must be signed in to change notification settings - Fork 150
pdfrx Initialization
If you use Flutter widgets like PdfViewer or PdfDocumentViewBuilder, they implicitly initialize the library by calling pdfrxFlutterInitialize.
But if you use PdfDocument directly, you should explicitly do either one of the following ways:
The first one is the recommended and the easiest way to initialize Flutter app.
For pure Dart apps (or even some of Flutter apps), you can use pdfrxInitialize.
Basically, these initialization functions do the following things:
- Set Pdfrx.getCacheDirectory
- Map PdfDocument factory/interop functions to actual platform ones
- Set Pdfrx.loadAsset (Flutter only)
- Download PDFium binary on-demand (pdfrxInitialize only)
The mechanism to locate cache directory is different between pure Dart apps and Flutter apps:
| Init. Func. | Underlying API | Notes |
|---|---|---|
| pdfrxInitialize | Directory.systemTemp | May not be suitable for mobile apps. |
| pdfrxFlutterInitialize | path_provider.getTemporaryDirectory | Always app local directory. |
For pure Dart apps, because it is typically used on desktop environments, pdfrx downloads PDFium binary if your environment does not have it.
- PDFium binaries are downloaded from https://github.com/bblanchon/pdfium-binaries/releases
- By default, the binary is downloaded to
[TMP_DIR]/pdfrx.cache - You can explicitly specify
libpdfiumshared library file path/name byPDFIUM_PATHenvironment variable
This document is for pdfrx 1.X.X versions. For the latest version, see doc/README.md