John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 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. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 7 | #ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_ |
| 8 | #define PUBLIC_FPDF_TRANSFORMPAGE_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Dan Sinclair | 85c8e7f | 2016-11-21 13:50:32 -0500 | [diff] [blame] | 10 | // NOLINTNEXTLINE(build/include) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 11 | #include "fpdfview.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 12 | |
Tom Sepez | cf22eb8 | 2015-05-12 17:28:08 -0700 | [diff] [blame] | 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 17 | /** |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 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 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 26 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page, |
| 27 | float left, |
| 28 | float bottom, |
| 29 | float right, |
| 30 | float top); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 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 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 41 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page, |
| 42 | float left, |
| 43 | float bottom, |
| 44 | float right, |
| 45 | float top); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 46 | |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 47 | /** |
| 48 | * Get "MediaBox" entry from the page dictionary. |
| 49 | * |
| 50 | * page - Handle to a page. |
| 51 | * left - Pointer to a float value receiving the left of the rectangle. |
| 52 | * bottom - Pointer to a float value receiving the bottom of the rectangle. |
| 53 | * right - Pointer to a float value receiving the right of the rectangle. |
| 54 | * top - Pointer to a float value receiving the top of the rectangle. |
| 55 | * |
| 56 | * On success, return true and write to the out parameters. Otherwise return |
| 57 | * false and leave the out parameters unmodified. |
| 58 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 59 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page, |
| 60 | float* left, |
| 61 | float* bottom, |
| 62 | float* right, |
| 63 | float* top); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 64 | |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 65 | /** |
| 66 | * Get "CropBox" entry from the page dictionary. |
| 67 | * |
| 68 | * page - Handle to a page. |
| 69 | * left - Pointer to a float value receiving the left of the rectangle. |
| 70 | * bottom - Pointer to a float value receiving the bottom of the rectangle. |
| 71 | * right - Pointer to a float value receiving the right of the rectangle. |
| 72 | * top - Pointer to a float value receiving the top of the rectangle. |
| 73 | * |
| 74 | * On success, return true and write to the out parameters. Otherwise return |
| 75 | * false and leave the out parameters unmodified. |
| 76 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 77 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page, |
| 78 | float* left, |
| 79 | float* bottom, |
| 80 | float* right, |
| 81 | float* top); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
Shirleen Lou | 07b4727 | 2017-11-18 00:13:45 +0000 | [diff] [blame] | 84 | * Apply transforms to |page|. |
| 85 | * |
| 86 | * If |matrix| is provided it will be applied to transform the page. |
| 87 | * If |clipRect| is provided it will be used to clip the resulting page. |
| 88 | * If neither |matrix| or |clipRect| are provided this method returns |false|. |
| 89 | * Returns |true| if transforms are applied. |
| 90 | * |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 91 | * This function will transform the whole page, and would take effect to all the |
| 92 | * objects in the page. |
| 93 | * |
| 94 | * page - Page handle. |
| 95 | * matrix - Transform matrix. |
| 96 | * clipRect - Clipping rectangle. |
Shirleen Lou | 07b4727 | 2017-11-18 00:13:45 +0000 | [diff] [blame] | 97 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 98 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 99 | FPDFPage_TransFormWithClip(FPDF_PAGE page, |
| 100 | FS_MATRIX* matrix, |
| 101 | FS_RECTF* clipRect); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 104 | * Transform (scale, rotate, shear, move) the clip path of page object. |
| 105 | * page_object - Handle to a page object. Returned by |
| 106 | * FPDFPageObj_NewImageObj(). |
| 107 | * |
| 108 | * a - The coefficient "a" of the matrix. |
| 109 | * b - The coefficient "b" of the matrix. |
| 110 | * c - The coefficient "c" of the matrix. |
| 111 | * d - The coefficient "d" of the matrix. |
| 112 | * e - The coefficient "e" of the matrix. |
| 113 | * f - The coefficient "f" of the matrix. |
| 114 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 115 | FPDF_EXPORT void FPDF_CALLCONV |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 116 | FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, |
| 117 | double a, |
| 118 | double b, |
| 119 | double c, |
| 120 | double d, |
| 121 | double e, |
| 122 | double f); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 125 | * Create a new clip path, with a rectangle inserted. |
| 126 | * |
Lei Zhang | 51948ab | 2018-10-09 22:03:30 +0000 | [diff] [blame^] | 127 | * Caller takes ownership of the returned FPDF_CLIPPATH. It should be freed with |
| 128 | * FPDF_DestroyClipPath(). |
| 129 | * |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 130 | * left - The left of the clip box. |
| 131 | * bottom - The bottom of the clip box. |
| 132 | * right - The right of the clip box. |
| 133 | * top - The top of the clip box. |
| 134 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 135 | FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left, |
| 136 | float bottom, |
| 137 | float right, |
| 138 | float top); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 139 | |
| 140 | /** |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 141 | * Destroy the clip path. |
| 142 | * |
Lei Zhang | 51948ab | 2018-10-09 22:03:30 +0000 | [diff] [blame^] | 143 | * clipPath - A handle to the clip path. It will be invalid after this call. |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 144 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 145 | FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 148 | * Clip the page content, the page content that outside the clipping region |
| 149 | * become invisible. |
| 150 | * |
| 151 | * A clip path will be inserted before the page content stream or content array. |
| 152 | * In this way, the page content will be clipped by this clip path. |
| 153 | * |
| 154 | * page - A page handle. |
Lei Zhang | 51948ab | 2018-10-09 22:03:30 +0000 | [diff] [blame^] | 155 | * clipPath - A handle to the clip path. (Does not take ownership.) |
Lei Zhang | f958f35 | 2018-06-08 18:02:45 +0000 | [diff] [blame] | 156 | */ |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 157 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page, |
| 158 | FPDF_CLIPPATH clipPath); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 159 | |
Tom Sepez | cf22eb8 | 2015-05-12 17:28:08 -0700 | [diff] [blame] | 160 | #ifdef __cplusplus |
| 161 | } |
| 162 | #endif |
| 163 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 164 | #endif // PUBLIC_FPDF_TRANSFORMPAGE_H_ |