Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: docs/getting-started.md

Issue 1840793002: Starting to add some documentation. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « docs/documentation.md ('k') | docs/v8-getting-started.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: docs/getting-started.md
diff --git a/docs/getting-started.md b/docs/getting-started.md
new file mode 100644
index 0000000000000000000000000000000000000000..7224cd8e657d5a06893692642b940c592303311a
--- /dev/null
+++ b/docs/getting-started.md
@@ -0,0 +1,88 @@
+# Getting Started with PDFium
+
+This guide walks through some examples of using the PDFium library. For an
+example of using PDFium see the [Chromium PDF Plugin][chrome-plugin].
+
+## Prerequisites
+
+You will need the PDFium library on your computer. You can see the
+[README](/README.md) for instructions on getting and installing PDFium.
+
+*** note
+You must compile PDFium without V8 or XFA support for the examples here to work.
Tom Sepez 2016/03/28 20:28:18 nit: without both V8 and XFA support
dsinclair 2016/03/29 01:05:19 Done.
+See the [V8 Getting Started][pdfium-v8] guide for how to initialize PDFium when
+V8 is compiled into the binary.
+
+V8 can be compiled out by providing `pdf_enable_v8=0 pdf_enable_xfa=0` to
Tom Sepez 2016/03/28 20:28:18 nit: move this up to line 13 GYP_DEFINES="pdf_ena
dsinclair 2016/03/29 01:05:18 Done.
+`build/gyp_pdfium`.
+***
+
+## PDFium Headers
+
+PDFium has been broken over several headers. You only need to include the
Tom Sepez 2016/03/28 20:28:18 PDFium's API has been broken up over
dsinclair 2016/03/29 01:05:18 Done.
+headers for functionality you need in your application. The full set of
Tom Sepez 2016/03/28 20:28:18 functionality you use in your application.
dsinclair 2016/03/29 01:05:18 Done.
+headers can be found in the [public/ folder of the repository][pdfium-public].
+
+In all cases you'll need to include `fpdfview.h` as it defines the needed
+methods for initialization and destruction of the library.
+
+## Initializing PDFium
+
+The first step to using PDFium is to initialize the library. As well, you'll
Tom Sepez 2016/03/28 20:28:18 Having done so, you'll then need to
dsinclair 2016/03/29 01:05:19 Done.
+need to destroy the library when you're finished. When initializing the
+library you provide the `FPDF_LIBRARY_CONFIG` parameters to
+`FPDF_InitLibraryWithConfig`.
+
+```c
+#include <fpdfview.h>
+
+int main() {
+ FPDF_LIBRARY_CONFIG config;
+ config.version = 2;
+ config.m_pUserFontPaths = NULL;
+ config.m_pIsolate = NULL;
+ config.m_v8EmbedderSlot = 0;
+
+ FPDF_InitLibraryWithConfig(&config);
+
+ FPDF_DestroyLibrary();
+ return 0;
+}
+```
+
+Currently the `config.version` must be set to `2`. `m_pUserFontPaths` can be
+used to override the font paths searched by PDFium. If you wish to use your
+own font paths pass a `NULL` terminated list of `const char*` paths to use.
+
+`m_pIsolate` and `m_v8EmbedderSlot` are both used to configure the V8
+javascript engine. In the first case, you can provide an isolate through
+`m_pIsolate` for PDFium to use to store per-isolate data. Passing `NULL` will
+case PDFium to allocate a new isolate. `m_v8EmbedderSlot` is the embedder data
+slot to use in the v8::Isolate to store PDFium data. The value must be between
+0 and v8::Internals::kNumIsolateDataSlots. Typically, 0 is a good choice.
+
+For more information on using Javascript see the [V8 Getting Started][pdfium-v8]
+guide.
+
+*** aside
+PDFium is built as a set of static libraries. You'll need to specify them all on
+the link line in order to compile. My build line was:
+
+```
+PDF_LIBS="-lpdfium -lfpdfapi -lfxge -lfpdfdoc -lfxcrt -lfx_agg \
Tom Sepez 2016/03/28 20:28:18 we really should consolidate our build down into f
dsinclair 2016/03/29 01:05:19 I think we could just do pdfium and pdfium_xfa as
+-lfxcodec -lfx_lpng -lfx_libopenjpeg -lfx_lcms2 -lfx_freetype -ljpeg \
+-lfx_zlib -lfdrm -lpdfwindow -lbigint -lformfiller -ljavascript \
+-lfxedit"
+PDF_DIR=<path/to/pdfium>
+
+clang -I $PDF_DIR/public -o init init.c -L $PDF_DIR/out/Debug -lstdc++ -framework AppKit $PDF_LIBS
+```
+
+The `-framework AppKit` as needed as I'm building on a Mac. Internally PDFium
+uses C++, which is why `-lstdc++` is required on the link line.
+***
+
+
+[chrome-plugin]: https://chromium.googlesource.com/chromium/src/+/master/pdf/
+[pdfium-public]: https://pdfium.googlesource.com/pdfium/+/master/public/
+[pdfium-v8]: /docs/v8-getting-started.md
« no previous file with comments | « docs/documentation.md ('k') | docs/v8-getting-started.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698