| 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 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 430 |
| 431 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) { | 431 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) { |
| 432 } | 432 } |
| 433 | 433 |
| 434 void RenderPdf(const std::string& name, const char* pBuf, size_t len, | 434 void RenderPdf(const std::string& name, const char* pBuf, size_t len, |
| 435 const Options& options) { | 435 const Options& options) { |
| 436 fprintf(stderr, "Rendering PDF file %s.\n", name.c_str()); | 436 fprintf(stderr, "Rendering PDF file %s.\n", name.c_str()); |
| 437 | 437 |
| 438 IPDF_JSPLATFORM platform_callbacks; | 438 IPDF_JSPLATFORM platform_callbacks; |
| 439 memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); | 439 memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); |
| 440 platform_callbacks.version = 2; | 440 platform_callbacks.version = 3; |
| 441 platform_callbacks.app_alert = ExampleAppAlert; | 441 platform_callbacks.app_alert = ExampleAppAlert; |
| 442 platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; | 442 platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; |
| 443 | 443 |
| 444 FPDF_FORMFILLINFO form_callbacks; | 444 FPDF_FORMFILLINFO form_callbacks; |
| 445 memset(&form_callbacks, '\0', sizeof(form_callbacks)); | 445 memset(&form_callbacks, '\0', sizeof(form_callbacks)); |
| 446 form_callbacks.version = 1; | 446 form_callbacks.version = 1; |
| 447 form_callbacks.m_pJsPlatform = &platform_callbacks; | 447 form_callbacks.m_pJsPlatform = &platform_callbacks; |
| 448 | 448 |
| 449 TestLoader loader(pBuf, len); | 449 TestLoader loader(pBuf, len); |
| 450 | 450 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 v8::StartupData natives; | 609 v8::StartupData natives; |
| 610 v8::StartupData snapshot; | 610 v8::StartupData snapshot; |
| 611 if (!GetExternalData(options, "natives_blob.bin", &natives) || | 611 if (!GetExternalData(options, "natives_blob.bin", &natives) || |
| 612 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { | 612 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { |
| 613 return 1; | 613 return 1; |
| 614 } | 614 } |
| 615 v8::V8::SetNativesDataBlob(&natives); | 615 v8::V8::SetNativesDataBlob(&natives); |
| 616 v8::V8::SetSnapshotDataBlob(&snapshot); | 616 v8::V8::SetSnapshotDataBlob(&snapshot); |
| 617 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 617 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 618 | 618 |
| 619 if (options.font_directory.empty()) { | 619 FPDF_LIBRARY_CONFIG config; |
| 620 FPDF_InitLibrary(); | 620 config.version = 2; |
| 621 } else { | 621 config.m_pUserFontPaths = nullptr; |
| 622 const char* path_array[2]; | 622 config.m_pIsolate = nullptr; |
| 623 config.m_v8EmbedderSlot = 0; |
| 624 |
| 625 const char* path_array[2]; |
| 626 if (!options.font_directory.empty()) { |
| 623 path_array[0] = options.font_directory.c_str(); | 627 path_array[0] = options.font_directory.c_str(); |
| 624 path_array[1] = nullptr; | 628 path_array[1] = nullptr; |
| 625 FPDF_LIBRARY_CONFIG config; | |
| 626 config.version = 1; | |
| 627 config.m_pUserFontPaths = path_array; | 629 config.m_pUserFontPaths = path_array; |
| 628 FPDF_InitLibraryWithConfig(&config); | |
| 629 } | 630 } |
| 631 FPDF_InitLibraryWithConfig(&config); |
| 630 | 632 |
| 631 UNSUPPORT_INFO unsuppored_info; | 633 UNSUPPORT_INFO unsuppored_info; |
| 632 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); | 634 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); |
| 633 unsuppored_info.version = 1; | 635 unsuppored_info.version = 1; |
| 634 unsuppored_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; | 636 unsuppored_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; |
| 635 | 637 |
| 636 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); | 638 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); |
| 637 | 639 |
| 638 while (!files.empty()) { | 640 while (!files.empty()) { |
| 639 std::string filename = files.front(); | 641 std::string filename = files.front(); |
| 640 files.pop_front(); | 642 files.pop_front(); |
| 641 size_t file_length = 0; | 643 size_t file_length = 0; |
| 642 char* file_contents = GetFileContents(filename.c_str(), &file_length); | 644 char* file_contents = GetFileContents(filename.c_str(), &file_length); |
| 643 if (!file_contents) | 645 if (!file_contents) |
| 644 continue; | 646 continue; |
| 645 RenderPdf(filename, file_contents, file_length, options); | 647 RenderPdf(filename, file_contents, file_length, options); |
| 646 free(file_contents); | 648 free(file_contents); |
| 647 } | 649 } |
| 648 | 650 |
| 649 FPDF_DestroyLibrary(); | 651 FPDF_DestroyLibrary(); |
| 650 v8::V8::ShutdownPlatform(); | 652 v8::V8::ShutdownPlatform(); |
| 651 delete platform; | 653 delete platform; |
| 652 | 654 |
| 653 return 0; | 655 return 0; |
| 654 } | 656 } |
| OLD | NEW |