Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

Building PDFium

Pieter van Ginkel edited this page Sep 28, 2016 · 5 revisions

Google changed their build system (again?), so new instructions.

The Pdfium project has instructions on how to get a build system up and running. These are located on https://pdfium.googlesource.com/pdfium/. To start, follow these steps until you get to gn args . option. The Pdfium project by default does not provide a shared library build script. This, and that we need to make a few additions to the project, requires you to make changes to the build script.

After you've followed the instructions until the gn args . command, make the following changes to the BUILD.gn file in the root of the Pdfium repo folder:

  • In the section config("pdfium_common_config"):
    • Add the following include path to the include_dirs list: "v8/include";
    • Add the following define to the defines list: "FPDFSDK_EXPORTS";
  • Change static_library("pdfium") to shared_library("pdfium") to build a shared library;
  • In the section shared_library("pdfium"):
    • Add the following source to the sources list: "fpdfsdk/pdfiumviewer.cpp".

These changes ensure that we're building a proper shared library and including the pdfiumviewer.cpp file as part of the compilation. This file is located in the repository in the directory Contrib and needs to be copied to the fpdfsdk folder.

After these preparations, the build can be done as normal.

First, we start with a x64 build; the default.

Run the following command:

gn args .

This will open a text editor. In the text editor, enter:

pdf_is_standalone = true
is_component_build = false
is_official_build = true
is_debug = false

If you don't want to include V8, or need Windows XP compatible libraries, also include the following flags:

pdf_enable_xfa = false
pdf_enable_v8 = false

This will update the Ninja scripts and will generate a few thousand error messages. Ignore those.

Then, build the pdfium.dll library:

ninja pdfium

This will output the pdfium.dll file into the root directory.

The x86 build is the same as the x64 build, except that the arguments to gn args . change. These become:

pdf_is_standalone = true
is_component_build = false
is_official_build = true
is_debug = false
target_cpu = "x86"

Again, if you don't want to include V8, or need Windows XP compatible libraries, also include the following flags:

pdf_enable_xfa = false
pdf_enable_v8 = false

Then, follow the same steps as for the x64 build to get the x86 pdfium.dll file.

Clone this wiki locally