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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( | 192 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( |
193 chrome_pdf::PDFEngineExports::Create()); | 193 chrome_pdf::PDFEngineExports::Create()); |
194 bool ret = engine_exports->GetPDFDocInfo( | 194 bool ret = engine_exports->GetPDFDocInfo( |
195 pdf_buffer, buffer_size, page_count, max_page_width); | 195 pdf_buffer, buffer_size, page_count, max_page_width); |
196 if (!g_sdk_initialized_via_pepper) { | 196 if (!g_sdk_initialized_via_pepper) { |
197 chrome_pdf::ShutdownSDK(); | 197 chrome_pdf::ShutdownSDK(); |
198 } | 198 } |
199 return ret; | 199 return ret; |
200 } | 200 } |
201 | 201 |
202 PDF_USED PP_EXPORT | |
203 bool GetPDFPageSizeByIndex(const void* pdf_buffer, | |
204 int buffer_size, int index, | |
205 double* width, double* height) { | |
206 if (!g_sdk_initialized_via_pepper) { | |
207 void* data = NULL; | |
208 #if defined(OS_WIN) | |
209 data = g_hmodule; | |
210 #endif | |
211 if (!chrome_pdf::InitializeSDK(data)) | |
212 return false; | |
213 } | |
214 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( | |
215 chrome_pdf::PDFEngineExports::Create()); | |
216 bool ret = engine_exports->GetPDFPageSizeByIndex( | |
217 pdf_buffer, buffer_size, index, width, height); | |
218 if(!g_sdk_initialized_via_pepper) | |
Dan Beam
2014/07/08 04:25:14
if (
^ \s
| |
219 chrome_pdf::ShutdownSDK(); | |
220 return ret; | |
221 } | |
222 | |
202 // Renders PDF page into 4-byte per pixel BGRA color bitmap. | 223 // Renders PDF page into 4-byte per pixel BGRA color bitmap. |
203 // |pdf_buffer| is the buffer that contains the entire PDF document to be | 224 // |pdf_buffer| is the buffer that contains the entire PDF document to be |
204 // rendered. | 225 // rendered. |
205 // |pdf_buffer_size| is the size of pdf_buffer in bytes. | 226 // |pdf_buffer_size| is the size of pdf_buffer in bytes. |
206 // |page_number| is the 0-based index of the page to be rendered. | 227 // |page_number| is the 0-based index of the page to be rendered. |
207 // |bitmap_buffer| is the output buffer for bitmap. | 228 // |bitmap_buffer| is the output buffer for bitmap. |
208 // |bitmap_width| is the width of the output bitmap. | 229 // |bitmap_width| is the width of the output bitmap. |
209 // |bitmap_height| is the height of the output bitmap. | 230 // |bitmap_height| is the height of the output bitmap. |
210 // |dpi| is the resolutions. | 231 // |dpi| is the resolutions. |
211 // |autorotate| specifies whether the final image should be rotated to match | 232 // |autorotate| specifies whether the final image should be rotated to match |
(...skipping 23 matching lines...) Expand all Loading... | |
235 autorotate); | 256 autorotate); |
236 bool ret = engine_exports->RenderPDFPageToBitmap( | 257 bool ret = engine_exports->RenderPDFPageToBitmap( |
237 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer); | 258 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer); |
238 if (!g_sdk_initialized_via_pepper) { | 259 if (!g_sdk_initialized_via_pepper) { |
239 chrome_pdf::ShutdownSDK(); | 260 chrome_pdf::ShutdownSDK(); |
240 } | 261 } |
241 return ret; | 262 return ret; |
242 } | 263 } |
243 | 264 |
244 } // extern "C" | 265 } // extern "C" |
OLD | NEW |