| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 FX_DOWNLOADHINTS hints; | 462 FX_DOWNLOADHINTS hints; |
| 463 memset(&hints, '\0', sizeof(hints)); | 463 memset(&hints, '\0', sizeof(hints)); |
| 464 hints.version = 1; | 464 hints.version = 1; |
| 465 hints.AddSegment = Add_Segment; | 465 hints.AddSegment = Add_Segment; |
| 466 | 466 |
| 467 FPDF_DOCUMENT doc; | 467 FPDF_DOCUMENT doc; |
| 468 FPDF_AVAIL pdf_avail = FPDFAvail_Create(&file_avail, &file_access); | 468 FPDF_AVAIL pdf_avail = FPDFAvail_Create(&file_avail, &file_access); |
| 469 | 469 |
| 470 (void)FPDFAvail_IsDocAvail(pdf_avail, &hints); | 470 (void)FPDFAvail_IsDocAvail(pdf_avail, &hints); |
| 471 | 471 |
| 472 if (!FPDFAvail_IsLinearized(pdf_avail)) { | 472 if (FPDFAvail_IsLinearized(pdf_avail)) { |
| 473 fprintf(stderr, "Linearized path...\n"); |
| 474 doc = FPDFAvail_GetDocument(pdf_avail, nullptr); |
| 475 } else { |
| 473 fprintf(stderr, "Non-linearized path...\n"); | 476 fprintf(stderr, "Non-linearized path...\n"); |
| 474 doc = FPDF_LoadCustomDocument(&file_access, nullptr); | 477 doc = FPDF_LoadCustomDocument(&file_access, nullptr); |
| 475 } else { | |
| 476 fprintf(stderr, "Linearized path...\n"); | |
| 477 doc = FPDFAvail_GetDocument(pdf_avail, nullptr); | |
| 478 } | 478 } |
| 479 | 479 |
| 480 if (!doc) { | 480 if (!doc) { |
| 481 fprintf(stderr, "Load pdf docs unsuccessful.\n"); | 481 fprintf(stderr, "Load pdf docs unsuccessful.\n"); |
| 482 return; | 482 return; |
| 483 } | 483 } |
| 484 | 484 |
| 485 (void)FPDF_GetDocPermissions(doc); | 485 (void)FPDF_GetDocPermissions(doc); |
| 486 (void)FPDFAvail_IsFormAvail(pdf_avail, &hints); | 486 (void)FPDFAvail_IsFormAvail(pdf_avail, &hints); |
| 487 | 487 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 v8::StartupData natives; | 614 v8::StartupData natives; |
| 615 v8::StartupData snapshot; | 615 v8::StartupData snapshot; |
| 616 if (!GetExternalData(options, "natives_blob.bin", &natives) || | 616 if (!GetExternalData(options, "natives_blob.bin", &natives) || |
| 617 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { | 617 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { |
| 618 return 1; | 618 return 1; |
| 619 } | 619 } |
| 620 v8::V8::SetNativesDataBlob(&natives); | 620 v8::V8::SetNativesDataBlob(&natives); |
| 621 v8::V8::SetSnapshotDataBlob(&snapshot); | 621 v8::V8::SetSnapshotDataBlob(&snapshot); |
| 622 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 622 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 623 | 623 |
| 624 if (!options.font_directory.empty()) { | 624 if (options.font_directory.empty()) { |
| 625 FPDF_InitLibrary(); |
| 626 } else { |
| 625 const char* path_array[2]; | 627 const char* path_array[2]; |
| 626 path_array[0] = options.font_directory.c_str(); | 628 path_array[0] = options.font_directory.c_str(); |
| 627 path_array[1] = nullptr; | 629 path_array[1] = nullptr; |
| 628 FPDF_LIBRARY_CONFIG config; | 630 FPDF_LIBRARY_CONFIG config; |
| 629 config.version = 1; | 631 config.version = 1; |
| 630 config.m_pUserFontPaths = path_array; | 632 config.m_pUserFontPaths = path_array; |
| 631 FPDF_InitLibraryWithConfig(&config); | 633 FPDF_InitLibraryWithConfig(&config); |
| 632 } else { | |
| 633 FPDF_InitLibrary(); | |
| 634 } | 634 } |
| 635 | 635 |
| 636 UNSUPPORT_INFO unsuppored_info; | 636 UNSUPPORT_INFO unsuppored_info; |
| 637 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); | 637 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); |
| 638 unsuppored_info.version = 1; | 638 unsuppored_info.version = 1; |
| 639 unsuppored_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; | 639 unsuppored_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; |
| 640 | 640 |
| 641 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); | 641 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); |
| 642 | 642 |
| 643 while (!files.empty()) { | 643 while (!files.empty()) { |
| 644 std::string filename = files.front(); | 644 std::string filename = files.front(); |
| 645 files.pop_front(); | 645 files.pop_front(); |
| 646 size_t file_length = 0; | 646 size_t file_length = 0; |
| 647 char* file_contents = GetFileContents(filename.c_str(), &file_length); | 647 char* file_contents = GetFileContents(filename.c_str(), &file_length); |
| 648 if (!file_contents) | 648 if (!file_contents) |
| 649 continue; | 649 continue; |
| 650 RenderPdf(filename, file_contents, file_length, options); | 650 RenderPdf(filename, file_contents, file_length, options); |
| 651 free(file_contents); | 651 free(file_contents); |
| 652 } | 652 } |
| 653 | 653 |
| 654 FPDF_DestroyLibrary(); | 654 FPDF_DestroyLibrary(); |
| 655 v8::V8::ShutdownPlatform(); | 655 v8::V8::ShutdownPlatform(); |
| 656 delete platform; | 656 delete platform; |
| 657 | 657 |
| 658 return 0; | 658 return 0; |
| 659 } | 659 } |
| OLD | NEW |