MohamedRejeb/pdfium-patched

Binary distribution of PDFium with some patches to expose useful APIs

★ 0Forks 0CGitHub ↗Compare

README

pdfium-patched

Build-and-distribute pipeline for Google's PDFium with a small additive patch set that exposes a few internal C++ accessors as FPDF_EXPORT C symbols. Releases are drop-in compatible with bblanchon/pdfium-binaries so any downstream Gradle / CMake build that today consumes bblanchon's binaries can switch by URL only.

Consuming releases

Each tag publishes one tgz per platform under https://github.com/MohamedRejeb/pdfium-patched/releases/download/<tag>/pdfium-<target>.tgz (filename pattern mirrors bblanchon/pdfium-binaries).

Targets: mac-arm64, mac-x64, linux-x64, win-x64. Mac / Linux tgz layout:

LICENSE              # PDFium's upstream license
VERSION              # one line: <pdfium-tag>+rejeb.<patches-rev>
lib/libpdfium.{dylib|so}
include/
  fpdfview.h, fpdf_annot.h, ...   # all upstream public/*.h
  cpp/fpdf_deleters.h, ...        # public/cpp/*.h
  fpdf_rejeb.h                    # additional FPDF_EXPORT declarations from this repo

Windows splits the runtime DLL and import library across bin/ and lib/ — same as bblanchon's layout:

bin/pdfium.dll
lib/pdfium.dll.lib   # MSVC import library

Gradle example (mirrors a bblanchon-style download task):

val downloadUrl = "https://github.com/MohamedRejeb/pdfium-patched/releases/download/v${pdfiumVersion}+rejeb.${patchesVersion}/pdfium-$os-$arch.tgz"

Building locally

Prerequisites

  • depot_tools on PATH — provides gn, ninja, gclient. Verify with which gn ninja gclient.
  • macOS: Xcode 15+ command-line tools, Python 3.
  • Linux: apt install build-essential python3 git curl pkg-config libfontconfig1-dev.
  • Windows: Visual Studio 2022 with Desktop C++ workload, Python 3.

Steps

export PDFIUM_PATCHED_ROOT="$(pwd)"

./scripts/01-fetch-pdfium.sh                  # gclient sync to pinned commit
./scripts/02-apply-patches.sh                 # git apply patches/*.patch
./scripts/03-configure.sh mac-arm64           # gn gen with args/<target>.args.gn
./scripts/04-build.sh mac-arm64               # ninja + smoke-test + package into dist/<target>/

Pick mac-arm64 | mac-x64 | linux-x64 | win-x64 for the target argument. Output lands in dist/<target>/{lib,include}/.

./scripts/02-apply-patches.sh resets the PDFium working tree (git reset --hard && git clean -fd) before applying — re-running is safe but destroys any manual edits inside pdfium/.

Authoring a new patch

  1. Manually clone PDFium at the pinned commit, make the change, commit it, then git format-patch -1 to produce the .patch file.
  2. Verify the C++ accessor you're wrapping actually exists at the pinned commit — PDFium internals shift between Chromium milestones.
  3. Look at how existing fpdfsdk/fpdf_*.cpp files convert FPDF_PAGEOBJECT → CPDF_PageObject* (CPDFPageObjectFromFPDFPageObject) and follow the same pattern.
  4. Number the patch sequentially (0001-…, 0002-…).
  5. Add the new declarations to include/fpdf_rejeb.h — 02-apply-patches.sh copies this file into PDFium's public/.
  6. Bump PATCHES_VERSION and tag with the new +rejeb.N.

Conventions (non-negotiable)

  • Naming: all new exports prefixed FPDFRejeb_ to stay out of upstream's namespace.
  • One concept per patch: patches apply in lexical order; bundling capabilities makes selective rebases impossible.
  • Additive by default: new files only (fpdfsdk/fpdf_rejeb.cpp, public/fpdf_rejeb.h) plus a one-line addition to fpdfsdk/BUILD.gn. A patch modifies upstream files only where no export can do the job, and says why in its header: 0015 and 0019 fix losses in the content generator, 0017 makes the content parser record where each object sits in its stream.

infra/ vs patches/

  • infra/ holds build-pipeline patches (always applied; not counted in PATCHES_VERSION) — vendored from bblanchon/pdfium-binaries for drop-in compatibility. Re-vendor on PDFium bumps if upstream drifts in the patched files. See infra/NOTICE.
  • patches/ holds feature patches that bump PATCHES_VERSION. Each adds one FPDFRejeb_* capability or fixes one upstream defect.

License

BSD 3-Clause for this repository. PDFium itself is BSD 3-Clause and ships its own license alongside the binary release artifacts. See LICENSE.

Contributors

MohamedRejeb

Issues