It turns out I also would like to deprecate
FPDF_InitLibraryWithConfig(), as it uses FPDF_LIBRARY_CONFIG, which is
a struct that is directly exposed to embedders. The struct can be
hard/annoying to change. For instance:
- Any field change should result in a version update. If PDFium
developers accidentally forget, embedders may have a bad time. (See
also next point)
- Adding a new field to FPDF_LIBRARY_CONFIG can potentially result in
an embedder passing in a config with the new field uninitialized.
- Fields in the struct must be annotated with the versions they are valid for.
- FPDF_InitLibraryWithConfig() needs to be able to parse all supported
config versions, which can become complex over time as the number of
fields increases.
While it is possible to work with the existing way of doing init, and
do versioning on FPDF_LIBRARY_CONFIG, there are potentially better
alternatives. I would like to have an opaque config object, instead of
FPDF_LIBRARY_CONFIG, just as PDFium exposes FPDF_DOCUMENT and not the
underlying class that implements a document. Along with a set of APIs
to modify the config, and a new library init function that takes the
opaque config object, they can fully replace
FPDF_InitLibraryWithConfig(). Then init config changes become public
API changes, which goes through the same experimental / stable /
deprecated lifecycle like any other public API. To put this more
concretely,
https://pdfium-review.googlesource.com/c/pdfium/+/97151/1/
is a work-in-progress CL to implement such an object and associated
APIs.
One additional change is the proposed init function returns a bool to
indicate whether initialization succeeded or not. (Maybe it should
become an error code...) It gives PDFium an opportunity to signal to
the embedder if something goes wrong during initialization. If PDFium
ever changes to require some initialization data from the embedder,
the return value can help let the embedder know about that.