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> |
11 #include <sstream> | 11 #include <sstream> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "../fpdfsdk/include/fpdf_dataavail.h" | 16 #include "../public/fpdf_dataavail.h" |
17 #include "../fpdfsdk/include/fpdf_ext.h" | 17 #include "../public/fpdf_ext.h" |
18 #include "../fpdfsdk/include/fpdfformfill.h" | 18 #include "../public/fpdf_formfill.h" |
19 #include "../fpdfsdk/include/fpdftext.h" | 19 #include "../public/fpdf_text.h" |
20 #include "../fpdfsdk/include/fpdfview.h" | 20 #include "../public/fpdfview.h" |
21 #include "../core/include/fxcrt/fx_system.h" | |
22 #include "image_diff_png.h" | 21 #include "image_diff_png.h" |
| 22 #include "v8/include/libplatform/libplatform.h" |
23 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
24 #include "v8/include/libplatform/libplatform.h" | |
25 | 24 |
26 #ifdef _WIN32 | 25 #ifdef _WIN32 |
27 #define snprintf _snprintf | 26 #define snprintf _snprintf |
28 #define PATH_SEPARATOR '\\' | 27 #define PATH_SEPARATOR '\\' |
29 #else | 28 #else |
30 #define PATH_SEPARATOR '/' | 29 #define PATH_SEPARATOR '/' |
31 #endif | 30 #endif |
32 | 31 |
33 enum OutputFormat { | 32 enum OutputFormat { |
34 OUTPUT_NONE, | 33 OUTPUT_NONE, |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 (void) FPDFAvail_IsPageAvail(pdf_avail, first_page, &hints); | 477 (void) FPDFAvail_IsPageAvail(pdf_avail, first_page, &hints); |
479 | 478 |
480 int page_count = FPDF_GetPageCount(doc); | 479 int page_count = FPDF_GetPageCount(doc); |
481 for (int i = 0; i < page_count; ++i) { | 480 for (int i = 0; i < page_count; ++i) { |
482 (void) FPDFAvail_IsPageAvail(pdf_avail, i, &hints); | 481 (void) FPDFAvail_IsPageAvail(pdf_avail, i, &hints); |
483 } | 482 } |
484 | 483 |
485 FORM_DoDocumentJSAction(form); | 484 FORM_DoDocumentJSAction(form); |
486 FORM_DoDocumentOpenAction(form); | 485 FORM_DoDocumentOpenAction(form); |
487 | 486 |
488 size_t rendered_pages = 0; | 487 int rendered_pages = 0; |
489 size_t bad_pages = 0; | 488 int bad_pages = 0; |
490 for (int i = 0; i < page_count; ++i) { | 489 for (int i = 0; i < page_count; ++i) { |
491 FPDF_PAGE page = FPDF_LoadPage(doc, i); | 490 FPDF_PAGE page = FPDF_LoadPage(doc, i); |
492 if (!page) { | 491 if (!page) { |
493 bad_pages ++; | 492 bad_pages ++; |
494 continue; | 493 continue; |
495 } | 494 } |
496 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); | 495 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); |
497 FORM_OnAfterLoadPage(page, form); | 496 FORM_OnAfterLoadPage(page, form); |
498 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); | 497 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); |
499 | 498 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 FORM_OnBeforeClosePage(page, form); | 547 FORM_OnBeforeClosePage(page, form); |
549 FPDFText_ClosePage(text_page); | 548 FPDFText_ClosePage(text_page); |
550 FPDF_ClosePage(page); | 549 FPDF_ClosePage(page); |
551 } | 550 } |
552 | 551 |
553 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); | 552 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); |
554 FPDFDOC_ExitFormFillEnvironment(form); | 553 FPDFDOC_ExitFormFillEnvironment(form); |
555 FPDF_CloseDocument(doc); | 554 FPDF_CloseDocument(doc); |
556 FPDFAvail_Destroy(pdf_avail); | 555 FPDFAvail_Destroy(pdf_avail); |
557 | 556 |
558 fprintf(stderr, "Rendered %" PRIuS " pages.\n", rendered_pages); | 557 fprintf(stderr, "Rendered %d pages.\n", rendered_pages); |
559 fprintf(stderr, "Skipped %" PRIuS " bad pages.\n", bad_pages); | 558 fprintf(stderr, "Skipped %d bad pages.\n", bad_pages); |
560 } | 559 } |
561 | 560 |
562 static const char usage_string[] = | 561 static const char usage_string[] = |
563 "Usage: pdfium_test [OPTION] [FILE]...\n" | 562 "Usage: pdfium_test [OPTION] [FILE]...\n" |
564 " --bin-dir=<path> - override path to v8 external data\n" | 563 " --bin-dir=<path> - override path to v8 external data\n" |
565 " --scale=<number> - scale output size by number (e.g. 0.5)\n" | 564 " --scale=<number> - scale output size by number (e.g. 0.5)\n" |
566 #ifdef _WIN32 | 565 #ifdef _WIN32 |
567 " --bmp - write page images <pdf-name>.<page-number>.bmp\n" | 566 " --bmp - write page images <pdf-name>.<page-number>.bmp\n" |
568 " --emf - write page meta files <pdf-name>.<page-number>.emf\n" | 567 " --emf - write page meta files <pdf-name>.<page-number>.emf\n" |
569 #endif | 568 #endif |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 RenderPdf(filename, file_contents, file_length, options); | 613 RenderPdf(filename, file_contents, file_length, options); |
615 free(file_contents); | 614 free(file_contents); |
616 } | 615 } |
617 | 616 |
618 FPDF_DestroyLibrary(); | 617 FPDF_DestroyLibrary(); |
619 v8::V8::ShutdownPlatform(); | 618 v8::V8::ShutdownPlatform(); |
620 delete platform; | 619 delete platform; |
621 | 620 |
622 return 0; | 621 return 0; |
623 } | 622 } |
OLD | NEW |