1 // 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. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_ 8 #define PUBLIC_FPDF_TRANSFORMPAGE_H_ 9 10 // NOLINTNEXTLINE(build/include) 11 #include "fpdfview.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** 18 * 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 */ 26 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page, 27 float left, 28 float bottom, 29 float right, 30 float top); 31 32 /** 33 * 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 */ 41 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page, 42 float left, 43 float bottom, 44 float right, 45 float top); 46 47 /** 48 * 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 */ 56 FPDF_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 */ 71 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetTrimBox(FPDF_PAGE page, 72 float left, 73 float bottom, 74 float right, 75 float top); 76 77 /** 78 * 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 */ 86 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetArtBox(FPDF_PAGE page, 87 float left, 88 float bottom, 89 float right, 90 float top); 91 92 /** 93 * 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 */ 104 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page, 105 float* left, 106 float* bottom, 107 float* right, 108 float* top); 109 110 /** 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 */ 122 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page, 123 float* left, 124 float* bottom, 125 float* right, 126 float* top); 127 128 /** 129 * 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 */ 140 FPDF_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 */ 158 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetTrimBox(FPDF_PAGE page, 159 float* left, 160 float* bottom, 161 float* right, 162 float* top); 163 164 /** 165 * 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 */ 176 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetArtBox(FPDF_PAGE page, 177 float* left, 178 float* bottom, 179 float* right, 180 float* top); 181 182 /** 183 * 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 * 190 * 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. 196 */ 197 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV 198 FPDFPage_TransFormWithClip(FPDF_PAGE page, 199 const FS_MATRIX* matrix, 200 const FS_RECTF* clipRect); 201 202 /** 203 * 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 */ 214 FPDF_EXPORT void FPDF_CALLCONV 215 FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, 216 double a, 217 double b, 218 double c, 219 double d, 220 double e, 221 double f); 222 223 // 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. 232 FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV 233 FPDFPageObj_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. 241 FPDF_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. 250 FPDF_EXPORT int FPDF_CALLCONV 251 FPDFClipPath_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. 263 FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV 264 FPDFClipPath_GetPathSegment(FPDF_CLIPPATH clip_path, 265 int path_index, 266 int segment_index); 267 268 /** 269 * Create a new clip path, with a rectangle inserted. 270 * 271 * Caller takes ownership of the returned FPDF_CLIPPATH. It should be freed with 272 * FPDF_DestroyClipPath(). 273 * 274 * 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 */ 279 FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left, 280 float bottom, 281 float right, 282 float top); 283 284 /** 285 * Destroy the clip path. 286 * 287 * clipPath - A handle to the clip path. It will be invalid after this call. 288 */ 289 FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath); 290 291 /** 292 * 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. 299 * clipPath - A handle to the clip path. (Does not take ownership.) 300 */ 301 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page, 302 FPDF_CLIPPATH clipPath); 303 304 #ifdef __cplusplus 305 } 306 #endif 307 308 #endif // PUBLIC_FPDF_TRANSFORMPAGE_H_ 309