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 #include <wchar.h> | 9 #include <wchar.h> |
10 | 10 |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); | 511 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); |
512 | 512 |
513 double scale = 1.0; | 513 double scale = 1.0; |
514 if (!options.scale_factor_as_string.empty()) { | 514 if (!options.scale_factor_as_string.empty()) { |
515 std::stringstream(options.scale_factor_as_string) >> scale; | 515 std::stringstream(options.scale_factor_as_string) >> scale; |
516 } | 516 } |
517 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); | 517 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); |
518 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); | 518 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); |
519 | 519 |
520 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); | 520 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); |
| 521 if (!bitmap) { |
| 522 fprintf(stderr, "Page was too large to be rendered.\n"); |
| 523 bad_pages++; |
| 524 continue; |
| 525 } |
| 526 |
521 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); | 527 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); |
522 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); | 528 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); |
523 rendered_pages ++; | 529 rendered_pages ++; |
524 | 530 |
525 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); | 531 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); |
526 int stride = FPDFBitmap_GetStride(bitmap); | 532 int stride = FPDFBitmap_GetStride(bitmap); |
527 const char* buffer = | 533 const char* buffer = |
528 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); | 534 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); |
529 | 535 |
530 switch (options.output_format) { | 536 switch (options.output_format) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 RenderPdf(filename, file_contents, file_length, options); | 627 RenderPdf(filename, file_contents, file_length, options); |
622 free(file_contents); | 628 free(file_contents); |
623 } | 629 } |
624 | 630 |
625 FPDF_DestroyLibrary(); | 631 FPDF_DestroyLibrary(); |
626 v8::V8::ShutdownPlatform(); | 632 v8::V8::ShutdownPlatform(); |
627 delete platform; | 633 delete platform; |
628 | 634 |
629 return 0; | 635 return 0; |
630 } | 636 } |
OLD | NEW |