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 <map> | 10 #include <map> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 output_format(OUTPUT_NONE) {} | 70 output_format(OUTPUT_NONE) {} |
71 | 71 |
72 bool show_config; | 72 bool show_config; |
73 bool send_events; | 73 bool send_events; |
74 bool pages; | 74 bool pages; |
75 OutputFormat output_format; | 75 OutputFormat output_format; |
76 std::string scale_factor_as_string; | 76 std::string scale_factor_as_string; |
77 std::string exe_path; | 77 std::string exe_path; |
78 std::string bin_directory; | 78 std::string bin_directory; |
79 std::string font_directory; | 79 std::string font_directory; |
80 int firstPage; | 80 // 0-based page numbers to be rendered. |
81 int lastPage; | 81 int first_page; |
82 int last_page; | |
82 }; | 83 }; |
83 | 84 |
84 struct FPDF_FORMFILLINFO_PDFiumTest : public FPDF_FORMFILLINFO { | 85 struct FPDF_FORMFILLINFO_PDFiumTest : public FPDF_FORMFILLINFO { |
85 // Hold a map of the currently loaded pages in order to avoid them | 86 // Hold a map of the currently loaded pages in order to avoid them |
86 // to get loaded twice. | 87 // to get loaded twice. |
87 std::map<int, FPDF_PAGE> loadedPages; | 88 std::map<int, FPDF_PAGE> loaded_pages; |
88 | 89 |
89 // Hold a pointer of FPDF_FORMHANDLE so that PDFium app hooks can | 90 // Hold a pointer of FPDF_FORMHANDLE so that PDFium app hooks can |
90 // make use of it. | 91 // make use of it. |
91 FPDF_FORMHANDLE formHandle; | 92 FPDF_FORMHANDLE form_handle; |
92 }; | 93 }; |
93 | 94 |
94 struct AvailDeleter { | 95 struct AvailDeleter { |
95 inline void operator()(FPDF_AVAIL avail) const { FPDFAvail_Destroy(avail); } | 96 inline void operator()(FPDF_AVAIL avail) const { FPDFAvail_Destroy(avail); } |
96 }; | 97 }; |
97 | 98 |
98 static FPDF_FORMFILLINFO_PDFiumTest* ToPDFiumTestFormFillInfo( | 99 static FPDF_FORMFILLINFO_PDFiumTest* ToPDFiumTestFormFillInfo( |
99 FPDF_FORMFILLINFO* formFillInfo) { | 100 FPDF_FORMFILLINFO* form_fill_info) { |
100 return static_cast<FPDF_FORMFILLINFO_PDFiumTest*>(formFillInfo); | 101 return static_cast<FPDF_FORMFILLINFO_PDFiumTest*>(form_fill_info); |
101 } | 102 } |
102 | 103 |
103 static bool CheckDimensions(int stride, int width, int height) { | 104 static bool CheckDimensions(int stride, int width, int height) { |
104 if (stride < 0 || width < 0 || height < 0) | 105 if (stride < 0 || width < 0 || height < 0) |
105 return false; | 106 return false; |
106 if (height > 0 && width > INT_MAX / height) | 107 if (height > 0 && width > INT_MAX / height) |
107 return false; | 108 return false; |
108 return true; | 109 return true; |
109 } | 110 } |
110 | 111 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 picture->serialize(&wStream); | 291 picture->serialize(&wStream); |
291 } | 292 } |
292 #endif | 293 #endif |
293 | 294 |
294 // These example JS platform callback handlers are entirely optional, | 295 // These example JS platform callback handlers are entirely optional, |
295 // and exist here to show the flow of information from a document back | 296 // and exist here to show the flow of information from a document back |
296 // to the embedder. | 297 // to the embedder. |
297 int ExampleAppAlert(IPDF_JSPLATFORM*, | 298 int ExampleAppAlert(IPDF_JSPLATFORM*, |
298 FPDF_WIDESTRING msg, | 299 FPDF_WIDESTRING msg, |
299 FPDF_WIDESTRING title, | 300 FPDF_WIDESTRING title, |
300 int nType, | 301 int type, |
301 int nIcon) { | 302 int icon) { |
302 printf("%ls", GetPlatformWString(title).c_str()); | 303 printf("%ls", GetPlatformWString(title).c_str()); |
303 if (nIcon || nType) | 304 if (icon || type) |
304 printf("[icon=%d,type=%d]", nIcon, nType); | 305 printf("[icon=%d,type=%d]", icon, type); |
305 printf(": %ls\n", GetPlatformWString(msg).c_str()); | 306 printf(": %ls\n", GetPlatformWString(msg).c_str()); |
306 return 0; | 307 return 0; |
307 } | 308 } |
308 | 309 |
309 int ExampleAppResponse(IPDF_JSPLATFORM*, | 310 int ExampleAppResponse(IPDF_JSPLATFORM*, |
310 FPDF_WIDESTRING question, | 311 FPDF_WIDESTRING question, |
311 FPDF_WIDESTRING title, | 312 FPDF_WIDESTRING title, |
312 FPDF_WIDESTRING defaultValue, | 313 FPDF_WIDESTRING default_value, |
313 FPDF_WIDESTRING label, | 314 FPDF_WIDESTRING label, |
314 FPDF_BOOL isPassword, | 315 FPDF_BOOL is_password, |
315 void* response, | 316 void* response, |
316 int length) { | 317 int length) { |
317 printf("%ls: %ls, defaultValue=%ls, label=%ls, isPassword=%d, length=%d\n", | 318 printf("%ls: %ls, default_value=%ls, label=%ls, is_password=%d, length=%d\n", |
318 GetPlatformWString(title).c_str(), | 319 GetPlatformWString(title).c_str(), |
319 GetPlatformWString(question).c_str(), | 320 GetPlatformWString(question).c_str(), |
320 GetPlatformWString(defaultValue).c_str(), | 321 GetPlatformWString(default_value).c_str(), |
321 GetPlatformWString(label).c_str(), isPassword, length); | 322 GetPlatformWString(label).c_str(), is_password, length); |
322 | 323 |
323 // UTF-16, always LE regardless of platform. | 324 // UTF-16, always LE regardless of platform. |
324 uint8_t* ptr = static_cast<uint8_t*>(response); | 325 uint8_t* ptr = static_cast<uint8_t*>(response); |
325 ptr[0] = 'N'; | 326 ptr[0] = 'N'; |
326 ptr[1] = 0; | 327 ptr[1] = 0; |
327 ptr[2] = 'o'; | 328 ptr[2] = 'o'; |
328 ptr[3] = 0; | 329 ptr[3] = 0; |
329 return 4; | 330 return 4; |
330 } | 331 } |
331 | 332 |
332 void ExampleDocGotoPage(IPDF_JSPLATFORM*, int pageNumber) { | 333 void ExampleDocGotoPage(IPDF_JSPLATFORM*, int page_number) { |
333 printf("Goto Page: %d\n", pageNumber); | 334 printf("Goto Page: %d\n", page_number); |
334 } | 335 } |
335 | 336 |
336 void ExampleDocMail(IPDF_JSPLATFORM*, | 337 void ExampleDocMail(IPDF_JSPLATFORM*, |
337 void* mailData, | 338 void* mailData, |
338 int length, | 339 int length, |
339 FPDF_BOOL bUI, | 340 FPDF_BOOL UI, |
340 FPDF_WIDESTRING To, | 341 FPDF_WIDESTRING To, |
341 FPDF_WIDESTRING Subject, | 342 FPDF_WIDESTRING Subject, |
342 FPDF_WIDESTRING CC, | 343 FPDF_WIDESTRING CC, |
343 FPDF_WIDESTRING BCC, | 344 FPDF_WIDESTRING BCC, |
344 FPDF_WIDESTRING Msg) { | 345 FPDF_WIDESTRING Msg) { |
345 printf("Mail Msg: %d, to=%ls, cc=%ls, bcc=%ls, subject=%ls, body=%ls\n", bUI, | 346 printf("Mail Msg: %d, to=%ls, cc=%ls, bcc=%ls, subject=%ls, body=%ls\n", UI, |
346 GetPlatformWString(To).c_str(), GetPlatformWString(CC).c_str(), | 347 GetPlatformWString(To).c_str(), GetPlatformWString(CC).c_str(), |
347 GetPlatformWString(BCC).c_str(), GetPlatformWString(Subject).c_str(), | 348 GetPlatformWString(BCC).c_str(), GetPlatformWString(Subject).c_str(), |
348 GetPlatformWString(Msg).c_str()); | 349 GetPlatformWString(Msg).c_str()); |
349 } | 350 } |
350 | 351 |
351 void ExampleUnsupportedHandler(UNSUPPORT_INFO*, int type) { | 352 void ExampleUnsupportedHandler(UNSUPPORT_INFO*, int type) { |
352 std::string feature = "Unknown"; | 353 std::string feature = "Unknown"; |
353 switch (type) { | 354 switch (type) { |
354 case FPDF_UNSP_DOC_XFAFORM: | 355 case FPDF_UNSP_DOC_XFAFORM: |
355 feature = "XFA"; | 356 feature = "XFA"; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 fprintf(stderr, "Duplicate --scale argument\n"); | 472 fprintf(stderr, "Duplicate --scale argument\n"); |
472 return false; | 473 return false; |
473 } | 474 } |
474 options->scale_factor_as_string = cur_arg.substr(8); | 475 options->scale_factor_as_string = cur_arg.substr(8); |
475 } else if (cur_arg.size() > 8 && cur_arg.compare(0, 8, "--pages=") == 0) { | 476 } else if (cur_arg.size() > 8 && cur_arg.compare(0, 8, "--pages=") == 0) { |
476 if (options->pages) { | 477 if (options->pages) { |
477 fprintf(stderr, "Duplicate --pages argument\n"); | 478 fprintf(stderr, "Duplicate --pages argument\n"); |
478 return false; | 479 return false; |
479 } | 480 } |
480 options->pages = true; | 481 options->pages = true; |
481 const std::string pagesstring = cur_arg.substr(8); | 482 const std::string pages_string = cur_arg.substr(8); |
482 size_t firstdash = pagesstring.find("-"); | 483 size_t first_dash = pages_string.find("-"); |
483 if (firstdash == std::string::npos) { | 484 if (first_dash == std::string::npos) { |
484 std::stringstream(pagesstring) >> options->firstPage; | 485 std::stringstream(pages_string) >> options->first_page; |
485 options->lastPage = options->firstPage; | 486 options->last_page = options->first_page; |
486 } else { | 487 } else { |
487 std::stringstream(pagesstring.substr(0, firstdash)) >> | 488 std::stringstream(pages_string.substr(0, first_dash)) >> |
488 options->firstPage; | 489 options->first_page; |
489 std::stringstream(pagesstring.substr(firstdash + 1)) >> | 490 std::stringstream(pages_string.substr(first_dash + 1)) >> |
490 options->lastPage; | 491 options->last_page; |
491 } | 492 } |
492 } else if (cur_arg.size() >= 2 && cur_arg[0] == '-' && cur_arg[1] == '-') { | 493 } else if (cur_arg.size() >= 2 && cur_arg[0] == '-' && cur_arg[1] == '-') { |
493 fprintf(stderr, "Unrecognized argument %s\n", cur_arg.c_str()); | 494 fprintf(stderr, "Unrecognized argument %s\n", cur_arg.c_str()); |
494 return false; | 495 return false; |
495 } else { | 496 } else { |
496 break; | 497 break; |
497 } | 498 } |
498 } | 499 } |
499 for (size_t i = cur_idx; i < args.size(); i++) | 500 for (size_t i = cur_idx; i < args.size(); i++) |
500 files->push_back(args[i]); | 501 files->push_back(args[i]); |
501 | 502 |
502 return true; | 503 return true; |
503 } | 504 } |
504 | 505 |
505 FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) { | 506 FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* p_this, size_t offset, size_t size) { |
dsinclair
2016/11/14 20:57:20
nit: rename p_this to avail or something.
npm
2016/11/14 21:01:14
Done.
| |
506 return true; | 507 return true; |
507 } | 508 } |
508 | 509 |
509 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) { | 510 void Add_Segment(FX_DOWNLOADHINTS* p_this, size_t offset, size_t size) {} |
510 } | |
511 | 511 |
512 void SendPageEvents(const FPDF_FORMHANDLE& form, | 512 void SendPageEvents(const FPDF_FORMHANDLE& form, |
513 const FPDF_PAGE& page, | 513 const FPDF_PAGE& page, |
514 const std::string& events) { | 514 const std::string& events) { |
515 auto lines = StringSplit(events, '\n'); | 515 auto lines = StringSplit(events, '\n'); |
516 for (auto line : lines) { | 516 for (auto line : lines) { |
517 auto command = StringSplit(line, '#'); | 517 auto command = StringSplit(line, '#'); |
518 if (command[0].empty()) | 518 if (command[0].empty()) |
519 continue; | 519 continue; |
520 auto tokens = StringSplit(command[0], ','); | 520 auto tokens = StringSplit(command[0], ','); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 } | 566 } |
567 } else { | 567 } else { |
568 fprintf(stderr, "Unrecognized event: %s\n", tokens[0].c_str()); | 568 fprintf(stderr, "Unrecognized event: %s\n", tokens[0].c_str()); |
569 } | 569 } |
570 } | 570 } |
571 } | 571 } |
572 | 572 |
573 FPDF_PAGE GetPageForIndex(FPDF_FORMFILLINFO* param, | 573 FPDF_PAGE GetPageForIndex(FPDF_FORMFILLINFO* param, |
574 FPDF_DOCUMENT doc, | 574 FPDF_DOCUMENT doc, |
575 int index) { | 575 int index) { |
576 FPDF_FORMFILLINFO_PDFiumTest* formFillInfo = ToPDFiumTestFormFillInfo(param); | 576 FPDF_FORMFILLINFO_PDFiumTest* form_fill_info = |
577 auto& loadedPages = formFillInfo->loadedPages; | 577 ToPDFiumTestFormFillInfo(param); |
578 auto& loaded_pages = form_fill_info->loaded_pages; | |
578 | 579 |
579 auto iter = loadedPages.find(index); | 580 auto iter = loaded_pages.find(index); |
580 if (iter != loadedPages.end()) | 581 if (iter != loaded_pages.end()) |
581 return iter->second; | 582 return iter->second; |
582 | 583 |
583 FPDF_PAGE page = FPDF_LoadPage(doc, index); | 584 FPDF_PAGE page = FPDF_LoadPage(doc, index); |
584 if (!page) | 585 if (!page) |
585 return nullptr; | 586 return nullptr; |
586 | 587 |
587 FPDF_FORMHANDLE& formHandle = formFillInfo->formHandle; | 588 FPDF_FORMHANDLE& form_handle = form_fill_info->form_handle; |
588 | 589 |
589 FORM_OnAfterLoadPage(page, formHandle); | 590 FORM_OnAfterLoadPage(page, form_handle); |
590 FORM_DoPageAAction(page, formHandle, FPDFPAGE_AACTION_OPEN); | 591 FORM_DoPageAAction(page, form_handle, FPDFPAGE_AACTION_OPEN); |
591 | 592 |
592 loadedPages[index] = page; | 593 loaded_pages[index] = page; |
593 return page; | 594 return page; |
594 } | 595 } |
595 | 596 |
596 bool RenderPage(const std::string& name, | 597 bool RenderPage(const std::string& name, |
597 FPDF_DOCUMENT doc, | 598 FPDF_DOCUMENT doc, |
598 FPDF_FORMHANDLE& form, | 599 FPDF_FORMHANDLE& form, |
599 FPDF_FORMFILLINFO_PDFiumTest& formFillInfo, | 600 FPDF_FORMFILLINFO_PDFiumTest& form_fill_info, |
600 const int page_index, | 601 const int page_index, |
601 const Options& options, | 602 const Options& options, |
602 const std::string& events) { | 603 const std::string& events) { |
603 FPDF_PAGE page = GetPageForIndex(&formFillInfo, doc, page_index); | 604 FPDF_PAGE page = GetPageForIndex(&form_fill_info, doc, page_index); |
604 if (!page) | 605 if (!page) |
605 return false; | 606 return false; |
606 | 607 |
607 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); | 608 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); |
608 | 609 |
609 if (options.send_events) | 610 if (options.send_events) |
610 SendPageEvents(form, page, events); | 611 SendPageEvents(form, page, events); |
611 | 612 |
612 double scale = 1.0; | 613 double scale = 1.0; |
613 if (!options.scale_factor_as_string.empty()) | 614 if (!options.scale_factor_as_string.empty()) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 #endif | 661 #endif |
661 default: | 662 default: |
662 break; | 663 break; |
663 } | 664 } |
664 | 665 |
665 FPDFBitmap_Destroy(bitmap); | 666 FPDFBitmap_Destroy(bitmap); |
666 } else { | 667 } else { |
667 fprintf(stderr, "Page was too large to be rendered.\n"); | 668 fprintf(stderr, "Page was too large to be rendered.\n"); |
668 } | 669 } |
669 | 670 |
670 formFillInfo.loadedPages.erase(page_index); | 671 form_fill_info.loaded_pages.erase(page_index); |
671 | 672 |
672 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_CLOSE); | 673 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_CLOSE); |
673 FORM_OnBeforeClosePage(page, form); | 674 FORM_OnBeforeClosePage(page, form); |
674 FPDFText_ClosePage(text_page); | 675 FPDFText_ClosePage(text_page); |
675 FPDF_ClosePage(page); | 676 FPDF_ClosePage(page); |
676 return !!bitmap; | 677 return !!bitmap; |
677 } | 678 } |
678 | 679 |
679 void RenderPdf(const std::string& name, | 680 void RenderPdf(const std::string& name, |
680 const char* pBuf, | 681 const char* pBuf, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 fprintf(stderr, "Unknown error %ld", err); | 776 fprintf(stderr, "Unknown error %ld", err); |
776 } | 777 } |
777 fprintf(stderr, ".\n"); | 778 fprintf(stderr, ".\n"); |
778 | 779 |
779 return; | 780 return; |
780 } | 781 } |
781 | 782 |
782 (void)FPDF_GetDocPermissions(doc); | 783 (void)FPDF_GetDocPermissions(doc); |
783 | 784 |
784 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); | 785 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); |
785 form_callbacks.formHandle = form; | 786 form_callbacks.form_handle = form; |
786 | 787 |
787 #ifdef PDF_ENABLE_XFA | 788 #ifdef PDF_ENABLE_XFA |
788 int doc_type = DOCTYPE_PDF; | 789 int doc_type = DOCTYPE_PDF; |
789 if (FPDF_HasXFAField(doc, &doc_type) && doc_type != DOCTYPE_PDF && | 790 if (FPDF_HasXFAField(doc, &doc_type) && doc_type != DOCTYPE_PDF && |
790 !FPDF_LoadXFA(doc)) { | 791 !FPDF_LoadXFA(doc)) { |
791 fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n"); | 792 fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n"); |
792 } | 793 } |
793 #endif // PDF_ENABLE_XFA | 794 #endif // PDF_ENABLE_XFA |
794 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); | 795 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); |
795 FPDF_SetFormFieldHighlightAlpha(form, 100); | 796 FPDF_SetFormFieldHighlightAlpha(form, 100); |
796 | 797 |
797 FORM_DoDocumentJSAction(form); | 798 FORM_DoDocumentJSAction(form); |
798 FORM_DoDocumentOpenAction(form); | 799 FORM_DoDocumentOpenAction(form); |
799 | 800 |
800 int page_count = FPDF_GetPageCount(doc); | 801 int page_count = FPDF_GetPageCount(doc); |
801 int rendered_pages = 0; | 802 int rendered_pages = 0; |
802 int bad_pages = 0; | 803 int bad_pages = 0; |
803 int firstPage = options.pages ? options.firstPage : 0; | 804 int first_page = options.pages ? options.first_page : 0; |
804 int lastPage = options.pages ? options.lastPage + 1 : page_count; | 805 int last_page = options.pages ? options.last_page + 1 : page_count; |
805 for (int i = firstPage; i < lastPage; ++i) { | 806 for (int i = first_page; i < last_page; ++i) { |
806 if (bIsLinearized) { | 807 if (bIsLinearized) { |
807 nRet = PDF_DATA_NOTAVAIL; | 808 nRet = PDF_DATA_NOTAVAIL; |
808 while (nRet == PDF_DATA_NOTAVAIL) | 809 while (nRet == PDF_DATA_NOTAVAIL) |
809 nRet = FPDFAvail_IsPageAvail(pdf_avail, i, &hints); | 810 nRet = FPDFAvail_IsPageAvail(pdf_avail, i, &hints); |
810 | 811 |
811 if (nRet == PDF_DATA_ERROR) { | 812 if (nRet == PDF_DATA_ERROR) { |
812 fprintf(stderr, "Unknown error in checking if page %d is available.\n", | 813 fprintf(stderr, "Unknown error in checking if page %d is available.\n", |
813 i); | 814 i); |
814 FPDFDOC_ExitFormFillEnvironment(form); | 815 FPDFDOC_ExitFormFillEnvironment(form); |
815 FPDF_CloseDocument(doc); | 816 FPDF_CloseDocument(doc); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
853 printf("%s\n", config.c_str()); | 854 printf("%s\n", config.c_str()); |
854 } | 855 } |
855 | 856 |
856 static const char kUsageString[] = | 857 static const char kUsageString[] = |
857 "Usage: pdfium_test [OPTION] [FILE]...\n" | 858 "Usage: pdfium_test [OPTION] [FILE]...\n" |
858 " --show-config - print build options and exit\n" | 859 " --show-config - print build options and exit\n" |
859 " --send-events - send input described by .evt file\n" | 860 " --send-events - send input described by .evt file\n" |
860 " --bin-dir=<path> - override path to v8 external data\n" | 861 " --bin-dir=<path> - override path to v8 external data\n" |
861 " --font-dir=<path> - override path to external fonts\n" | 862 " --font-dir=<path> - override path to external fonts\n" |
862 " --scale=<number> - scale output size by number (e.g. 0.5)\n" | 863 " --scale=<number> - scale output size by number (e.g. 0.5)\n" |
863 " --pages=<number>(-<number>) - only render the given page(s)\n" | 864 " --pages=<number>(-<number>) - only render the given 0-based page(s)\n" |
864 #ifdef _WIN32 | 865 #ifdef _WIN32 |
865 " --bmp - write page images <pdf-name>.<page-number>.bmp\n" | 866 " --bmp - write page images <pdf-name>.<page-number>.bmp\n" |
866 " --emf - write page meta files <pdf-name>.<page-number>.emf\n" | 867 " --emf - write page meta files <pdf-name>.<page-number>.emf\n" |
867 #endif // _WIN32 | 868 #endif // _WIN32 |
868 " --txt - write page text in UTF32-LE <pdf-name>.<page-number>.txt\n" | 869 " --txt - write page text in UTF32-LE <pdf-name>.<page-number>.txt\n" |
869 " --png - write page images <pdf-name>.<page-number>.png\n" | 870 " --png - write page images <pdf-name>.<page-number>.png\n" |
870 " --ppm - write page images <pdf-name>.<page-number>.ppm\n" | 871 " --ppm - write page images <pdf-name>.<page-number>.ppm\n" |
871 #ifdef PDF_ENABLE_SKIA | 872 #ifdef PDF_ENABLE_SKIA |
872 " --skp - write page images <pdf-name>.<page-number>.skp\n" | 873 " --skp - write page images <pdf-name>.<page-number>.skp\n" |
873 #endif | 874 #endif |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
911 config.m_v8EmbedderSlot = 0; | 912 config.m_v8EmbedderSlot = 0; |
912 | 913 |
913 const char* path_array[2]; | 914 const char* path_array[2]; |
914 if (!options.font_directory.empty()) { | 915 if (!options.font_directory.empty()) { |
915 path_array[0] = options.font_directory.c_str(); | 916 path_array[0] = options.font_directory.c_str(); |
916 path_array[1] = nullptr; | 917 path_array[1] = nullptr; |
917 config.m_pUserFontPaths = path_array; | 918 config.m_pUserFontPaths = path_array; |
918 } | 919 } |
919 FPDF_InitLibraryWithConfig(&config); | 920 FPDF_InitLibraryWithConfig(&config); |
920 | 921 |
921 UNSUPPORT_INFO unsuppored_info; | 922 UNSUPPORT_INFO unsupported_info; |
922 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); | 923 memset(&unsupported_info, '\0', sizeof(unsupported_info)); |
923 unsuppored_info.version = 1; | 924 unsupported_info.version = 1; |
924 unsuppored_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; | 925 unsupported_info.FSDK_UnSupport_Handler = ExampleUnsupportedHandler; |
925 | 926 |
926 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); | 927 FSDK_SetUnSpObjProcessHandler(&unsupported_info); |
927 | 928 |
928 for (const std::string& filename : files) { | 929 for (const std::string& filename : files) { |
929 size_t file_length = 0; | 930 size_t file_length = 0; |
930 std::unique_ptr<char, pdfium::FreeDeleter> file_contents = | 931 std::unique_ptr<char, pdfium::FreeDeleter> file_contents = |
931 GetFileContents(filename.c_str(), &file_length); | 932 GetFileContents(filename.c_str(), &file_length); |
932 if (!file_contents) | 933 if (!file_contents) |
933 continue; | 934 continue; |
934 fprintf(stderr, "Rendering PDF file %s.\n", filename.c_str()); | 935 fprintf(stderr, "Rendering PDF file %s.\n", filename.c_str()); |
935 std::string events; | 936 std::string events; |
936 if (options.send_events) { | 937 if (options.send_events) { |
(...skipping 23 matching lines...) Expand all Loading... | |
960 delete platform; | 961 delete platform; |
961 | 962 |
962 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 963 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
963 free(const_cast<char*>(natives.data)); | 964 free(const_cast<char*>(natives.data)); |
964 free(const_cast<char*>(snapshot.data)); | 965 free(const_cast<char*>(snapshot.data)); |
965 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 966 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
966 #endif // PDF_ENABLE_V8 | 967 #endif // PDF_ENABLE_V8 |
967 | 968 |
968 return 0; | 969 return 0; |
969 } | 970 } |
OLD | NEW |