OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <wchar.h> | 9 #include <wchar.h> |
10 | 10 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 (void) FPDFAvail_IsDocAvail(pdf_avail, &hints); | 461 (void) FPDFAvail_IsDocAvail(pdf_avail, &hints); |
462 | 462 |
463 if (!FPDFAvail_IsLinearized(pdf_avail)) { | 463 if (!FPDFAvail_IsLinearized(pdf_avail)) { |
464 fprintf(stderr, "Non-linearized path...\n"); | 464 fprintf(stderr, "Non-linearized path...\n"); |
465 doc = FPDF_LoadCustomDocument(&file_access, NULL); | 465 doc = FPDF_LoadCustomDocument(&file_access, NULL); |
466 } else { | 466 } else { |
467 fprintf(stderr, "Linearized path...\n"); | 467 fprintf(stderr, "Linearized path...\n"); |
468 doc = FPDFAvail_GetDocument(pdf_avail, NULL); | 468 doc = FPDFAvail_GetDocument(pdf_avail, NULL); |
469 } | 469 } |
470 | 470 |
| 471 if (!doc) |
| 472 { |
| 473 fprintf(stderr, "Load pdf docs unsuccessful.\n"); |
| 474 return; |
| 475 } |
| 476 |
471 (void) FPDF_GetDocPermissions(doc); | 477 (void) FPDF_GetDocPermissions(doc); |
472 (void) FPDFAvail_IsFormAvail(pdf_avail, &hints); | 478 (void) FPDFAvail_IsFormAvail(pdf_avail, &hints); |
473 | 479 |
474 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); | 480 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); |
475 if (!FPDF_LoadXFA(doc)) { | 481 int docType = DOCTYPE_PDF; |
476 fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n"); | 482 if (FPDF_HasXFAField(doc, docType)) |
| 483 { |
| 484 if (docType != DOCTYPE_PDF && !FPDF_LoadXFA(doc)) |
| 485 fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n"); |
477 } | 486 } |
478 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); | 487 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); |
479 FPDF_SetFormFieldHighlightAlpha(form, 100); | 488 FPDF_SetFormFieldHighlightAlpha(form, 100); |
480 | 489 |
481 int first_page = FPDFAvail_GetFirstPageNum(doc); | 490 int first_page = FPDFAvail_GetFirstPageNum(doc); |
482 (void) FPDFAvail_IsPageAvail(pdf_avail, first_page, &hints); | 491 (void) FPDFAvail_IsPageAvail(pdf_avail, first_page, &hints); |
483 | 492 |
484 int page_count = FPDF_GetPageCount(doc); | 493 int page_count = FPDF_GetPageCount(doc); |
485 for (int i = 0; i < page_count; ++i) { | 494 for (int i = 0; i < page_count; ++i) { |
486 (void) FPDFAvail_IsPageAvail(pdf_avail, i, &hints); | 495 (void) FPDFAvail_IsPageAvail(pdf_avail, i, &hints); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 RenderPdf(filename, file_contents, file_length, options); | 621 RenderPdf(filename, file_contents, file_length, options); |
613 free(file_contents); | 622 free(file_contents); |
614 } | 623 } |
615 | 624 |
616 FPDF_DestroyLibrary(); | 625 FPDF_DestroyLibrary(); |
617 v8::V8::ShutdownPlatform(); | 626 v8::V8::ShutdownPlatform(); |
618 delete platform; | 627 delete platform; |
619 | 628 |
620 return 0; | 629 return 0; |
621 } | 630 } |
OLD | NEW |