Index: chrome/browser/printing/print_preview_pdf_generated_browsertest.cc |
diff --git a/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc b/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc |
index 8d3f3b15d2c2e21b9e1683c4b8a9fd97b2f774ae..381c17ac30efd0b05d6e743c3e5355057e2f3950 100644 |
--- a/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc |
+++ b/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc |
@@ -335,29 +335,25 @@ class PrintPreviewPdfGeneratedBrowserTest : public InProcessBrowserTest { |
// Converts the PDF to a PNG file so that the layout test can do an image |
// diff on this image and a reference image. |
void PdfToPng() { |
- int num_pages; |
- double max_width_in_points = 0; |
- std::vector<uint8_t> bitmap_data; |
- double total_height_in_pixels = 0; |
std::string pdf_data; |
- |
ASSERT_TRUE(base::ReadFileToString(pdf_file_save_path_, &pdf_data)); |
- ASSERT_TRUE(chrome_pdf::GetPDFDocInfo(pdf_data.data(), |
- pdf_data.size(), |
- &num_pages, |
- &max_width_in_points)); |
+ int num_pages; |
+ double max_width_in_points = 0; |
+ void* pdf_handle = nullptr; |
+ ASSERT_TRUE(chrome_pdf::GetPDFDocInfo(pdf_data.data(), pdf_data.size(), |
+ &num_pages, &max_width_in_points, |
+ &pdf_handle)); |
ASSERT_GT(num_pages, 0); |
double max_width_in_pixels = |
ConvertUnitDouble(max_width_in_points, kPointsPerInch, kDpi); |
+ std::vector<uint8_t> bitmap_data; |
+ double total_height_in_pixels = 0; |
for (int i = 0; i < num_pages; ++i) { |
double width_in_points, height_in_points; |
- ASSERT_TRUE(chrome_pdf::GetPDFPageSizeByIndex(pdf_data.data(), |
- pdf_data.size(), |
- i, |
- &width_in_points, |
- &height_in_points)); |
+ ASSERT_TRUE(chrome_pdf::GetPDFPageSizeByIndex( |
+ pdf_handle, i, &width_in_points, &height_in_points)); |
double width_in_pixels = ConvertUnitDouble( |
width_in_points, kPointsPerInch, kDpi); |
@@ -388,14 +384,9 @@ class PrintPreviewPdfGeneratedBrowserTest : public InProcessBrowserTest { |
kColorChannels * settings.area().size().GetArea()); |
ASSERT_TRUE(chrome_pdf::RenderPDFPageToBitmap( |
- pdf_data.data(), |
- pdf_data.size(), |
- i, |
- page_bitmap_data.data(), |
- settings.area().size().width(), |
- settings.area().size().height(), |
- settings.dpi(), |
- true)); |
+ pdf_handle, i, page_bitmap_data.data(), |
+ settings.area().size().width(), settings.area().size().height(), |
+ settings.dpi(), true)); |
FillPng(&page_bitmap_data, |
width_in_pixels, |
max_width_in_pixels, |
@@ -405,6 +396,7 @@ class PrintPreviewPdfGeneratedBrowserTest : public InProcessBrowserTest { |
page_bitmap_data.end()); |
} |
+ chrome_pdf::ReleasePDFHandle(pdf_handle); |
CreatePng(bitmap_data, max_width_in_pixels, total_height_in_pixels); |
} |