Clean up extension confirmation prompts and make them consistent between Views and...
[chromium-blink-merge.git] / pdf / pdf.h
blob37e72e510be95cffb2768fb3c8e3d049bdadda55
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
3 // found in the LICENSE file.
5 #ifndef PDF_PDF_H_
6 #define PDF_PDF_H_
8 #include "ppapi/c/ppb.h"
9 #include "ppapi/cpp/module.h"
11 namespace chrome_pdf {
13 class PDFModule : public pp::Module {
14 public:
15 PDFModule();
16 virtual ~PDFModule();
18 // pp::Module implementation.
19 virtual bool Init();
20 virtual pp::Instance* CreateInstance(PP_Instance instance);
23 int PPP_InitializeModule(PP_Module module_id,
24 PPB_GetInterface get_browser_interface);
25 void PPP_ShutdownModule();
26 const void* PPP_GetInterface(const char* interface_name);
28 #if defined(OS_WIN)
29 // |pdf_buffer| is the buffer that contains the entire PDF document to be
30 // rendered.
31 // |buffer_size| is the size of |pdf_buffer| in bytes.
32 // |page_number| is the 0-based index of the page to be rendered.
33 // |dc| is the device context to render into.
34 // |dpi| and |dpi_y| is the resolution. If the value is -1, the dpi from the DC
35 // will be used.
36 // |bounds_origin_x|, |bounds_origin_y|, |bounds_width| and |bounds_height|
37 // specify a bounds rectangle within the DC in which to render the PDF
38 // page.
39 // |fit_to_bounds| specifies whether the output should be shrunk to fit the
40 // supplied bounds if the page size is larger than the bounds in any
41 // dimension. If this is false, parts of the PDF page that lie outside
42 // the bounds will be clipped.
43 // |stretch_to_bounds| specifies whether the output should be stretched to fit
44 // the supplied bounds if the page size is smaller than the bounds in any
45 // dimension.
46 // If both |fit_to_bounds| and |stretch_to_bounds| are true, then
47 // |fit_to_bounds| is honored first.
48 // |keep_aspect_ratio| If any scaling is to be done is true, this flag
49 // specifies whether the original aspect ratio of the page should be
50 // preserved while scaling.
51 // |center_in_bounds| specifies whether the final image (after any scaling is
52 // done) should be centered within the given bounds.
53 // |autorotate| specifies whether the final image should be rotated to match
54 // the output bound.
55 // Returns false if the document or the page number are not valid.
56 bool RenderPDFPageToDC(const void* pdf_buffer,
57 int buffer_size,
58 int page_number,
59 HDC dc,
60 int dpi,
61 int bounds_origin_x,
62 int bounds_origin_y,
63 int bounds_width,
64 int bounds_height,
65 bool fit_to_bounds,
66 bool stretch_to_bounds,
67 bool keep_aspect_ratio,
68 bool center_in_bounds,
69 bool autorotate);
70 #endif
71 // |page_count| and |max_page_width| are optional and can be NULL.
72 // Returns false if the document is not valid.
73 bool GetPDFDocInfo(const void* pdf_buffer,
74 int buffer_size, int* page_count,
75 double* max_page_width);
77 // Gets the dimensions of a specific page in a document.
78 // |pdf_buffer| is the buffer that contains the entire PDF document to be
79 // rendered.
80 // |pdf_buffer_size| is the size of |pdf_buffer| in bytes.
81 // |page_number| is the page number that the function will get the dimensions
82 // of.
83 // |width| is the output for the width of the page in points.
84 // |height| is the output for the height of the page in points.
85 // Returns false if the document or the page number are not valid.
86 bool GetPDFPageSizeByIndex(const void* pdf_buffer,
87 int pdf_buffer_size, int page_number,
88 double* width, double* height);
90 // Renders PDF page into 4-byte per pixel BGRA color bitmap.
91 // |pdf_buffer| is the buffer that contains the entire PDF document to be
92 // rendered.
93 // |pdf_buffer_size| is the size of |pdf_buffer| in bytes.
94 // |page_number| is the 0-based index of the page to be rendered.
95 // |bitmap_buffer| is the output buffer for bitmap.
96 // |bitmap_width| is the width of the output bitmap.
97 // |bitmap_height| is the height of the output bitmap.
98 // |dpi| is the resolutions.
99 // |autorotate| specifies whether the final image should be rotated to match
100 // the output bound.
101 // Returns false if the document or the page number are not valid.
102 bool RenderPDFPageToBitmap(const void* pdf_buffer,
103 int pdf_buffer_size,
104 int page_number,
105 void* bitmap_buffer,
106 int bitmap_width,
107 int bitmap_height,
108 int dpi,
109 bool autorotate);
111 } // namespace chrome_pdf
113 #endif // PDF_PDF_H_