blob: 38ef1130ab8534b7f3251ad50593314eb76f915d [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium 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.
Tom Sepez9857e202015-05-13 17:09:26 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez9857e202015-05-13 17:09:26 -07007#ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_
8#define PUBLIC_FPDF_TRANSFORMPAGE_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Dan Sinclair85c8e7f2016-11-21 13:50:32 -050010// NOLINTNEXTLINE(build/include)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070011#include "fpdfview.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070012
Tom Sepezcf22eb82015-05-12 17:28:08 -070013#ifdef __cplusplus
14extern "C" {
15#endif
16
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070017/**
Lei Zhangf958f352018-06-08 18:02:45 +000018 * Set "MediaBox" entry to the page dictionary.
19 *
20 * page - Handle to a page.
21 * left - The left of the rectangle.
22 * bottom - The bottom of the rectangle.
23 * right - The right of the rectangle.
24 * top - The top of the rectangle.
25 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -040026FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page,
27 float left,
28 float bottom,
29 float right,
30 float top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070031
32/**
Lei Zhangf958f352018-06-08 18:02:45 +000033 * Set "CropBox" entry to the page dictionary.
34 *
35 * page - Handle to a page.
36 * left - The left of the rectangle.
37 * bottom - The bottom of the rectangle.
38 * right - The right of the rectangle.
39 * top - The top of the rectangle.
40 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -040041FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page,
42 float left,
43 float bottom,
44 float right,
45 float top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070046
Lei Zhangf958f352018-06-08 18:02:45 +000047/**
xlou618edef2018-10-12 23:37:41 +000048 * Set "BleedBox" entry to the page dictionary.
49 *
50 * page - Handle to a page.
51 * left - The left of the rectangle.
52 * bottom - The bottom of the rectangle.
53 * right - The right of the rectangle.
54 * top - The top of the rectangle.
55 */
56FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetBleedBox(FPDF_PAGE page,
57 float left,
58 float bottom,
59 float right,
60 float top);
61
62/**
63 * Set "TrimBox" entry to the page dictionary.
64 *
65 * page - Handle to a page.
66 * left - The left of the rectangle.
67 * bottom - The bottom of the rectangle.
68 * right - The right of the rectangle.
69 * top - The top of the rectangle.
70 */
71FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetTrimBox(FPDF_PAGE page,
72 float left,
73 float bottom,
74 float right,
75 float top);
76
77/**
xlouc7f66ed2018-10-11 21:15:18 +000078 * Set "ArtBox" entry to the page dictionary.
79 *
80 * page - Handle to a page.
81 * left - The left of the rectangle.
82 * bottom - The bottom of the rectangle.
83 * right - The right of the rectangle.
84 * top - The top of the rectangle.
85 */
86FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetArtBox(FPDF_PAGE page,
87 float left,
88 float bottom,
89 float right,
90 float top);
91
92/**
Lei Zhangf958f352018-06-08 18:02:45 +000093 * Get "MediaBox" entry from the page dictionary.
94 *
95 * page - Handle to a page.
96 * left - Pointer to a float value receiving the left of the rectangle.
97 * bottom - Pointer to a float value receiving the bottom of the rectangle.
98 * right - Pointer to a float value receiving the right of the rectangle.
99 * top - Pointer to a float value receiving the top of the rectangle.
100 *
101 * On success, return true and write to the out parameters. Otherwise return
102 * false and leave the out parameters unmodified.
103 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400104FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page,
105 float* left,
106 float* bottom,
107 float* right,
108 float* top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700109
Lei Zhangf958f352018-06-08 18:02:45 +0000110/**
111 * Get "CropBox" entry from the page dictionary.
112 *
113 * page - Handle to a page.
114 * left - Pointer to a float value receiving the left of the rectangle.
115 * bottom - Pointer to a float value receiving the bottom of the rectangle.
116 * right - Pointer to a float value receiving the right of the rectangle.
117 * top - Pointer to a float value receiving the top of the rectangle.
118 *
119 * On success, return true and write to the out parameters. Otherwise return
120 * false and leave the out parameters unmodified.
121 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400122FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page,
123 float* left,
124 float* bottom,
125 float* right,
126 float* top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700127
128/**
xlou618edef2018-10-12 23:37:41 +0000129 * Get "BleedBox" entry from the page dictionary.
130 *
131 * page - Handle to a page.
132 * left - Pointer to a float value receiving the left of the rectangle.
133 * bottom - Pointer to a float value receiving the bottom of the rectangle.
134 * right - Pointer to a float value receiving the right of the rectangle.
135 * top - Pointer to a float value receiving the top of the rectangle.
136 *
137 * On success, return true and write to the out parameters. Otherwise return
138 * false and leave the out parameters unmodified.
139 */
140FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetBleedBox(FPDF_PAGE page,
141 float* left,
142 float* bottom,
143 float* right,
144 float* top);
145
146/**
147 * Get "TrimBox" entry from the page dictionary.
148 *
149 * page - Handle to a page.
150 * left - Pointer to a float value receiving the left of the rectangle.
151 * bottom - Pointer to a float value receiving the bottom of the rectangle.
152 * right - Pointer to a float value receiving the right of the rectangle.
153 * top - Pointer to a float value receiving the top of the rectangle.
154 *
155 * On success, return true and write to the out parameters. Otherwise return
156 * false and leave the out parameters unmodified.
157 */
158FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetTrimBox(FPDF_PAGE page,
159 float* left,
160 float* bottom,
161 float* right,
162 float* top);
163
164/**
xlouc7f66ed2018-10-11 21:15:18 +0000165 * Get "ArtBox" entry from the page dictionary.
166 *
167 * page - Handle to a page.
168 * left - Pointer to a float value receiving the left of the rectangle.
169 * bottom - Pointer to a float value receiving the bottom of the rectangle.
170 * right - Pointer to a float value receiving the right of the rectangle.
171 * top - Pointer to a float value receiving the top of the rectangle.
172 *
173 * On success, return true and write to the out parameters. Otherwise return
174 * false and leave the out parameters unmodified.
175 */
176FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetArtBox(FPDF_PAGE page,
177 float* left,
178 float* bottom,
179 float* right,
180 float* top);
181
182/**
Shirleen Lou07b47272017-11-18 00:13:45 +0000183 * Apply transforms to |page|.
184 *
185 * If |matrix| is provided it will be applied to transform the page.
186 * If |clipRect| is provided it will be used to clip the resulting page.
187 * If neither |matrix| or |clipRect| are provided this method returns |false|.
188 * Returns |true| if transforms are applied.
189 *
Lei Zhangf958f352018-06-08 18:02:45 +0000190 * This function will transform the whole page, and would take effect to all the
191 * objects in the page.
192 *
193 * page - Page handle.
194 * matrix - Transform matrix.
195 * clipRect - Clipping rectangle.
Shirleen Lou07b47272017-11-18 00:13:45 +0000196 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400197FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
198FPDFPage_TransFormWithClip(FPDF_PAGE page,
Lei Zhang970fcfe2018-12-20 19:51:18 +0000199 const FS_MATRIX* matrix,
200 const FS_RECTF* clipRect);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700201
202/**
Lei Zhangf958f352018-06-08 18:02:45 +0000203 * Transform (scale, rotate, shear, move) the clip path of page object.
204 * page_object - Handle to a page object. Returned by
205 * FPDFPageObj_NewImageObj().
206 *
207 * a - The coefficient "a" of the matrix.
208 * b - The coefficient "b" of the matrix.
209 * c - The coefficient "c" of the matrix.
210 * d - The coefficient "d" of the matrix.
211 * e - The coefficient "e" of the matrix.
212 * f - The coefficient "f" of the matrix.
213 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400214FPDF_EXPORT void FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,
216 double a,
217 double b,
218 double c,
219 double d,
220 double e,
221 double f);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700222
Miklos Vajna45501f32019-07-30 07:41:02 +0000223// Experimental API.
224// Get the clip path of the page object.
225//
226// page object - Handle to a page object. Returned by e.g.
227// FPDFPage_GetObject().
228//
229// Caller does not take ownership of the returned FPDF_CLIPPATH. Instead, it
230// remains valid until FPDF_ClosePage() is called for the page containing
231// page_object.
232FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV
233FPDFPageObj_GetClipPath(FPDF_PAGEOBJECT page_object);
234
235// Experimental API.
236// Get number of paths inside |clip_path|.
237//
238// clip_path - handle to a clip_path.
239//
240// Returns the number of objects in |clip_path| or -1 on failure.
241FPDF_EXPORT int FPDF_CALLCONV FPDFClipPath_CountPaths(FPDF_CLIPPATH clip_path);
242
243// Experimental API.
244// Get number of segments inside one path of |clip_path|.
245//
246// clip_path - handle to a clip_path.
247// path_index - index into the array of paths of the clip path.
248//
249// Returns the number of segments or -1 on failure.
250FPDF_EXPORT int FPDF_CALLCONV
251FPDFClipPath_CountPathSegments(FPDF_CLIPPATH clip_path, int path_index);
252
253// Experimental API.
254// Get segment in one specific path of |clip_path| at index.
255//
256// clip_path - handle to a clip_path.
257// path_index - the index of a path.
258// segment_index - the index of a segment.
259//
260// Returns the handle to the segment, or NULL on failure. The caller does not
261// take ownership of the returned FPDF_CLIPPATH. Instead, it remains valid until
262// FPDF_ClosePage() is called for the page containing page_object.
263FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
264FPDFClipPath_GetPathSegment(FPDF_CLIPPATH clip_path,
265 int path_index,
266 int segment_index);
267
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700268/**
Lei Zhangf958f352018-06-08 18:02:45 +0000269 * Create a new clip path, with a rectangle inserted.
270 *
Lei Zhang51948ab2018-10-09 22:03:30 +0000271 * Caller takes ownership of the returned FPDF_CLIPPATH. It should be freed with
272 * FPDF_DestroyClipPath().
273 *
Lei Zhangf958f352018-06-08 18:02:45 +0000274 * left - The left of the clip box.
275 * bottom - The bottom of the clip box.
276 * right - The right of the clip box.
277 * top - The top of the clip box.
278 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400279FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left,
280 float bottom,
281 float right,
282 float top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700283
284/**
Lei Zhangf958f352018-06-08 18:02:45 +0000285 * Destroy the clip path.
286 *
Lei Zhang51948ab2018-10-09 22:03:30 +0000287 * clipPath - A handle to the clip path. It will be invalid after this call.
Lei Zhangf958f352018-06-08 18:02:45 +0000288 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400289FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700290
291/**
Lei Zhangf958f352018-06-08 18:02:45 +0000292 * Clip the page content, the page content that outside the clipping region
293 * become invisible.
294 *
295 * A clip path will be inserted before the page content stream or content array.
296 * In this way, the page content will be clipped by this clip path.
297 *
298 * page - A page handle.
Lei Zhang51948ab2018-10-09 22:03:30 +0000299 * clipPath - A handle to the clip path. (Does not take ownership.)
Lei Zhangf958f352018-06-08 18:02:45 +0000300 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400301FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
302 FPDF_CLIPPATH clipPath);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700303
Tom Sepezcf22eb82015-05-12 17:28:08 -0700304#ifdef __cplusplus
305}
306#endif
307
Tom Sepez9857e202015-05-13 17:09:26 -0700308#endif // PUBLIC_FPDF_TRANSFORMPAGE_H_