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 // Gets the dimensions of a specific page in a document. | |
203 // |pdf_buffer| is the buffer that contains the entire PDF document to be | |
204 // rendered. | |
205 // |pdf_buffer_size| is the size of the pdf_buffer in bytes. | |
Lei Zhang
2014/07/09 21:59:51
the pdf_buffer -> |pdf_buffer|
ivandavid
2014/07/09 22:53:40
Done.
| |
206 // |page_number| is the page number that the function will get the dimensions | |
207 // of. | |
208 // |width| is the output for the width of the page in points. | |
209 // |height| is the output for the height of the page in points. | |
210 // Returns false if the document or the page number are not valid. | |
Dan Beam
2014/07/09 22:18:21
^ I'd say put this doc comment on the interface
ivandavid
2014/07/09 22:53:40
OK. I put the comment in pdf_engine.h PDFEngineExp
| |
211 PDF_USED PP_EXPORT | |
212 bool GetPDFPageSizeByIndex(const void* pdf_buffer, | |
213 int pdf_buffer_size, int page_number, | |
214 double* width, double* height) { | |
215 if (!g_sdk_initialized_via_pepper) { | |
216 void* data = NULL; | |
217 #if defined(OS_WIN) | |
218 data = g_hmodule; | |
219 #endif | |
220 if (!chrome_pdf::InitializeSDK(data)) | |
221 return false; | |
222 } | |
223 scoped_ptr<chrome_pdf::PDFEngineExports> engine_exports( | |
224 chrome_pdf::PDFEngineExports::Create()); | |
225 bool ret = engine_exports->GetPDFPageSizeByIndex( | |
226 pdf_buffer, pdf_buffer_size, page_number, width, height); | |
227 if (!g_sdk_initialized_via_pepper) | |
228 chrome_pdf::ShutdownSDK(); | |
229 return ret; | |
230 } | |
231 | |
202 // Renders PDF page into 4-byte per pixel BGRA color bitmap. | 232 // 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 | 233 // |pdf_buffer| is the buffer that contains the entire PDF document to be |
204 // rendered. | 234 // rendered. |
205 // |pdf_buffer_size| is the size of pdf_buffer in bytes. | 235 // |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. | 236 // |page_number| is the 0-based index of the page to be rendered. |
207 // |bitmap_buffer| is the output buffer for bitmap. | 237 // |bitmap_buffer| is the output buffer for bitmap. |
208 // |bitmap_width| is the width of the output bitmap. | 238 // |bitmap_width| is the width of the output bitmap. |
209 // |bitmap_height| is the height of the output bitmap. | 239 // |bitmap_height| is the height of the output bitmap. |
210 // |dpi| is the resolutions. | 240 // |dpi| is the resolutions. |
211 // |autorotate| specifies whether the final image should be rotated to match | 241 // |autorotate| specifies whether the final image should be rotated to match |
(...skipping 23 matching lines...) Expand all Loading... | |
235 autorotate); | 265 autorotate); |
236 bool ret = engine_exports->RenderPDFPageToBitmap( | 266 bool ret = engine_exports->RenderPDFPageToBitmap( |
237 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer); | 267 pdf_buffer, pdf_buffer_size, page_number, settings, bitmap_buffer); |
238 if (!g_sdk_initialized_via_pepper) { | 268 if (!g_sdk_initialized_via_pepper) { |
239 chrome_pdf::ShutdownSDK(); | 269 chrome_pdf::ShutdownSDK(); |
240 } | 270 } |
241 return ret; | 271 return ret; |
242 } | 272 } |
243 | 273 |
244 } // extern "C" | 274 } // extern "C" |
OLD | NEW |