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 #ifndef PDF_PDF_H_ | 5 #ifndef PDF_PDF_H_ |
6 #define PDF_PDF_H_ | 6 #define PDF_PDF_H_ |
7 | 7 |
8 #include "ppapi/c/ppb.h" | 8 #include "ppapi/c/ppb.h" |
9 #include "ppapi/cpp/module.h" | 9 #include "ppapi/cpp/module.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 bool Init() override; | 29 bool Init() override; |
30 pp::Instance* CreateInstance(PP_Instance instance) override; | 30 pp::Instance* CreateInstance(PP_Instance instance) override; |
31 }; | 31 }; |
32 | 32 |
33 int PPP_InitializeModule(PP_Module module_id, | 33 int PPP_InitializeModule(PP_Module module_id, |
34 PPB_GetInterface get_browser_interface); | 34 PPB_GetInterface get_browser_interface); |
35 void PPP_ShutdownModule(); | 35 void PPP_ShutdownModule(); |
36 const void* PPP_GetInterface(const char* interface_name); | 36 const void* PPP_GetInterface(const char* interface_name); |
37 | 37 |
38 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
39 // |pdf_handle| is the handle to the PDF document. | 39 // |pdf_buffer| is the buffer that contains the entire PDF document to be |
| 40 // rendered. |
| 41 // |buffer_size| is the size of |pdf_buffer| in bytes. |
40 // |page_number| is the 0-based index of the page to be rendered. | 42 // |page_number| is the 0-based index of the page to be rendered. |
41 // |dc| is the device context to render into. | 43 // |dc| is the device context to render into. |
42 // |dpi| and |dpi_y| is the resolution. If the value is -1, the dpi from the DC | 44 // |dpi| and |dpi_y| is the resolution. If the value is -1, the dpi from the DC |
43 // will be used. | 45 // will be used. |
44 // |bounds_origin_x|, |bounds_origin_y|, |bounds_width| and |bounds_height| | 46 // |bounds_origin_x|, |bounds_origin_y|, |bounds_width| and |bounds_height| |
45 // specify a bounds rectangle within the DC in which to render the PDF | 47 // specify a bounds rectangle within the DC in which to render the PDF |
46 // page. | 48 // page. |
47 // |fit_to_bounds| specifies whether the output should be shrunk to fit the | 49 // |fit_to_bounds| specifies whether the output should be shrunk to fit the |
48 // supplied bounds if the page size is larger than the bounds in any | 50 // supplied bounds if the page size is larger than the bounds in any |
49 // dimension. If this is false, parts of the PDF page that lie outside | 51 // dimension. If this is false, parts of the PDF page that lie outside |
50 // the bounds will be clipped. | 52 // the bounds will be clipped. |
51 // |stretch_to_bounds| specifies whether the output should be stretched to fit | 53 // |stretch_to_bounds| specifies whether the output should be stretched to fit |
52 // the supplied bounds if the page size is smaller than the bounds in any | 54 // the supplied bounds if the page size is smaller than the bounds in any |
53 // dimension. | 55 // dimension. |
54 // If both |fit_to_bounds| and |stretch_to_bounds| are true, then | 56 // If both |fit_to_bounds| and |stretch_to_bounds| are true, then |
55 // |fit_to_bounds| is honored first. | 57 // |fit_to_bounds| is honored first. |
56 // |keep_aspect_ratio| If any scaling is to be done is true, this flag | 58 // |keep_aspect_ratio| If any scaling is to be done is true, this flag |
57 // specifies whether the original aspect ratio of the page should be | 59 // specifies whether the original aspect ratio of the page should be |
58 // preserved while scaling. | 60 // preserved while scaling. |
59 // |center_in_bounds| specifies whether the final image (after any scaling is | 61 // |center_in_bounds| specifies whether the final image (after any scaling is |
60 // done) should be centered within the given bounds. | 62 // done) should be centered within the given bounds. |
61 // |autorotate| specifies whether the final image should be rotated to match | 63 // |autorotate| specifies whether the final image should be rotated to match |
62 // the output bound. | 64 // the output bound. |
63 // Returns false if the document or the page number are not valid. | 65 // Returns false if the document or the page number are not valid. |
64 bool RenderPDFPageToDC(void* pdf_handle, | 66 bool RenderPDFPageToDC(const void* pdf_buffer, |
| 67 int buffer_size, |
65 int page_number, | 68 int page_number, |
66 HDC dc, | 69 HDC dc, |
67 int dpi, | 70 int dpi, |
68 int bounds_origin_x, | 71 int bounds_origin_x, |
69 int bounds_origin_y, | 72 int bounds_origin_y, |
70 int bounds_width, | 73 int bounds_width, |
71 int bounds_height, | 74 int bounds_height, |
72 bool fit_to_bounds, | 75 bool fit_to_bounds, |
73 bool stretch_to_bounds, | 76 bool stretch_to_bounds, |
74 bool keep_aspect_ratio, | 77 bool keep_aspect_ratio, |
75 bool center_in_bounds, | 78 bool center_in_bounds, |
76 bool autorotate); | 79 bool autorotate); |
77 | 80 |
78 void SetPDFEnsureTypefaceCharactersAccessible( | 81 void SetPDFEnsureTypefaceCharactersAccessible( |
79 PDFEnsureTypefaceCharactersAccessible func); | 82 PDFEnsureTypefaceCharactersAccessible func); |
80 | 83 |
81 void SetPDFUseGDIPrinting(bool enable); | 84 void SetPDFUseGDIPrinting(bool enable); |
82 #endif // defined(OS_WIN) | 85 #endif // defined(OS_WIN) |
83 | 86 |
84 // All the out parameters are optional and can be NULL. | 87 // |page_count| and |max_page_width| are optional and can be NULL. |
85 // Returns false if the document is not valid. | 88 // Returns false if the document is not valid. |
86 // Returns true on success. In which case, if |pdf_handle| is not NULL, then | |
87 // the handle is guaranteed to be valid and not NULL. The caller takes | |
88 // ownership of |pdf_handle| and must call ReleasePDFHandle() on it when done. | |
89 bool GetPDFDocInfo(const void* pdf_buffer, | 89 bool GetPDFDocInfo(const void* pdf_buffer, |
90 int buffer_size, | 90 int buffer_size, |
91 int* page_count, | 91 int* page_count, |
92 double* max_page_width, | 92 double* max_page_width); |
93 void** pdf_handle); | |
94 | |
95 // Releases the handle received from GetPDFDocInfo(). | |
96 // |pdf_handle| can be NULL. | |
97 void ReleasePDFHandle(void* pdf_handle); | |
98 | 93 |
99 // Gets the dimensions of a specific page in a document. | 94 // Gets the dimensions of a specific page in a document. |
100 // |pdf_handle| is the handle to the PDF document. | 95 // |pdf_buffer| is the buffer that contains the entire PDF document to be |
| 96 // rendered. |
| 97 // |pdf_buffer_size| is the size of |pdf_buffer| in bytes. |
101 // |page_number| is the page number that the function will get the dimensions | 98 // |page_number| is the page number that the function will get the dimensions |
102 // of. | 99 // of. |
103 // |width| is the output for the width of the page in points. | 100 // |width| is the output for the width of the page in points. |
104 // |height| is the output for the height of the page in points. | 101 // |height| is the output for the height of the page in points. |
105 // Returns false if the document or the page number are not valid. | 102 // Returns false if the document or the page number are not valid. |
106 bool GetPDFPageSizeByIndex(void* pdf_handle, | 103 bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
| 104 int pdf_buffer_size, |
107 int page_number, | 105 int page_number, |
108 double* width, | 106 double* width, |
109 double* height); | 107 double* height); |
110 | 108 |
111 // Renders PDF page into 4-byte per pixel BGRA color bitmap. | 109 // Renders PDF page into 4-byte per pixel BGRA color bitmap. |
112 // |pdf_handle| is the handle to the PDF document. | 110 // |pdf_buffer| is the buffer that contains the entire PDF document to be |
| 111 // rendered. |
| 112 // |pdf_buffer_size| is the size of |pdf_buffer| in bytes. |
113 // |page_number| is the 0-based index of the page to be rendered. | 113 // |page_number| is the 0-based index of the page to be rendered. |
114 // |bitmap_buffer| is the output buffer for bitmap. | 114 // |bitmap_buffer| is the output buffer for bitmap. |
115 // |bitmap_width| is the width of the output bitmap. | 115 // |bitmap_width| is the width of the output bitmap. |
116 // |bitmap_height| is the height of the output bitmap. | 116 // |bitmap_height| is the height of the output bitmap. |
117 // |dpi| is the resolutions. | 117 // |dpi| is the resolutions. |
118 // |autorotate| specifies whether the final image should be rotated to match | 118 // |autorotate| specifies whether the final image should be rotated to match |
119 // the output bound. | 119 // the output bound. |
120 // Returns false if the document or the page number are not valid. | 120 // Returns false if the document or the page number are not valid. |
121 bool RenderPDFPageToBitmap(void* pdf_handle, | 121 bool RenderPDFPageToBitmap(const void* pdf_buffer, |
| 122 int pdf_buffer_size, |
122 int page_number, | 123 int page_number, |
123 void* bitmap_buffer, | 124 void* bitmap_buffer, |
124 int bitmap_width, | 125 int bitmap_width, |
125 int bitmap_height, | 126 int bitmap_height, |
126 int dpi, | 127 int dpi, |
127 bool autorotate); | 128 bool autorotate); |
128 | 129 |
129 } // namespace chrome_pdf | 130 } // namespace chrome_pdf |
130 | 131 |
131 #endif // PDF_PDF_H_ | 132 #endif // PDF_PDF_H_ |
OLD | NEW |