-
Notifications
You must be signed in to change notification settings - Fork 422
Building PDFium
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"
;
- Add the following include path to the
- Change
static_library("pdfium")
toshared_library("pdfium")
to build a shared library; - In the section
shared_library("pdfium")
:- Add the following source to the
sources
list:"fpdfsdk/pdfiumviewer.cpp"
.
- Add the following source to the
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.