| 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 "pdf/pdf.h" | 5 #include "pdf/pdf.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool fit_to_bounds, | 97 bool fit_to_bounds, |
| 98 bool stretch_to_bounds, | 98 bool stretch_to_bounds, |
| 99 bool keep_aspect_ratio, | 99 bool keep_aspect_ratio, |
| 100 bool center_in_bounds, | 100 bool center_in_bounds, |
| 101 bool autorotate) { | 101 bool autorotate) { |
| 102 if (!g_sdk_initialized_via_pepper) { | 102 if (!g_sdk_initialized_via_pepper) { |
| 103 if (!chrome_pdf::InitializeSDK()) { | 103 if (!chrome_pdf::InitializeSDK()) { |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( | 107 chrome_pdf::PDFEngineExports* engine_exports = |
| 108 chrome_pdf::PDFEngineExports::Create()); | 108 chrome_pdf::PDFEngineExports::Get(); |
| 109 chrome_pdf::PDFEngineExports::RenderingSettings settings( | 109 chrome_pdf::PDFEngineExports::RenderingSettings settings( |
| 110 dpi, dpi, pp::Rect(bounds_origin_x, bounds_origin_y, bounds_width, | 110 dpi, dpi, pp::Rect(bounds_origin_x, bounds_origin_y, bounds_width, |
| 111 bounds_height), | 111 bounds_height), |
| 112 fit_to_bounds, stretch_to_bounds, keep_aspect_ratio, center_in_bounds, | 112 fit_to_bounds, stretch_to_bounds, keep_aspect_ratio, center_in_bounds, |
| 113 autorotate); | 113 autorotate); |
| 114 bool ret = engine_exports->RenderPDFPageToDC(pdf_buffer, buffer_size, | 114 bool ret = engine_exports->RenderPDFPageToDC(pdf_buffer, buffer_size, |
| 115 page_number, settings, dc); | 115 page_number, settings, dc); |
| 116 if (!g_sdk_initialized_via_pepper) { | 116 if (!g_sdk_initialized_via_pepper) { |
| 117 chrome_pdf::ShutdownSDK(); | 117 chrome_pdf::ShutdownSDK(); |
| 118 } | 118 } |
| 119 return ret; | 119 return ret; |
| 120 } | 120 } |
| 121 | 121 |
| 122 #endif // OS_WIN | 122 #endif // OS_WIN |
| 123 | 123 |
| 124 bool GetPDFDocInfo(const void* pdf_buffer, | 124 bool GetPDFDocInfo(const void* pdf_buffer, |
| 125 int buffer_size, int* page_count, | 125 int buffer_size, int* page_count, |
| 126 double* max_page_width) { | 126 double* max_page_width) { |
| 127 if (!g_sdk_initialized_via_pepper) { | 127 if (!g_sdk_initialized_via_pepper) { |
| 128 if (!chrome_pdf::InitializeSDK()) | 128 if (!chrome_pdf::InitializeSDK()) |
| 129 return false; | 129 return false; |
| 130 } | 130 } |
| 131 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( | 131 chrome_pdf::PDFEngineExports* engine_exports = |
| 132 chrome_pdf::PDFEngineExports::Create()); | 132 chrome_pdf::PDFEngineExports::Get(); |
| 133 bool ret = engine_exports->GetPDFDocInfo( | 133 bool ret = engine_exports->GetPDFDocInfo( |
| 134 pdf_buffer, buffer_size, page_count, max_page_width); | 134 pdf_buffer, buffer_size, page_count, max_page_width); |
| 135 if (!g_sdk_initialized_via_pepper) { | 135 if (!g_sdk_initialized_via_pepper) { |
| 136 chrome_pdf::ShutdownSDK(); | 136 chrome_pdf::ShutdownSDK(); |
| 137 } | 137 } |
| 138 return ret; | 138 return ret; |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool GetPDFPageSizeByIndex(const void* pdf_buffer, | 141 bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
| 142 int pdf_buffer_size, int page_number, | 142 int pdf_buffer_size, int page_number, |
| 143 double* width, double* height) { | 143 double* width, double* height) { |
| 144 if (!g_sdk_initialized_via_pepper) { | 144 if (!g_sdk_initialized_via_pepper) { |
| 145 if (!chrome_pdf::InitializeSDK()) | 145 if (!chrome_pdf::InitializeSDK()) |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( | 148 chrome_pdf::PDFEngineExports* engine_exports = |
| 149 chrome_pdf::PDFEngineExports::Create()); | 149 chrome_pdf::PDFEngineExports::Get(); |
| 150 bool ret = engine_exports->GetPDFPageSizeByIndex( | 150 bool ret = engine_exports->GetPDFPageSizeByIndex( |
| 151 pdf_buffer, pdf_buffer_size, page_number, width, height); | 151 pdf_buffer, pdf_buffer_size, page_number, width, height); |
| 152 if (!g_sdk_initialized_via_pepper) | 152 if (!g_sdk_initialized_via_pepper) |
| 153 chrome_pdf::ShutdownSDK(); | 153 chrome_pdf::ShutdownSDK(); |
| 154 return ret; | 154 return ret; |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool RenderPDFPageToBitmap(const void* pdf_buffer, | 157 bool RenderPDFPageToBitmap(const void* pdf_buffer, |
| 158 int pdf_buffer_size, | 158 int pdf_buffer_size, |
| 159 int page_number, | 159 int page_number, |
| 160 void* bitmap_buffer, | 160 void* bitmap_buffer, |
| 161 int bitmap_width, | 161 int bitmap_width, |
| 162 int bitmap_height, | 162 int bitmap_height, |
| 163 int dpi, | 163 int dpi, |
| 164 bool autorotate) { | 164 bool autorotate) { |
| 165 if (!g_sdk_initialized_via_pepper) { | 165 if (!g_sdk_initialized_via_pepper) { |
| 166 if (!chrome_pdf::InitializeSDK()) | 166 if (!chrome_pdf::InitializeSDK()) |
| 167 return false; | 167 return false; |
| 168 } | 168 } |
| 169 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( | 169 chrome_pdf::PDFEngineExports* engine_exports = |
| 170 chrome_pdf::PDFEngineExports::Create()); | 170 chrome_pdf::PDFEngineExports::Get(); |
| 171 chrome_pdf::PDFEngineExports::RenderingSettings settings( | 171 chrome_pdf::PDFEngineExports::RenderingSettings settings( |
| 172 dpi, dpi, pp::Rect(bitmap_width, bitmap_height), true, false, true, true, | 172 dpi, dpi, pp::Rect(bitmap_width, bitmap_height), true, false, true, true, |
| 173 autorotate); | 173 autorotate); |
| 174 bool ret = engine_exports->RenderPDFPageToBitmap( | 174 bool ret = engine_exports->RenderPDFPageToBitmap( |
| 175 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer); | 175 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer); |
| 176 if (!g_sdk_initialized_via_pepper) { | 176 if (!g_sdk_initialized_via_pepper) { |
| 177 chrome_pdf::ShutdownSDK(); | 177 chrome_pdf::ShutdownSDK(); |
| 178 } | 178 } |
| 179 return ret; | 179 return ret; |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace chrome_pdf | 182 } // namespace chrome_pdf |
| OLD | NEW |