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

Side by Side Diff: samples/pdfium_test.cc

Issue 477873003: Fix a hang issue due to inconsistent page number in the test file (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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 | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | 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 9
10 #include <list> 10 #include <list>
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 (void) FPDFAvail_IsPageAvail(pdf_avail, first_page, &hints); 297 (void) FPDFAvail_IsPageAvail(pdf_avail, first_page, &hints);
298 298
299 int page_count = FPDF_GetPageCount(doc); 299 int page_count = FPDF_GetPageCount(doc);
300 for (int i = 0; i < page_count; ++i) { 300 for (int i = 0; i < page_count; ++i) {
301 (void) FPDFAvail_IsPageAvail(pdf_avail, i, &hints); 301 (void) FPDFAvail_IsPageAvail(pdf_avail, i, &hints);
302 } 302 }
303 303
304 FORM_DoDocumentJSAction(form); 304 FORM_DoDocumentJSAction(form);
305 FORM_DoDocumentOpenAction(form); 305 FORM_DoDocumentOpenAction(form);
306 306
307 size_t renderedPages = 0;
Tom Sepez 2014/08/22 00:23:31 nit: we use the rendered_pages style for local va
jun_fang 2014/08/22 01:07:25 Got it.
307 for (int i = 0; i < page_count; ++i) { 308 for (int i = 0; i < page_count; ++i) {
308 FPDF_PAGE page = FPDF_LoadPage(doc, i); 309 FPDF_PAGE page = FPDF_LoadPage(doc, i);
310 if (!page) {
311 continue;
Tom Sepez 2014/08/22 00:23:31 nit: Should we count the bad pages, too, and outpu
jun_fang 2014/08/22 01:07:25 Will add it.
312 }
309 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); 313 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
310 FORM_OnAfterLoadPage(page, form); 314 FORM_OnAfterLoadPage(page, form);
311 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); 315 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN);
312 316
313 int width = static_cast<int>(FPDF_GetPageWidth(page)); 317 int width = static_cast<int>(FPDF_GetPageWidth(page));
314 int height = static_cast<int>(FPDF_GetPageHeight(page)); 318 int height = static_cast<int>(FPDF_GetPageHeight(page));
315 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); 319 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0);
316 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); 320 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF);
317 321
318 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); 322 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0);
323 renderedPages ++;
324
319 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); 325 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0);
320 int stride = FPDFBitmap_GetStride(bitmap); 326 int stride = FPDFBitmap_GetStride(bitmap);
321 const char* buffer = 327 const char* buffer =
322 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); 328 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap));
323 329
324 switch (format) { 330 switch (format) {
325 #ifdef _WIN32 331 #ifdef _WIN32
326 case OUTPUT_BMP: 332 case OUTPUT_BMP:
327 WriteBmp(name, i, buffer, stride, width, height); 333 WriteBmp(name, i, buffer, stride, width, height);
328 break; 334 break;
(...skipping 15 matching lines...) Expand all
344 FORM_OnBeforeClosePage(page, form); 350 FORM_OnBeforeClosePage(page, form);
345 FPDFText_ClosePage(text_page); 351 FPDFText_ClosePage(text_page);
346 FPDF_ClosePage(page); 352 FPDF_ClosePage(page);
347 } 353 }
348 354
349 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); 355 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC);
350 FPDFDOC_ExitFormFillEnviroument(form); 356 FPDFDOC_ExitFormFillEnviroument(form);
351 FPDF_CloseDocument(doc); 357 FPDF_CloseDocument(doc);
352 FPDFAvail_Destroy(pdf_avail); 358 FPDFAvail_Destroy(pdf_avail);
353 359
354 printf("Loaded, parsed and rendered %d pages.\n", page_count); 360 printf("Loaded, parsed and rendered %d pages.\n", renderedPages);
355 } 361 }
356 362
357 int main(int argc, const char* argv[]) { 363 int main(int argc, const char* argv[]) {
358 v8::V8::InitializeICU(); 364 v8::V8::InitializeICU();
359 OutputFormat format = OUTPUT_NONE; 365 OutputFormat format = OUTPUT_NONE;
360 std::list<const char*> files; 366 std::list<const char*> files;
361 if (!ParseCommandLine(argc, argv, &format, &files)) { 367 if (!ParseCommandLine(argc, argv, &format, &files)) {
362 printf("Usage: pdfium_test [OPTION] [FILE]...\n"); 368 printf("Usage: pdfium_test [OPTION] [FILE]...\n");
363 printf("--ppm write page images <pdf-name>.<page-number>.ppm\n"); 369 printf("--ppm write page images <pdf-name>.<page-number>.ppm\n");
364 #ifdef _WIN32 370 #ifdef _WIN32
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } else { 402 } else {
397 RenderPdf(filename, pBuf, len, format); 403 RenderPdf(filename, pBuf, len, format);
398 } 404 }
399 free(pBuf); 405 free(pBuf);
400 } 406 }
401 407
402 FPDF_DestroyLibrary(); 408 FPDF_DestroyLibrary();
403 409
404 return 0; 410 return 0;
405 } 411 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698