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.
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
7 #ifndef PUBLIC_FPDF_EDIT_H_
8 #define PUBLIC_FPDF_EDIT_H_
14 // Define all types used in the SDK. Note they can be simply regarded as opaque pointers
15 // or long integer numbers.
17 #define FPDF_ARGB(a,r,g,b) ((((uint32_t)(((uint8_t)(b)|((FX_WORD)((uint8_t)(g))<<8))|(((FX_DWORD)(uint8_t)(r))<<16)))) | (((FX_DWORD)(uint8_t)(a))<<24))
18 #define FPDF_GetBValue(argb) ((uint8_t)(argb))
19 #define FPDF_GetGValue(argb) ((uint8_t)(((uint16_t)(argb)) >> 8))
20 #define FPDF_GetRValue(argb) ((uint8_t)((argb)>>16))
21 #define FPDF_GetAValue(argb) ((uint8_t)((argb)>>24))
27 //////////////////////////////////////////////////////////////////////
31 //////////////////////////////////////////////////////////////////////
33 // Function: FPDF_CreateNewDocument
34 // Create a new PDF document.
38 // A handle to a document. If failed, NULL is returned.
39 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument();
41 //////////////////////////////////////////////////////////////////////
45 //////////////////////////////////////////////////////////////////////
47 // Function: FPDFPage_New
48 // Construct an empty page.
50 // document - Handle to document. Returned by FPDF_LoadDocument and FPDF_CreateNewDocument.
51 // page_index - The index of a page.
52 // width - The page width.
53 // height - The page height.
55 // The handle to the page.
57 // Loaded page can be deleted by FPDFPage_Delete.
58 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, double height);
60 // Function: FPDFPage_Delete
63 // document - Handle to document. Returned by FPDF_LoadDocument and FPDF_CreateNewDocument.
64 // page_index - The index of a page.
67 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index);
69 // Function: FPDFPage_GetRotation
70 // Get the page rotation. One of following values will be returned: 0(0), 1(90), 2(180), 3(270).
72 // page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
74 // The PDF page rotation.
76 // The PDF page rotation is rotated clockwise.
77 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page);
79 // Function: FPDFPage_SetRotation
80 // Set page rotation. One of following values will be set: 0(0), 1(90), 2(180), 3(270).
82 // page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
83 // rotate - The value of the PDF page rotation.
87 // The PDF page rotation is rotated clockwise.
89 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
91 // Function: FPDFPage_InsertObject
92 // Insert an object to the page. The page object is automatically freed.
94 // page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
95 // page_obj - Handle to a page object. Returned by FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and
96 // FPDFPageObj_NewPathObj.
99 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj);
101 // Function: FPDFPage_CountObject
102 // Get number of page objects inside the page.
104 // page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
106 // The number of the page object.
107 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page);
109 // Function: FPDFPage_GetObject
110 // Get page object by index.
112 // page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
113 // index - The index of a page object.
115 // The handle of the page object. Null for failed.
116 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index);
118 // Function: FPDFPage_HasTransparency
119 // Check that whether the content of specified PDF page contains transparency.
121 // page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
123 // TRUE means that the PDF page does contains transparency.
124 // Otherwise, returns FALSE.
125 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page);
127 // Function: FPDFPage_GenerateContent
128 // Generate PDF Page content.
130 // page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
132 // True if successful, false otherwise.
134 // Before you save the page to a file, or reload the page, you must call the FPDFPage_GenerateContent function.
135 // Or the changed information will be lost.
136 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page);
138 //////////////////////////////////////////////////////////////////////
140 // Page Object functions
142 //////////////////////////////////////////////////////////////////////
144 // Function: FPDFPageObj_HasTransparency
145 // Check that whether the specified PDF page object contains transparency.
147 // pageObject - Handle to a page object.
149 // TRUE means that the PDF page object does contains transparency.
150 // Otherwise, returns FALSE.
151 DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject);
153 // Function: FPDFPageObj_Transform
154 // Transform (scale, rotate, shear, move) page object.
156 // page_object - Handle to a page object. Returned by FPDFPageObj_NewImageObj.
157 // a - The coefficient "a" of the matrix.
158 // b - The coefficient "b" of the matrix.
159 // c - The coefficient "c" of the matrix.
160 // d - The coefficient "d" of the matrix.
161 // e - The coefficient "e" of the matrix.
162 // f - The coefficient "f" of the matrix.
165 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
166 double a, double b, double c, double d, double e, double f);
168 // Function: FPDFPage_TransformAnnots
169 // Transform (scale, rotate, shear, move) all annots in a page.
171 // page - Handle to a page.
172 // a - The coefficient "a" of the matrix.
173 // b - The coefficient "b" of the matrix.
174 // c - The coefficient "c" of the matrix.
175 // d - The coefficient "d" of the matrix.
176 // e - The coefficient "e" of the matrix.
177 // f - The coefficient "f" of the matrix.
180 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
181 double a, double b, double c, double d, double e, double f);
183 // The page object constants.
184 #define FPDF_PAGEOBJ_TEXT 1
185 #define FPDF_PAGEOBJ_PATH 2
186 #define FPDF_PAGEOBJ_IMAGE 3
187 #define FPDF_PAGEOBJ_SHADING 4
188 #define FPDF_PAGEOBJ_FORM 5
190 //////////////////////////////////////////////////////////////////////
194 //////////////////////////////////////////////////////////////////////
196 // Function: FPDFPageObj_NewImgeObj
197 // Create a new Image Object.
199 // document - Handle to document. Returned by FPDF_LoadDocument or FPDF_CreateNewDocument function.
201 // Handle of image object.
202 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document);
205 // Function: FPDFImageObj_LoadJpegFile
206 // Load Image from a JPEG image file and then set it to an image object.
208 // pages - Pointers to the start of all loaded pages, could be NULL.
209 // nCount - Number of pages, could be 0.
210 // image_object - Handle of image object returned by FPDFPageObj_NewImgeObj.
211 // fileAccess - The custom file access handler, which specifies the JPEG image file.
213 // TRUE if successful, FALSE otherwise.
215 // The image object might already has an associated image, which is shared and cached by the loaded pages, In this case, we need to clear the cache of image for all the loaded pages.
216 // Pass pages and count to this API to clear the image cache.
217 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess);
220 // Function: FPDFImageObj_SetMatrix
221 // Set the matrix of an image object.
223 // image_object - Handle of image object returned by FPDFPageObj_NewImgeObj.
224 // a - The coefficient "a" of the matrix.
225 // b - The coefficient "b" of the matrix.
226 // c - The coefficient "c" of the matrix.
227 // d - The coefficient "d" of the matrix.
228 // e - The coefficient "e" of the matrix.
229 // f - The coefficient "f" of the matrix.
231 // TRUE if successful, FALSE otherwise.
232 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
233 double a, double b, double c, double d, double e, double f);
235 // Function: FPDFImageObj_SetBitmap
236 // Set the bitmap to an image object.
238 // pages - Pointer's to the start of all loaded pages.
239 // nCount - Number of pages.
240 // image_object - Handle of image object returned by FPDFPageObj_NewImgeObj.
241 // bitmap - The handle of the bitmap which you want to set it to the image object.
243 // TRUE if successful, FALSE otherwise.
244 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap);
250 #endif // PUBLIC_FPDF_EDIT_H_