Index: samples/pdfium_test.cc |
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc |
index d861f2f5c9f92dc6e53fef2054499c0793bfbe5e..e4a55f27ff466a1e589de5ad344aa69483892a1d 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); |