summaryrefslogtreecommitdiff
path: root/samples/pdfium_test.cc
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-11-30 15:46:36 -0800
committerTom Sepez <tsepez@chromium.org>2015-11-30 15:46:36 -0800
commitc46d0005880b24d38d9e7eab2f446e9724e93537 (patch)
tree731f81c6fcb313a9e3c2b8e0ceaf21f3ce70b6b4 /samples/pdfium_test.cc
parent40e9ff30b7f22b37c071dc9751f489d4cc22b0ee (diff)
downloadpdfium-c46d0005880b24d38d9e7eab2f446e9724e93537.tar.xz
Allow building non-XFA (master) on the XFA branch.
This first pass is GYP-only, will do GN in the next CL. R=ochang@chromium.org Review URL: https://codereview.chromium.org/1480403002 .
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r--samples/pdfium_test.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 86c7afd529..4fd6b86c62 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -407,7 +407,11 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
FPDF_FORMFILLINFO form_callbacks;
memset(&form_callbacks, '\0', sizeof(form_callbacks));
+#ifdef PDF_ENABLE_XFA
form_callbacks.version = 2;
+#else // PDF_ENABLE_XFA
+ form_callbacks.version = 1;
+#endif // PDF_ENABLE_XFA
form_callbacks.m_pJsPlatform = &platform_callbacks;
TestLoader loader(pBuf, len);
@@ -494,11 +498,13 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
(void)FPDF_GetDocPermissions(doc);
FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks);
+#ifdef PDF_ENABLE_XFA
int docType = DOCTYPE_PDF;
if (FPDF_HasXFAField(doc, &docType) && docType != DOCTYPE_PDF &&
!FPDF_LoadXFA(doc)) {
fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n");
}
+#endif // PDF_ENABLE_XFA
FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD);
FPDF_SetFormFieldHighlightAlpha(form, 100);
@@ -529,11 +535,16 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC);
+#ifdef PDF_ENABLE_XFA
// Note: The shut down order here is the reverse of the non-XFA branch order.
// Need to work out if this is required, and if it is, the lifetimes of
// objects owned by |doc| that |form| reference.
FPDF_CloseDocument(doc);
FPDFDOC_ExitFormFillEnvironment(form);
+#else // PDF_ENABLE_XFA
+ FPDFDOC_ExitFormFillEnvironment(form);
+ FPDF_CloseDocument(doc);
+#endif // PDF_ENABLE_XFA
FPDFAvail_Destroy(pdf_avail);
@@ -549,7 +560,7 @@ static const char usage_string[] =
#ifdef _WIN32
" --bmp - write page images <pdf-name>.<page-number>.bmp\n"
" --emf - write page meta files <pdf-name>.<page-number>.emf\n"
-#endif
+#endif // _WIN32
" --png - write page images <pdf-name>.<page-number>.png\n"
" --ppm - write page images <pdf-name>.<page-number>.ppm\n";