• Home
Name Date Size #Lines LOC

..--

build/03-May-2024-86

build_overrides/03-May-2024-141110

constants/03-May-2024-279167

core/03-May-2024-287,832262,368

docs/03-May-2024-523396

fpdfsdk/03-May-2024-50,56939,654

fxbarcode/03-May-2024-13,47110,058

fxjs/03-May-2024-36,36329,186

public/03-May-2024-8,2172,321

samples/03-May-2024-2,4252,063

skia/03-May-2024-803539

testing/03-May-2024-38,48634,684

third_party/03-May-2024-190,981132,006

tools/03-May-2024-163123

xfa/03-May-2024-92,28673,402

.clang-formatD03-May-202481 32

.gitattributesD03-May-2024524 2725

.gnD03-May-2024810 3631

.vpythonD03-May-20241.5 KiB3935

AUTHORSD03-May-20241.9 KiB6057

Android.bpD03-May-20242.3 KiB11594

BUILD.gnD03-May-20247.7 KiB375335

DEPSD03-May-20249.6 KiB292261

LICENSED03-May-202412.6 KiB231196

MODULE_LICENSE_BSDD03-May-20240

NOTICED03-May-20241.5 KiB2827

PRESUBMIT.pyD03-May-202412 KiB324246

README.mdD03-May-202410.1 KiB273193

TEST_MAPPINGD03-May-202487 87

codereview.settingsD03-May-2024309 98

navbar.mdD03-May-2024343 156

pdfium.gniD03-May-20242.3 KiB7855

update_pdfium.pyD03-May-20244.2 KiB13696

README.md

