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> |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); | 498 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN); |
499 | 499 |
500 double scale = 1.0; | 500 double scale = 1.0; |
501 if (!options.scale_factor_as_string.empty()) { | 501 if (!options.scale_factor_as_string.empty()) { |
502 std::stringstream(options.scale_factor_as_string) >> scale; | 502 std::stringstream(options.scale_factor_as_string) >> scale; |
503 } | 503 } |
504 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); | 504 int width = static_cast<int>(FPDF_GetPageWidth(page) * scale); |
505 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); | 505 int height = static_cast<int>(FPDF_GetPageHeight(page) * scale); |
506 | 506 |
507 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); | 507 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); |
| 508 if (!bitmap) { |
| 509 fprintf(stderr, "Page was too large to be rendered.\n"); |
| 510 bad_pages++; |
| 511 continue; |
| 512 } |
| 513 |
508 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); | 514 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); |
509 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); | 515 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); |
510 rendered_pages ++; | 516 rendered_pages ++; |
511 | 517 |
512 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); | 518 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); |
513 int stride = FPDFBitmap_GetStride(bitmap); | 519 int stride = FPDFBitmap_GetStride(bitmap); |
514 const char* buffer = | 520 const char* buffer = |
515 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); | 521 reinterpret_cast<const char*>(FPDFBitmap_GetBuffer(bitmap)); |
516 | 522 |
517 switch (options.output_format) { | 523 switch (options.output_format) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 RenderPdf(filename, file_contents, file_length, options); | 614 RenderPdf(filename, file_contents, file_length, options); |
609 free(file_contents); | 615 free(file_contents); |
610 } | 616 } |
611 | 617 |
612 FPDF_DestroyLibrary(); | 618 FPDF_DestroyLibrary(); |
613 v8::V8::ShutdownPlatform(); | 619 v8::V8::ShutdownPlatform(); |
614 delete platform; | 620 delete platform; |
615 | 621 |
616 return 0; | 622 return 0; |
617 } | 623 } |
OLD | NEW |