- Notifications
You must be signed in to change notification settings - Fork94
The PDF library used by the Chromium project
License
chromium/pdfium
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PDFium uses the same build tooling as Chromium. See the platform-specificChromium build instructions to get started, but replace Chromium's"Get the code" instructions withPDFium's.
The default architecture for Windows, Linux, and Mac is "x64
". On Windows,"x86
" is also supported. GN parameter "target_cpu = "x86"
" can be used tooverride the default value. If you specify Android build, the default CPUarchitecture will be "arm
".
It is expected that there are still some places lurking in the code which willnot function properly on big-endian architectures. Bugs and/or patches arewelcome, however providing this support isnot a priority at this time.
PDFium aims to be compliant with theChromium policy.
Currently this means Clang. Former MSVC users should consider using clang-clif needed. Community-contributed patches for gcc will be allowed. No MSVCpatches will be taken.
Run:download_from_google_storage --config
and follow theauthentication instructions.Note that you must authenticate with your@google.com credentials. Enter "0" if asked for a project-id.
Once you've done this, the toolchain will be installed automatically foryou in theGenerate the build files step below.
The toolchain will be indepot_tools\win_toolchain\vs_files\<hash>
, andwindbg can be found indepot_tools\win_toolchain\vs_files\<hash>\win_sdk\Debuggers
.
If you want the IDE for debugging and editing, you will need to installit separately, but this is optional and not needed for building PDFium.
The name of the top-level directory does not matter. In the following example,the directory name is "repo". This directory must not have been used before bygclient config
as each directory can only house a single gclientconfiguration.
mkdir repocd repogclient config --unmanaged https://pdfium.googlesource.com/pdfium.gitgclient synccd pdfium
On Linux, additional build dependencies need to be installed by running thefollowing from thepdfium
directory.
./build/install-build-deps.sh
PDFium uses GN to generate the build files andNinjato execute the build files. Both of these are included with thedepot_tools checkout.
PDFium may be built either with or without JavaScript support, and withor without XFA forms support. Both of these features are enabled bydefault. Also note that the XFA feature requires JavaScript.
Configuration is done by executinggn args <directory>
to configure the build.This will launch an editor in which you can set the following arguments.By convention,<directory>
should be namedout/foo
, and some tools / testsupport code only works if one follows this convention.A typical<directory>
name isout/Debug
.
use_remoteexec = false # Approved users only. Do necessary setup & authentication first.is_debug = true # Enable debugging features.# Set true to enable experimental Skia backend.pdf_use_skia = false# Set true to enable experimental Fontations backend.pdf_enable_fontations = falsepdf_enable_xfa = true # Set false to remove XFA support (implies JS support).pdf_enable_v8 = true # Set false to remove Javascript support.pdf_is_standalone = true # Set for a non-embedded build.is_component_build = false # Disable component build (Though it should work)
For test applications likepdfium_test
to build, one must setpdf_is_standalone = true
.
By default, the entire project builds with C++20.
By default, PDFium expects to build with a clang compiler that providesadditional chrome plugins. To build against a vanilla one lacking these,one must setclang_use_chrome_plugins = false
.
When complete the arguments will be stored in<directory>/args.gn
, andGN will automatically use the new arguments to generate build files.Should your files fail to generate, please double-check that you have setuse_sysroot as indicated above.
You can build the standalone test program by running:ninja -C <directory> pdfium_test
You can build the entire product (which includes a few unit tests) by running:ninja -C <directory> pdfium_all
The pdfium_test program supports reading, parsing, and rasterizing the pages ofa .pdf file to .ppm or .png output image files (Windows supports two otherformats). For example:<directory>/pdfium_test --ppm path/to/myfile.pdf
. Notethat this will write output images topath/to/myfile.pdf.<n>.ppm
.Runpdfium_test --help
to see all the options.
There are currently several test suites that can be run:
- pdfium_unittests
- pdfium_embeddertests
- testing/tools/run_corpus_tests.py
- testing/tools/run_javascript_tests.py
- testing/tools/run_pixel_tests.py
It is possible the tests in thetesting
directory can fail due to fontdifferences on the various platforms. These tests are reliable on the bots. Ifyou see failures, it can be a good idea to run the tests on the tip-of-treecheckout to see if the same failures appear.
If your change affects rendering, a pixel test should be added. Simply add a.in
or.pdf
file intesting/resources/pixel
and the pixel runner willpick it up at the next run.
Make sure that your test case doesn't have any copyright issues. It should alsobe a minimal test case focusing on the bug that renders the same way in manyPDF viewers. Try to avoid binary data in streams by using theASCIIHexDecode
simply because it makes the PDF more readable in a text editor.
To try out your new test, you can call therun_pixel_tests.py
script:
$ ./testing/tools/run_pixel_tests.py your_new_file.in
To generate the expected image, you can use themake_expected.sh
script:
$ ./testing/tools/make_expected.sh your_new_file.pdf
Please make sure to haveoptipng
installed which optimized the file size ofthe resulting png.
.in
files are PDF template files. PDF files contain many byte offsets thathave to be kept correct or the file won't be valid. The template makes thiseasier by replacing the byte offsets with certain keywords.
This saves space and also allows an easy way to reduce the test case to theessentials as you can simply remove everything that is not necessary.
A simple example can be foundhere.
To transform this into a PDF, you can use thefixup_pdf_template.py
tool:
$ ./testing/tools/fixup_pdf_template.py your_file.in
This will create ayour_file.pdf
in the same directory asyour_file.in
.
There is no official style guide for the .in file, but a consistent style ispreferred simply to help with readability. If possible, object numbers shouldbe consecutive and/Type
and/SubType
should be on top of a dictionary tomake object identification easier.
The public/ directory contains header files for the APIs available for use byembedders of PDFium. The PDFium project endeavors to keep these as stable aspossible.
Outside of the public/ directory, code may change at any time, and embeddersshould not directly call these routines.
Code coverage reports for PDFium can be generated in Linux developmentenvironments. Details can be foundhere.
Chromium provides code coverage reports for PDFiumhere. PDFium is located inthird_party/pdfium
in Chromium's source code.This includes code coverage from PDFium's fuzzers.
The current health of the source tree can be foundhere.
There are several mailing lists that are setup:
Note, the Reviews and Bugs lists are typically read-only.
PDFium uses thisbug tracker, but for securitybugs, please useChromium's security bug template.
See theCONTRIBUTING document for more information oncontributing to the PDFium project.
About
The PDF library used by the Chromium project
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.