blob: 742da490fa9ea8a0852593dfff26555b66c707e3 [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/**
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 Sinclair00d2ad12017-08-10 14:13:02 -040059FPDF_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-Malek3f3b45c2014-05-23 17:28:10 -070064
Lei Zhangf958f352018-06-08 18:02:45 +000065/**
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 Sinclair00d2ad12017-08-10 14:13:02 -040077FPDF_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-Malek3f3b45c2014-05-23 17:28:10 -070082
83/**
Shirleen Lou07b47272017-11-18 00:13:45 +000084 * 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 Zhangf958f352018-06-08 18:02:45 +000091 * 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 Lou07b47272017-11-18 00:13:45 +000097 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -040098FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
99FPDFPage_TransFormWithClip(FPDF_PAGE page,
100 FS_MATRIX* matrix,
101 FS_RECTF* clipRect);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700102
103/**
Lei Zhangf958f352018-06-08 18:02:45 +0000104 * 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 Sinclair00d2ad12017-08-10 14:13:02 -0400115FPDF_EXPORT void FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116FPDFPageObj_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-Malek3f3b45c2014-05-23 17:28:10 -0700123
124/**
Lei Zhangf958f352018-06-08 18:02:45 +0000125 * Create a new clip path, with a rectangle inserted.
126 *
Lei Zhang51948ab2018-10-09 22:03:30 +0000127 * Caller takes ownership of the returned FPDF_CLIPPATH. It should be freed with
128 * FPDF_DestroyClipPath().
129 *
Lei Zhangf958f352018-06-08 18:02:45 +0000130 * 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 Sinclair00d2ad12017-08-10 14:13:02 -0400135FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left,
136 float bottom,
137 float right,
138 float top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700139
140/**
Lei Zhangf958f352018-06-08 18:02:45 +0000141 * Destroy the clip path.
142 *
Lei Zhang51948ab2018-10-09 22:03:30 +0000143 * clipPath - A handle to the clip path. It will be invalid after this call.
Lei Zhangf958f352018-06-08 18:02:45 +0000144 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400145FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700146
147/**
Lei Zhangf958f352018-06-08 18:02:45 +0000148 * 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 Zhang51948ab2018-10-09 22:03:30 +0000155 * clipPath - A handle to the clip path. (Does not take ownership.)
Lei Zhangf958f352018-06-08 18:02:45 +0000156 */
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400157FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
158 FPDF_CLIPPATH clipPath);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700159
Tom Sepezcf22eb82015-05-12 17:28:08 -0700160#ifdef __cplusplus
161}
162#endif
163
Tom Sepez9857e202015-05-13 17:09:26 -0700164#endif // PUBLIC_FPDF_TRANSFORMPAGE_H_