Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: samples/pdfium_test.cc

Issue 901403004: Merge to XFA: First JavaScript testing implementation. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | testing/resources/javascript/app_alert.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 bool Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) { 412 bool Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
413 return true; 413 return true;
414 } 414 }
415 415
416 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) { 416 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {
417 } 417 }
418 418
419 void RenderPdf(const std::string& name, const char* pBuf, size_t len, 419 void RenderPdf(const std::string& name, const char* pBuf, size_t len,
420 const Options& options) { 420 const Options& options) {
421 printf("Rendering PDF file %s.\n", name.c_str()); 421 fprintf(stderr, "Rendering PDF file %s.\n", name.c_str());
422 422
423 IPDF_JSPLATFORM platform_callbacks; 423 IPDF_JSPLATFORM platform_callbacks;
424 memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); 424 memset(&platform_callbacks, '\0', sizeof(platform_callbacks));
425 platform_callbacks.version = 1; 425 platform_callbacks.version = 1;
426 platform_callbacks.app_alert = Form_Alert; 426 platform_callbacks.app_alert = Form_Alert;
427 427
428 FPDF_FORMFILLINFO form_callbacks; 428 FPDF_FORMFILLINFO form_callbacks;
429 memset(&form_callbacks, '\0', sizeof(form_callbacks)); 429 memset(&form_callbacks, '\0', sizeof(form_callbacks));
430 form_callbacks.version = 2; 430 form_callbacks.version = 2;
431 form_callbacks.m_pJsPlatform = &platform_callbacks; 431 form_callbacks.m_pJsPlatform = &platform_callbacks;
(...skipping 15 matching lines...) Expand all
447 memset(&hints, '\0', sizeof(hints)); 447 memset(&hints, '\0', sizeof(hints));
448 hints.version = 1; 448 hints.version = 1;
449 hints.AddSegment = Add_Segment; 449 hints.AddSegment = Add_Segment;
450 450
451 FPDF_DOCUMENT doc; 451 FPDF_DOCUMENT doc;
452 FPDF_AVAIL pdf_avail = FPDFAvail_Create(&file_avail, &file_access); 452 FPDF_AVAIL pdf_avail = FPDFAvail_Create(&file_avail, &file_access);
453 453
454 (void) FPDFAvail_IsDocAvail(pdf_avail, &hints); 454 (void) FPDFAvail_IsDocAvail(pdf_avail, &hints);
455 455
456 if (!FPDFAvail_IsLinearized(pdf_avail)) { 456 if (!FPDFAvail_IsLinearized(pdf_avail)) {
457 printf("Non-linearized path...\n"); 457 fprintf(stderr, "Non-linearized path...\n");
458 doc = FPDF_LoadCustomDocument(&file_access, NULL); 458 doc = FPDF_LoadCustomDocument(&file_access, NULL);
459 } else { 459 } else {
460 printf("Linearized path...\n"); 460 fprintf(stderr, "Linearized path...\n");
461 doc = FPDFAvail_GetDocument(pdf_avail, NULL); 461 doc = FPDFAvail_GetDocument(pdf_avail, NULL);
462 } 462 }
463 463
464 (void) FPDF_GetDocPermissions(doc); 464 (void) FPDF_GetDocPermissions(doc);
465 (void) FPDFAvail_IsFormAvail(pdf_avail, &hints); 465 (void) FPDFAvail_IsFormAvail(pdf_avail, &hints);
466 466
467 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); 467 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks);
468 if (!FPDF_LoadXFA(doc)) { 468 if (!FPDF_LoadXFA(doc)) {
469 printf("LoadXFA unsuccessful, continuing anyway.\n"); 469 printf("LoadXFA unsuccessful, continuing anyway.\n");
470 } 470 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 FORM_OnBeforeClosePage(page, form); 541 FORM_OnBeforeClosePage(page, form);
542 FPDFText_ClosePage(text_page); 542 FPDFText_ClosePage(text_page);
543 FPDF_ClosePage(page); 543 FPDF_ClosePage(page);
544 } 544 }
545 545
546 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); 546 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC);
547 FPDF_CloseDocument(doc); 547 FPDF_CloseDocument(doc);
548 FPDFDOC_ExitFormFillEnvironment(form); 548 FPDFDOC_ExitFormFillEnvironment(form);
549 FPDFAvail_Destroy(pdf_avail); 549 FPDFAvail_Destroy(pdf_avail);
550 550
551 printf("Loaded, parsed and rendered %" PRIuS " pages.\n", rendered_pages); 551 fprintf(stderr, "Rendered %" PRIuS " pages.\n", rendered_pages);
552 printf("Skipped %" PRIuS " bad pages.\n", bad_pages); 552 fprintf(stderr, "Skipped %" PRIuS " bad pages.\n", bad_pages);
553 } 553 }
554 554
555 static const char usage_string[] =
556 "Usage: pdfium_test [OPTION] [FILE]...\n"
557 " --bin-dir=<path> - override path to v8 external data\n"
558 " --scale=<number> - scale output size by number (e.g. 0.5)\n"
559 #ifdef _WIN32
560 " --bmp - write page images <pdf-name>.<page-number>.bmp\n"
561 " --emf - write page meta files <pdf-name>.<page-number>.emf\n"
562 #endif
563 " --png - write page images <pdf-name>.<page-number>.png\n"
564 " --ppm - write page images <pdf-name>.<page-number>.ppm\n";
565
555 int main(int argc, const char* argv[]) { 566 int main(int argc, const char* argv[]) {
556 std::vector<std::string> args(argv, argv + argc); 567 std::vector<std::string> args(argv, argv + argc);
557 Options options; 568 Options options;
558 std::list<std::string> files; 569 std::list<std::string> files;
559 if (!ParseCommandLine(args, &options, &files)) { 570 if (!ParseCommandLine(args, &options, &files)) {
560 printf("Usage: pdfium_test [OPTION] [FILE]...\n"); 571 fprintf(stderr, "%s", usage_string);
561 printf("--bin-dir=<path> - override path to v8 external data\n");
562 printf("--scale=<number> - scale output size by number (e.g. 0.5)\n");
563 printf("--png - write page images <pdf-name>.<page-number>.png\n");
564 printf("--ppm - write page images <pdf-name>.<page-number>.ppm\n");
565 #ifdef _WIN32
566 printf("--bmp - write page images <pdf-name>.<page-number>.bmp\n");
567 printf("--emf - write page meta files <pdf-name>.<page-number>.emf\n");
568 #endif
569 return 1; 572 return 1;
570 } 573 }
571 574
572 v8::V8::InitializeICU(); 575 v8::V8::InitializeICU();
573 576
574 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 577 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
575 v8::StartupData natives; 578 v8::StartupData natives;
576 v8::StartupData snapshot; 579 v8::StartupData snapshot;
577 if (!GetExternalData(options, "natives_blob.bin", &natives) || 580 if (!GetExternalData(options, "natives_blob.bin", &natives) ||
578 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { 581 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) {
(...skipping 20 matching lines...) Expand all
599 if (!file_contents) 602 if (!file_contents)
600 continue; 603 continue;
601 RenderPdf(filename, file_contents, file_length, options); 604 RenderPdf(filename, file_contents, file_length, options);
602 free(file_contents); 605 free(file_contents);
603 } 606 }
604 607
605 FPDF_DestroyLibrary(); 608 FPDF_DestroyLibrary();
606 609
607 return 0; 610 return 0;
608 } 611 }
OLDNEW
« no previous file with comments | « no previous file | testing/resources/javascript/app_alert.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698