Building PDFium - northwoodspd/PdfiumViewer GitHub Wiki
Because these build instructions depend heavily on Google's build system, they are likely to change with each version.
The Pdfium project has instructions on how to get a build system up and running. These are located here. Follow those steps until you get to the gn args <directory>
step (but don't run that command yet, switch back to these instructions).
Pull our fork of pdfium-binaries. Using a VS Dev command prompt, run build.bat
. It will pull down the Google repo for pdfium, do some setup, and then build it. You should end up with a zip file that looks very much like a nuget package. The pdfium.dll should be in there. It will be a 32-bit build, even though the default is 64-bit. This can be changed in the args.gn file if 64-bit is needed. Copy the pdfium.dll into the Libraries folder in this repo. After committing that, the TeamCity build will push out a nuget package to Artifactory. Update Pilot to use that updated package and you're good to go.
These instructions no longer apply, however they do describe what is needed so I'm leaving them here in case it helps with troubleshooting.
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 their build script.
After you've followed the instructions until the gn args <directory>
command, make the following changes in the Pdfium repo (not this one):
-
.\BUILD.gn
:- 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
component("pdfium")
toshared_library("pdfium")
to build a shared library;- In this same section, change
static_component_type = "static_library"
tostatic_component_type = "shared_library"
- In this same section, change
- In the section
-
.\fpdfsdk\BUILD.gn
:- In the section
source_set("fpdfsdk")
:- Add the following source to the
sources
list:"pdfiumviewer.cpp"
.
- Add the following source to the
- In the section
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 this repository in the directory Contrib
and needs to be copied to the fpdfsdk
folder.
After these preparations, the build can be done as follows.
From the root of the pdfium repo (not this one), run the following command:
gn args .
This will open a text editor. In the text editor, enter:
pdf_enable_xfa = false
pdf_enable_v8 = false
pdf_is_standalone = true
is_component_build = true
is_official_build = false
is_debug = false
target_cpu = "x86"
For a 64-bit version, don't include that last line for the
target_cpu
(or include it and replace the"x86"
with"x64"
. For a full list of options that can be used, try here
This will update the Ninja scripts and will generate a few thousand error messages. Ignore those. They'll look like this:
...
ERROR Input to target not generated by a dependency.
The file:
//third_party/zlib/zutil.c
is listed as an input or source for the target:
//third_party/zlib:zlib
but no targets in the build generate that file.
ERROR Input to targets not generated by a dependency.
The file:
//third_party/zlib/zutil.h
is listed as an input or source for the targets:
//third_party/zlib:zlib_common_headers
//third_party/zlib:zlib
but no targets in the build generate that file.
If you have generated inputs, there needs to be a dependency path between the
two targets in addition to just listing the files. For indirect dependencies,
the intermediate ones must be public_deps. data_deps don't count since they're
only runtime dependencies. If you think a dependency chain exists, it might be
because the chain is private. Try "gn path" to analyze.
2377 generated input errors found.
Then, build the pdfium.dll
library:
ninja pdfium
This will output the pdfium.dll
file into the root directory.