Chromium Code Reviews

Side by Side Diff: pdf/pdf.h

Issue 2508563003: Printing: Load the source PDF only once. (Closed)
Patch Set: More renaming Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « chrome/utility/printing_handler.cc ('k') | pdf/pdf.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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...)
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_buffer| is the buffer that contains the entire PDF document to be 39 // |pdf_handle| is the handle to the PDF document.
40 // rendered.
41 // |buffer_size| is the size of |pdf_buffer| in bytes.
42 // |page_number| is the 0-based index of the page to be rendered. 40 // |page_number| is the 0-based index of the page to be rendered.
43 // |dc| is the device context to render into. 41 // |dc| is the device context to render into.
44 // |dpi| and |dpi_y| is the resolution. If the value is -1, the dpi from the DC 42 // |dpi| and |dpi_y| is the resolution. If the value is -1, the dpi from the DC
45 // will be used. 43 // will be used.
46 // |bounds_origin_x|, |bounds_origin_y|, |bounds_width| and |bounds_height| 44 // |bounds_origin_x|, |bounds_origin_y|, |bounds_width| and |bounds_height|
47 // specify a bounds rectangle within the DC in which to render the PDF 45 // specify a bounds rectangle within the DC in which to render the PDF
48 // page. 46 // page.
49 // |fit_to_bounds| specifies whether the output should be shrunk to fit the 47 // |fit_to_bounds| specifies whether the output should be shrunk to fit the
50 // supplied bounds if the page size is larger than the bounds in any 48 // supplied bounds if the page size is larger than the bounds in any
51 // dimension. If this is false, parts of the PDF page that lie outside 49 // dimension. If this is false, parts of the PDF page that lie outside
52 // the bounds will be clipped. 50 // the bounds will be clipped.
53 // |stretch_to_bounds| specifies whether the output should be stretched to fit 51 // |stretch_to_bounds| specifies whether the output should be stretched to fit
54 // the supplied bounds if the page size is smaller than the bounds in any 52 // the supplied bounds if the page size is smaller than the bounds in any
55 // dimension. 53 // dimension.
56 // If both |fit_to_bounds| and |stretch_to_bounds| are true, then 54 // If both |fit_to_bounds| and |stretch_to_bounds| are true, then
57 // |fit_to_bounds| is honored first. 55 // |fit_to_bounds| is honored first.
58 // |keep_aspect_ratio| If any scaling is to be done is true, this flag 56 // |keep_aspect_ratio| If any scaling is to be done is true, this flag
59 // specifies whether the original aspect ratio of the page should be 57 // specifies whether the original aspect ratio of the page should be
60 // preserved while scaling. 58 // preserved while scaling.
61 // |center_in_bounds| specifies whether the final image (after any scaling is 59 // |center_in_bounds| specifies whether the final image (after any scaling is
62 // done) should be centered within the given bounds. 60 // done) should be centered within the given bounds.
63 // |autorotate| specifies whether the final image should be rotated to match 61 // |autorotate| specifies whether the final image should be rotated to match
64 // the output bound. 62 // the output bound.
65 // Returns false if the document or the page number are not valid. 63 // Returns false if the document or the page number are not valid.
66 bool RenderPDFPageToDC(const void* pdf_buffer, 64 bool RenderPDFPageToDC(void* pdf_handle,
67 int buffer_size,
68 int page_number, 65 int page_number,
69 HDC dc, 66 HDC dc,
70 int dpi, 67 int dpi,
71 int bounds_origin_x, 68 int bounds_origin_x,
72 int bounds_origin_y, 69 int bounds_origin_y,
73 int bounds_width, 70 int bounds_width,
74 int bounds_height, 71 int bounds_height,
75 bool fit_to_bounds, 72 bool fit_to_bounds,
76 bool stretch_to_bounds, 73 bool stretch_to_bounds,
77 bool keep_aspect_ratio, 74 bool keep_aspect_ratio,
78 bool center_in_bounds, 75 bool center_in_bounds,
79 bool autorotate); 76 bool autorotate);
80 77
81 void SetPDFEnsureTypefaceCharactersAccessible( 78 void SetPDFEnsureTypefaceCharactersAccessible(
82 PDFEnsureTypefaceCharactersAccessible func); 79 PDFEnsureTypefaceCharactersAccessible func);
83 80
84 void SetPDFUseGDIPrinting(bool enable); 81 void SetPDFUseGDIPrinting(bool enable);
85 #endif // defined(OS_WIN) 82 #endif // defined(OS_WIN)
86 83
87 // |page_count| and |max_page_width| are optional and can be NULL. 84 // All the out parameters are optional and can be NULL.
88 // Returns false if the document is not valid. 85 // 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, int* page_count, 90 int buffer_size,
91 double* max_page_width); 91 int* page_count,
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);
92 98
93 // Gets the dimensions of a specific page in a document. 99 // Gets the dimensions of a specific page in a document.
94 // |pdf_buffer| is the buffer that contains the entire PDF document to be 100 // |pdf_handle| is the handle to the PDF document.
95 // rendered.
96 // |pdf_buffer_size| is the size of |pdf_buffer| in bytes.
97 // |page_number| is the page number that the function will get the dimensions 101 // |page_number| is the page number that the function will get the dimensions
98 // of. 102 // of.
99 // |width| is the output for the width of the page in points. 103 // |width| is the output for the width of the page in points.
100 // |height| is the output for the height of the page in points. 104 // |height| is the output for the height of the page in points.
101 // Returns false if the document or the page number are not valid. 105 // Returns false if the document or the page number are not valid.
102 bool GetPDFPageSizeByIndex(const void* pdf_buffer, 106 bool GetPDFPageSizeByIndex(void* pdf_handle,
103 int pdf_buffer_size, int page_number, 107 int page_number,
104 double* width, double* height); 108 double* width,
109 double* height);
105 110
106 // Renders PDF page into 4-byte per pixel BGRA color bitmap. 111 // Renders PDF page into 4-byte per pixel BGRA color bitmap.
107 // |pdf_buffer| is the buffer that contains the entire PDF document to be 112 // |pdf_handle| is the handle to the PDF document.
108 // rendered.
109 // |pdf_buffer_size| is the size of |pdf_buffer| in bytes.
110 // |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.
111 // |bitmap_buffer| is the output buffer for bitmap. 114 // |bitmap_buffer| is the output buffer for bitmap.
112 // |bitmap_width| is the width of the output bitmap. 115 // |bitmap_width| is the width of the output bitmap.
113 // |bitmap_height| is the height of the output bitmap. 116 // |bitmap_height| is the height of the output bitmap.
114 // |dpi| is the resolutions. 117 // |dpi| is the resolutions.
115 // |autorotate| specifies whether the final image should be rotated to match 118 // |autorotate| specifies whether the final image should be rotated to match
116 // the output bound. 119 // the output bound.
117 // 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.
118 bool RenderPDFPageToBitmap(const void* pdf_buffer, 121 bool RenderPDFPageToBitmap(void* pdf_handle,
119 int pdf_buffer_size,
120 int page_number, 122 int page_number,
121 void* bitmap_buffer, 123 void* bitmap_buffer,
122 int bitmap_width, 124 int bitmap_width,
123 int bitmap_height, 125 int bitmap_height,
124 int dpi, 126 int dpi,
125 bool autorotate); 127 bool autorotate);
126 128
127 } // namespace chrome_pdf 129 } // namespace chrome_pdf
128 130
129 #endif // PDF_PDF_H_ 131 #endif // PDF_PDF_H_
OLDNEW
« no previous file with comments | « chrome/utility/printing_handler.cc ('k') | pdf/pdf.cc » ('j') | no next file with comments »

Powered by Google App Engine