1# PDFium
2
3## Prerequisites
4
5Get the Chromium depot\_tools via the
6[instructions](https://www.chromium.org/developers/how-tos/install-depot-tools).
7This provides the gclient utility needed below and many other tools needed for
8PDFium development.
9
10Also install Python, Subversion, and Git and make sure they're in your path.
11
12
13### Windows development
14
15PDFium uses the same build tool as Chromium:
16
17#### Open source contributors
18Please refer to
19[Chromium's Visual Studio set up](https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#visual-studio)
20for requirements and instructions on build environment configuration.
21
22Run `set DEPOT_TOOLS_WIN_TOOLCHAIN=0`, or set that variable in your global
23environment.
24
25Compilation is done through Ninja, **not** Visual Studio.
26
27### CPU Architectures supported
28
29The default architecture for Windows, Linux, and Mac is "`x64`". On Windows,
30"`x86`" is also supported. GN parameter "`target_cpu = "x86"`" can be used to
31override the default value. If you specify Android build, the default CPU
32architecture will be "`arm`".
33
34It is expected that there are still some places lurking in the code which will
35not function properly on big-endian architectures. Bugs and/or patches are
36welcome, however providing this support is **not** a priority at this time.
37
38#### Google employees
39
40Run: `download_from_google_storage --config` and follow the
41authentication instructions. **Note that you must authenticate with your
42@google.com credentials**. Enter "0" if asked for a project-id.
43
44Once you've done this, the toolchain will be installed automatically for
45you in the [Generate the build files](#GenBuild) step below.
46
47The toolchain will be in `depot_tools\win_toolchain\vs_files\<hash>`, and
48windbg can be found in
49`depot_tools\win_toolchain\vs_files\<hash>\win_sdk\Debuggers`.
50
51If you want the IDE for debugging and editing, you will need to install
52it separately, but this is optional and not needed for building PDFium.
53
54## Get the code
55
56The name of the top-level directory does not matter. In our examples, we use
57"repo". This directory must not have been used before by `gclient config` as
58each directory can only house a single gclient configuration.
59
60```
61mkdir repo
62cd repo
63gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
64gclient sync
65cd pdfium
66```
67
68Additional build dependencies need to be installed by running the following from
69the `pdfium` directory.
70
71```
72./build/install-build-deps.sh
73```
74
75## Generate the build files
76
77We use GN to generate the build files and [Ninja](https://ninja-build.org/)
78to execute the build files.  Both of these are included with the
79depot\_tools checkout.
80
81### Selecting build configuration
82
83PDFium may be built either with or without JavaScript support, and with
84or without XFA forms support.  Both of these features are enabled by
85default. Also note that the XFA feature requires JavaScript.
86
87Configuration is done by executing `gn args <directory>` to configure the build.
88This will launch an editor in which you can set the following arguments.
89By convention, `<directory>` should be named `out/foo`, and some tools / test
90support code only works if one follows this convention.
91A typical `<directory>` name is `out/Debug`.
92
93```
94use_goma = true  # Googlers only. Make sure goma is installed and running first.
95is_debug = true  # Enable debugging features.
96
97# Set true to enable experimental Skia backend.
98pdf_use_skia = false
99# Set true to enable experimental Skia backend (paths only).
100pdf_use_skia_paths = false
101
102pdf_enable_xfa = true  # Set false to remove XFA support (implies JS support).
103pdf_enable_v8 = true  # Set false to remove Javascript support.
104pdf_is_standalone = true  # Set for a non-embedded build.
105is_component_build = false # Disable component build (Though it should work)
106
107clang_use_chrome_plugins = false  # Currently must be false.
108```
109
110For sample applications like `pdfium_test` to build, one must set
111`pdf_is_standalone = true`.
112
113By default, the entire project builds with C++14, because features like V8
114support, XFA support, and the Skia backend all have dependencies on libraries
115that require C++14. If one does not need any of those features, and need to fall
116back to building in C++11 mode, then set `use_cxx11 = true`. This fallback is
117temporary and will go away in the future when PDFium fully transitions to C++14.
118See [this bug](https://crbug.com/pdfium/1407) for details.
119
120When building with the experimental Skia backend, Skia itself it built with
121C++17. There is no configuration for this. One just has to use a build toolchain
122that supports C++17.
123
124When complete the arguments will be stored in `<directory>/args.gn`, and
125GN will automatically use the new arguments to generate build files.
126Should your files fail to generate, please double-check that you have set
127use\_sysroot as indicated above.
128
129## Building the code
130
131You can build the sample program by running: `ninja -C <directory> pdfium_test`
132You can build the entire product (which includes a few unit tests) by running:
133`ninja -C <directory> pdfium_all`.
134
135## Running the sample program
136
137The pdfium\_test program supports reading, parsing, and rasterizing the pages of
138a .pdf file to .ppm or .png output image files (Windows supports two other
139formats). For example: `<directory>/pdfium_test --ppm path/to/myfile.pdf`. Note
140that this will write output images to `path/to/myfile.pdf.<n>.ppm`.
141Run `pdfium_test --help` to see all the options.
142
143## Testing
144
145There are currently several test suites that can be run:
146
147 * pdfium\_unittests
148 * pdfium\_embeddertests
149 * testing/tools/run\_corpus\_tests.py
150 * testing/tools/run\_javascript\_tests.py
151 * testing/tools/run\_pixel\_tests.py
152
153It is possible the tests in the `testing` directory can fail due to font
154differences on the various platforms. These tests are reliable on the bots. If
155you see failures, it can be a good idea to run the tests on the tip-of-tree
156checkout to see if the same failures appear.
157
158### Pixel Tests
159
160If your change affects rendering, a pixel test should be added. Simply add a
161`.in` or `.pdf` file in `testing/resources/pixel` and the pixel runner will
162pick it up at the next run.
163
164Make sure that your test case doesn't have any copyright issues. It should also
165be a minimal test case focusing on the bug that renders the same way in many
166PDF viewers. Try to avoid binary data in streams by using the `ASCIIHexDecode`
167simply because it makes the PDF more readable in a text editor.
168
169To try out your new test, you can call the `run_pixel_tests.py` script:
170
171```bash
172$ ./testing/tools/run_pixel_tests.py your_new_file.in
173```
174
175To generate the expected image, you can use the `make_expected.sh` script:
176
177```bash
178$ ./testing/tools/make_expected.sh your_new_file.pdf
179```
180
181Please make sure to have `optipng` installed which optimized the file size of
182the resulting png.
183
184### `.in` files
185
186`.in` files are PDF template files. PDF files contain many byte offsets that
187have to be kept correct or the file won't be valid. The template makes this
188easier by replacing the byte offsets with certain keywords.
189
190This saves space and also allows an easy way to reduce the test case to the
191essentials as you can simply remove everything that is not necessary.
192
193A simple example can be found [here](https://pdfium.googlesource.com/pdfium/+/refs/heads/master/testing/resources/rectangles.in).
194
195To transform this into a PDF, you can use the `fixup_pdf_template.py` tool:
196
197```bash
198$ ./testing/tools/fixup_pdf_template.py your_file.in
199```
200
201This will create a `your_file.pdf` in the same directory as `your_file.in`.
202
203There is no official style guide for the .in file, but a consistent style is
204preferred simply to help with readability. If possible, object numbers should
205be consecutive and `/Type` and `/SubType` should be on top of a dictionary to
206make object identification easier.
207
208## Embedding PDFium in your own projects
209
210The public/ directory contains header files for the APIs available for use by
211embedders of PDFium. We endeavor to keep these as stable as possible.
212
213Outside of the public/ directory, code may change at any time, and embedders
214should not directly call these routines.
215
216## Code Coverage
217
218Code coverage reports for PDFium can be generated in Linux development
219environments. Details can be found [here](/docs/code-coverage.md).
220
221Chromium provides code coverage reports for PDFium
222[here](https://chromium-coverage.appspot.com/). PDFium is located in
223`third_party/pdfium` in Chromium's source code.
224This includes code coverage from PDFium's fuzzers.
225
226## Profiling
227
228Valgrind and other profiling tools do not work correctly with the standard build
229setup that PDFium uses. You will need to add
230`ro_segment_workaround_for_valgrind=true` to `args.gn` to get symbols to
231correctly appear.
232
233## Waterfall
234
235The current health of the source tree can be found
236[here](https://ci.chromium.org/p/pdfium/g/main/console).
237
238## Community
239
240There are several mailing lists that are setup:
241
242 * [PDFium](https://groups.google.com/forum/#!forum/pdfium)
243 * [PDFium Reviews](https://groups.google.com/forum/#!forum/pdfium-reviews)
244 * [PDFium Bugs](https://groups.google.com/forum/#!forum/pdfium-bugs)
245
246Note, the Reviews and Bugs lists are typically read-only.
247
248## Bugs
249
250 We use this
251[bug tracker](https://bugs.chromium.org/p/pdfium/issues/list), but for security
252bugs, please use
253[Chromium's security bug template](https://bugs.chromium.org/p/chromium/issues/entry?template=Security%20Bug)
254and add the "Cr-Internals-Plugins-PDF" label.
255
256## Contributing code
257
258For contributing code, we will follow
259[Chromium's process](https://chromium.googlesource.com/chromium/src/+/master/docs/contributing.md)
260as much as possible. The main exceptions are:
261
2621. Code has to conform to the existing style and not Chromium/Google style.
2632. PDFium uses a different Gerrit instance for code reviews, and credentials for
264this Gerrit instance need to be generated before uploading changes.
2653. PDFium is transitioning to C++14, but still supports C++11 compatibility
266for the duration of the transition period. Prefer to use only C++11 features,
267though technically C++14 is allowed in code that is only built when V8, XFA, or
268Skia is turned on.
269
270Before submitting a fix for a bug, it can help if you create an issue in the
271bug tracker. This allows easier discussion about the problem and also helps
272with statistics tracking.
273