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 typedef void* FPDF_PAGEARCSAVER; 18 typedef void* FPDF_PAGEARCLOADER; 19 20 /** 21 * Set "MediaBox" entry to the page dictionary. 22 * @param[in] page - Handle to a page. 23 * @param[in] left - The left of the rectangle. 24 * @param[in] bottom - The bottom of the rectangle. 25 * @param[in] right - The right of the rectangle. 26 * @param[in] top - The top of the rectangle. 27 * @retval None. 28 */ 29 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page, 30 float left, 31 float bottom, 32 float right, 33 float top); 34 35 /** 36 * Set "CropBox" entry to the page dictionary. 37 * @param[in] page - Handle to a page. 38 * @param[in] left - The left of the rectangle. 39 * @param[in] bottom - The bottom of the rectangle. 40 * @param[in] right - The right of the rectangle. 41 * @param[in] top - The top of the rectangle. 42 * @retval None. 43 */ 44 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page, 45 float left, 46 float bottom, 47 float right, 48 float top); 49 50 /** Get "MediaBox" entry from the page dictionary. 51 * @param[in] page - Handle to a page. 52 * @param[in] left - Pointer to a double value receiving the left of the 53 * rectangle. 54 * @param[in] bottom - Pointer to a double value receiving the bottom of the 55 * rectangle. 56 * @param[in] right - Pointer to a double value receiving the right of the 57 * rectangle. 58 * @param[in] top - Pointer to a double value receiving the top of the 59 * rectangle. 60 * @retval True if success,else fail. 61 */ 62 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page, 63 float* left, 64 float* bottom, 65 float* right, 66 float* top); 67 68 /** Get "CropBox" entry from the page dictionary. 69 * @param[in] page - Handle to a page. 70 * @param[in] left - Pointer to a double value receiving the left of the 71 * rectangle. 72 * @param[in] bottom - Pointer to a double value receiving the bottom of the 73 * rectangle. 74 * @param[in] right - Pointer to a double value receiving the right of the 75 * rectangle. 76 * @param[in] top - Pointer to a double value receiving the top of the 77 * rectangle. 78 * @retval True if success,else fail. 79 */ 80 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page, 81 float* left, 82 float* bottom, 83 float* right, 84 float* top); 85 86 /** 87 * Apply transforms to |page|. 88 * 89 * If |matrix| is provided it will be applied to transform the page. 90 * If |clipRect| is provided it will be used to clip the resulting page. 91 * If neither |matrix| or |clipRect| are provided this method returns |false|. 92 * Returns |true| if transforms are applied. 93 * 94 * @param[in] page - Page handle. 95 * @param[in] matrix - Transform matrix. 96 * @param[in] clipRect - Clipping rectangle. 97 * @Note. This function will transform the whole page, and would take effect to 98 * all the objects in the page. 99 */ 100 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV 101 FPDFPage_TransFormWithClip(FPDF_PAGE page, 102 FS_MATRIX* matrix, 103 FS_RECTF* clipRect); 104 105 /** 106 * Transform (scale, rotate, shear, move) the clip path of page object. 107 * @param[in] page_object - Handle to a page object. Returned by 108 * FPDFPageObj_NewImageObj. 109 * @param[in] a - The coefficient "a" of the matrix. 110 * @param[in] b - The coefficient "b" of the matrix. 111 * @param[in] c - The coefficient "c" of the matrix. 112 * @param[in] d - The coefficient "d" of the matrix. 113 * @param[in] e - The coefficient "e" of the matrix. 114 * @param[in] f - The coefficient "f" of the matrix. 115 * @retval None. 116 */ 117 FPDF_EXPORT void FPDF_CALLCONV 118 FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, 119 double a, 120 double b, 121 double c, 122 double d, 123 double e, 124 double f); 125 126 /** 127 * Create a new clip path, with a rectangle inserted. 128 * 129 * @param[in] left - The left of the clip box. 130 * @param[in] bottom - The bottom of the clip box. 131 * @param[in] right - The right of the clip box. 132 * @param[in] top - The top of the clip box. 133 * @retval a handle to the clip path. 134 */ 135 FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left, 136 float bottom, 137 float right, 138 float top); 139 140 /** 141 * Destroy the clip path. 142 * 143 * @param[in] clipPath - A handle to the clip path. 144 * Destroy the clip path. 145 * @retval None. 146 */ 147 FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath); 148 149 /** 150 * Clip the page content, the page content that outside the clipping region 151 * become invisible. 152 * 153 * @param[in] page - A page handle. 154 * @param[in] clipPath - A handle to the clip path. 155 * @Note. A clip path will be inserted before the page content stream or content 156 * array. In this way, the page content will be clipped 157 * by this clip path. 158 */ 159 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page, 160 FPDF_CLIPPATH clipPath); 161 162 #ifdef __cplusplus 163 } 164 #endif 165 166 #endif // PUBLIC_FPDF_TRANSFORMPAGE_H_ 167