Skip to content

PDFium - Project to compile PDFium library to multiple platforms.

License

Notifications You must be signed in to change notification settings

checkersoftware/pdfium-lib

 
 

Repository files navigation

PDFium Library Logo

PDFium Library

PDFium - iOS PDFium - macOS PDFium - Android PDFium - WASM

Project to compile PDFium library to multiple platforms.

How to compile for Checker Software use cases

We are only going to use the wasm binaries for our purposes. You can either utilize a Ubuntu 20.04/22.04/24.04 instance or run a docker container instance. Note that the minor ver .04 is important here as compiling it on a different minor .10 will not work. Alternatively use the docker container to setup the compiling environment beforehand.

NOTE: STEPS 1-3 IS ONLY REQUIRED TO BE RAN ONCE. OTHER STEPS MUST BE RAN EVERY TIME FOR A BUILD.

  1. Get the source, make sure that it is commit(s) ahead of upstream with addFunction, removeFunction, and -sALLOW_TABLE_GROWTH part of the wasm compilation exports.
git clone https://github.com/checkersoftware/pdfium-lib.git
cd pdfium-lib
Docker setup for if you are not using a standalone Ubuntu distro.

  1. Build the image with command (this is for macbooks with M series processors):
docker build --platform linux/amd64 -t pdfium-wasm -f docker/wasm/Dockerfile docker/wasm
  1. Now you can open an interactive shell for the container with:
docker run --platform linux/amd64 -v ${PWD}:/app -it pdfium-wasm

Run the rest of the commands in this interactive shell.




  1. Install PIP requirements:
python3 -m pip install -r requirements.txt
  1. Get Google Depot Tools:
python3 make.py build-depot-tools
export PATH=$PATH:$PWD/build/depot-tools

From here forth only these steps need to be ran for compilation.

  1. Get Emscripten SDK: python3 make.py build-emsdk

  2. Execute EMSDK environment file "emsdk_env" according to your system. For us this should be /emsdk/emsdk_env.sh

  3. Get PDFium: python3 make.py build-pdfium-wasm

  4. Patch: python3 make.py patch-wasm

  5. PDFium Linux dependencies ./build/wasm32/pdfium/build/install-build-deps.sh

  6. Compile: python3 make.py build-wasm

  7. Install libraries: python3 make.py install-wasm

  8. Test: python3 make.py test-wasm

  9. Generate javascript libraries: python3 make.py generate-wasm

At this point you should be able to find pdfium.js and pdfium.wasm inside ./build/wasm32/wasm/release/node, those replace the current pdfium.js and pdfium.wasm files in our projects.




Platforms

This project currently compiles to these platforms:

  • iOS device (arm64)
  • iOS simulator (x86_64, arm64)
  • Android (armv7, armv8, x86, x86_64)
  • macOS (x86_64, arm64)
  • WASM (Web Assembly)

Platforms in roadmap:

  • Linux
  • Windows

Obs: PDFium project is from Google and i only patch it to compile to all platforms above. Check all oficial details and PDFium license here:

https://pdfium.googlesource.com/

Web demo

Since this project generate WASM version, i published a demo that you can test PDFium direct on web browser here:

https://pdfviewer.github.io

Or with a public PDF as parameter:

https://pdfviewer.github.io/?title=Demo%20PDF%20with%201MB&url=https://raw.githubusercontent.com/mozilla/pdf.js-sample-files/master/tracemonkey.pdf

Requirements

  1. Ninja Build
  2. Python 3
  3. PIP

Obs: Generally Python 3 already come with PIP installed. Check it with command python3 -m pip --version.

Prebuilt binary

Access releases page to download prebuilt binaries:

https://github.com/paulocoutinhox/pdfium-lib/releases

How to include files and extend pdfium

Check tutorial here: How to include files

Buy me a coffee

Support the continuous development of this project.

Buy Me a Coffee at ko-fi.com

My other projects

License

This license informations is about this personal project, not the Google PDFium Library.

MIT

Copyright (c) 2018-2024, Paulo Coutinho

About

PDFium - Project to compile PDFium library to multiple platforms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 46.0%
  • HTML 33.7%
  • Swift 6.4%
  • Objective-C 5.9%
  • Dockerfile 4.2%
  • JavaScript 1.9%
  • C++ 1.9%