diff options
author | JUN FANG <jun_fang@foxitsoftware.com> | 2015-03-05 13:39:21 -0800 |
---|---|---|
committer | JUN FANG <jun_fang@foxitsoftware.com> | 2015-03-05 13:39:21 -0800 |
commit | 827a1722f70e7092270b5e0fdfba1e9c0b1ac50f (patch) | |
tree | 4f54a77d5b14d0ee3cce0e210fd8c450f7a92042 /samples/pdfium_test.cc | |
parent | 2785fb46249df5229e057917e54fe161bb0e3517 (diff) | |
download | pdfium-827a1722f70e7092270b5e0fdfba1e9c0b1ac50f.tar.xz |
Check whether a pdf has XFA fields before loading XFA fields
BUG=452793
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/973673002
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r-- | samples/pdfium_test.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index d861f2f5c9..e4a55f27ff 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -468,12 +468,21 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len, doc = FPDFAvail_GetDocument(pdf_avail, NULL); } + if (!doc) + { + fprintf(stderr, "Load pdf docs unsuccessful.\n"); + return; + } + (void) FPDF_GetDocPermissions(doc); (void) FPDFAvail_IsFormAvail(pdf_avail, &hints); FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); - if (!FPDF_LoadXFA(doc)) { - fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n"); + int docType = DOCTYPE_PDF; + if (FPDF_HasXFAField(doc, docType)) + { + if (docType != DOCTYPE_PDF && !FPDF_LoadXFA(doc)) + fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n"); } FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); FPDF_SetFormFieldHighlightAlpha(form, 100); |