blob: 7c37b83aa9e412d128970e0ba817d6e495e7fe34 [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_EDIT_H_
8#define PUBLIC_FPDF_EDIT_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Tom Sepezbfa9a822015-06-09 13:24:12 -070010#include <stdint.h>
11
Dan Sinclair85c8e7f2016-11-21 13:50:32 -050012// NOLINTNEXTLINE(build/include)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070013#include "fpdfview.h"
14
dan sinclair61b2fc72016-03-23 19:21:44 -040015#define FPDF_ARGB(a, r, g, b) \
16 ((uint32_t)(((uint32_t)(b)&0xff) | (((uint32_t)(g)&0xff) << 8) | \
17 (((uint32_t)(r)&0xff) << 16) | (((uint32_t)(a)&0xff) << 24)))
Nico Weber9d8ec5a2015-08-04 13:00:21 -070018#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))
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022
Jane Liuca898292017-08-16 11:25:35 -040023// Refer to PDF Reference version 1.7 table 4.12 for all color space families.
24#define FPDF_COLORSPACE_UNKNOWN 0
25#define FPDF_COLORSPACE_DEVICEGRAY 1
26#define FPDF_COLORSPACE_DEVICERGB 2
27#define FPDF_COLORSPACE_DEVICECMYK 3
28#define FPDF_COLORSPACE_CALGRAY 4
29#define FPDF_COLORSPACE_CALRGB 5
30#define FPDF_COLORSPACE_LAB 6
31#define FPDF_COLORSPACE_ICCBASED 7
32#define FPDF_COLORSPACE_SEPARATION 8
33#define FPDF_COLORSPACE_DEVICEN 9
34#define FPDF_COLORSPACE_INDEXED 10
35#define FPDF_COLORSPACE_PATTERN 11
36
dsinclair5f597db2016-03-25 09:04:54 -070037// The page object constants.
Miklos Vajna14233192017-04-03 16:02:39 +020038#define FPDF_PAGEOBJ_UNKNOWN 0
dsinclair5f597db2016-03-25 09:04:54 -070039#define FPDF_PAGEOBJ_TEXT 1
40#define FPDF_PAGEOBJ_PATH 2
41#define FPDF_PAGEOBJ_IMAGE 3
42#define FPDF_PAGEOBJ_SHADING 4
43#define FPDF_PAGEOBJ_FORM 5
44
Miklos Vajna36eed872017-09-20 22:52:43 +020045// The path segment constants.
46#define FPDF_SEGMENT_UNKNOWN -1
47#define FPDF_SEGMENT_LINETO 0
48#define FPDF_SEGMENT_BEZIERTO 1
49#define FPDF_SEGMENT_MOVETO 2
50
Nicolas Pena55e026b2017-02-07 14:59:23 -050051#define FPDF_FILLMODE_ALTERNATE 1
52#define FPDF_FILLMODE_WINDING 2
53
Nicolas Penad03ca422017-03-06 13:54:33 -050054#define FPDF_FONT_TYPE1 1
55#define FPDF_FONT_TRUETYPE 2
56
wileyrya5be0b292017-05-31 19:13:37 -050057#define FPDF_LINECAP_BUTT 0
58#define FPDF_LINECAP_ROUND 1
59#define FPDF_LINECAP_PROJECTING_SQUARE 2
60
61#define FPDF_LINEJOIN_MITER 0
62#define FPDF_LINEJOIN_ROUND 1
63#define FPDF_LINEJOIN_BEVEL 2
64
rbpottere8468c42017-07-11 10:04:29 -070065#define FPDF_PRINTMODE_EMF 0
66#define FPDF_PRINTMODE_TEXTONLY 1
67#define FPDF_PRINTMODE_POSTSCRIPT2 2
68#define FPDF_PRINTMODE_POSTSCRIPT3 3
69
Jane Liuca898292017-08-16 11:25:35 -040070typedef struct FPDF_IMAGEOBJ_METADATA {
71 // The image width in pixels.
72 unsigned int width;
73 // The image height in pixels.
74 unsigned int height;
75 // The image's horizontal pixel-per-inch.
76 float horizontal_dpi;
77 // The image's vertical pixel-per-inch.
78 float vertical_dpi;
79 // The number of bits used to represent each pixel.
80 unsigned int bits_per_pixel;
81 // The image's colorspace. See above for the list of FPDF_COLORSPACE_*.
82 int colorspace;
Julian Lungerecd063e2017-12-27 10:18:50 -050083 // The image's marked content ID. Useful for pairing with associated alt-text.
84 // A value of -1 indicates no ID.
85 int marked_content_id;
Jane Liuca898292017-08-16 11:25:35 -040086} FPDF_IMAGEOBJ_METADATA;
87
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070088#ifdef __cplusplus
89extern "C" {
dsinclair5f597db2016-03-25 09:04:54 -070090#endif // __cplusplus
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070091
dsinclair5f597db2016-03-25 09:04:54 -070092// Create a new PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070093//
dsinclair5f597db2016-03-25 09:04:54 -070094// Returns a handle to a new document, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -040095FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070096
dsinclair5f597db2016-03-25 09:04:54 -070097// Create a new PDF page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070098//
dsinclair5f597db2016-03-25 09:04:54 -070099// document - handle to document.
Lei Zhang3f3f5132018-01-31 14:53:02 +0000100// page_index - suggested 0-based index of the page to create. If it is larger
101// than document's current last index(L), the created page index
102// is the next available index -- L+1.
103// width - the page width in points.
104// height - the page height in points.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700105//
Lei Zhang3f3f5132018-01-31 14:53:02 +0000106// Returns the handle to the new page or NULL on failure.
dsinclair5f597db2016-03-25 09:04:54 -0700107//
Lei Zhang3f3f5132018-01-31 14:53:02 +0000108// The page should be closed with FPDF_ClosePage() when finished as
weili9b777de2016-08-19 16:19:46 -0700109// with any other page in the document.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400110FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
111 int page_index,
112 double width,
113 double height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700114
dsinclair5f597db2016-03-25 09:04:54 -0700115// Delete the page at |page_index|.
116//
117// document - handle to document.
118// page_index - the index of the page to delete.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400119FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document,
120 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700121
dsinclair5f597db2016-03-25 09:04:54 -0700122// Get the rotation of |page|.
123//
124// page - handle to a page
125//
126// Returns one of the following indicating the page rotation:
127// 0 - No rotation.
128// 1 - Rotated 90 degrees clockwise.
129// 2 - Rotated 180 degrees clockwise.
130// 3 - Rotated 270 degrees clockwise.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400131FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetRotation(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700132
dsinclair5f597db2016-03-25 09:04:54 -0700133// Set rotation for |page|.
Tom Sepez9857e202015-05-13 17:09:26 -0700134//
dsinclair5f597db2016-03-25 09:04:54 -0700135// page - handle to a page.
136// rotate - the rotation value, one of:
137// 0 - No rotation.
138// 1 - Rotated 90 degrees clockwise.
139// 2 - Rotated 180 degrees clockwise.
140// 3 - Rotated 270 degrees clockwise.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400141FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
Bo Xu394010d2014-06-12 13:41:50 -0700142
dsinclair5f597db2016-03-25 09:04:54 -0700143// Insert |page_obj| into |page|.
144//
145// page - handle to a page
146// page_obj - handle to a page object. The |page_obj| will be automatically
147// freed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400148FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page,
149 FPDF_PAGEOBJECT page_obj);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700150
Henrique Nakashima35841fa2018-03-15 15:25:16 +0000151// Experimental API.
152// Remove |page_obj| from |page|.
153//
154// page - handle to a page
155// page_obj - handle to a page object to be removed.
156//
157// Returns TRUE on success.
158//
159// Ownership is transferred to the caller. Call FPDFPageObj_Destroy() to free
160// it.
161FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
162FPDFPage_RemoveObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj);
163
dsinclair5f597db2016-03-25 09:04:54 -0700164// Get number of page objects inside |page|.
165//
166// page - handle to a page.
167//
168// Returns the number of objects in |page|.
Miklos Vajna92627612017-09-25 12:59:29 +0200169//
170// DEPRECATED. Please use FPDFPage_CountObjects.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400171FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObject(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700172
Miklos Vajna92627612017-09-25 12:59:29 +0200173// Get number of page objects inside |page|.
174//
175// page - handle to a page.
176//
177// Returns the number of objects in |page|.
178FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page);
179
dsinclair5f597db2016-03-25 09:04:54 -0700180// Get object in |page| at |index|.
181//
182// page - handle to a page.
183// index - the index of a page object.
184//
185// Returns the handle to the page object, or NULL on failed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400186FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page,
187 int index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700188
dsinclair5f597db2016-03-25 09:04:54 -0700189// Checks if |page| contains transparency.
190//
191// page - handle to a page.
192//
193// Returns TRUE if |page| contains transparency.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400194FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700195
dsinclair5f597db2016-03-25 09:04:54 -0700196// Generate the content of |page|.
197//
198// page - handle to a page.
199//
200// Returns TRUE on success.
201//
202// Before you save the page to a file, or reload the page, you must call
203// |FPDFPage_GenerateContent| or any changes to |page| will be lost.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400204FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700205
Jane Liu2e5f0ae2017-08-08 15:23:27 -0400206// Destroy |page_obj| by releasing its resources. |page_obj| must have been
207// created by FPDFPageObj_CreateNew{Path|Rect}() or
208// FPDFPageObj_New{Text|Image}Obj(). This function must be called on
209// newly-created objects if they are not added to a page through
210// FPDFPage_InsertObject() or to an annotation through FPDFAnnot_AppendObject().
211//
212// page_obj - handle to a page object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400213FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj);
Jane Liu2e5f0ae2017-08-08 15:23:27 -0400214
Nicolas Pena603a31d2017-06-14 11:41:18 -0400215// Checks if |page_object| contains transparency.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700216//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400217// page_object - handle to a page object.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700218//
dsinclair5f597db2016-03-25 09:04:54 -0700219// Returns TRUE if |pageObject| contains transparency.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400220FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Nicolas Pena603a31d2017-06-14 11:41:18 -0400221FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT page_object);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700222
Nicolas Pena603a31d2017-06-14 11:41:18 -0400223// Get type of |page_object|.
Miklos Vajna14233192017-04-03 16:02:39 +0200224//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400225// page_object - handle to a page object.
Miklos Vajna14233192017-04-03 16:02:39 +0200226//
227// Returns one of the FPDF_PAGEOBJ_* values on success, FPDF_PAGEOBJ_UNKNOWN on
228// error.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400229FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object);
Miklos Vajna14233192017-04-03 16:02:39 +0200230
Nicolas Pena603a31d2017-06-14 11:41:18 -0400231// Transform |page_object| by the given matrix.
dsinclair5f597db2016-03-25 09:04:54 -0700232//
233// page_object - handle to a page object.
234// a - matrix value.
235// b - matrix value.
236// c - matrix value.
237// d - matrix value.
238// e - matrix value.
239// f - matrix value.
240//
241// The matrix is composed as:
242// |a c e|
243// |b d f|
244// and can be used to scale, rotate, shear and translate the |page_object|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400245FPDF_EXPORT void FPDF_CALLCONV
246FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
247 double a,
248 double b,
249 double c,
250 double d,
251 double e,
252 double f);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700253
dsinclair5f597db2016-03-25 09:04:54 -0700254// Transform all annotations in |page|.
255//
256// page - handle to a page.
257// a - matrix value.
258// b - matrix value.
259// c - matrix value.
260// d - matrix value.
261// e - matrix value.
262// f - matrix value.
263//
264// The matrix is composed as:
265// |a c e|
266// |b d f|
267// and can be used to scale, rotate, shear and translate the |page| annotations.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400268FPDF_EXPORT void FPDF_CALLCONV FPDFPage_TransformAnnots(FPDF_PAGE page,
269 double a,
270 double b,
271 double c,
272 double d,
273 double e,
274 double f);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700275
dsinclair5f597db2016-03-25 09:04:54 -0700276// Create a new image object.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700277//
dsinclair5f597db2016-03-25 09:04:54 -0700278// document - handle to a document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700279//
dsinclair5f597db2016-03-25 09:04:54 -0700280// Returns a handle to a new image object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400281FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
Lei Zhangcbd89572017-03-15 17:35:47 -0700282FPDFPageObj_NewImageObj(FPDF_DOCUMENT document);
283
Henrique Nakashimac90adc52018-03-27 16:26:44 +0000284// Get number of content marks in |page_object|.
285//
286// page_object - handle to a page object.
287//
288// Returns the number of content marks in |page_object|, or -1 in case of
289// failure.
290FPDF_EXPORT int FPDF_CALLCONV
291FPDFPageObj_CountMarks(FPDF_PAGEOBJECT page_object);
292
293// Get content mark in |page_object| at |index|.
294//
295// page_object - handle to a page object.
296// index - the index of a page object.
297//
298// Returns the handle to the content mark, or NULL on failure. The handle is
299// still owned by the library, and it should not be freed directly. It becomes
300// invalid if the page object is destroyed, either directly or indirectly by
301// unloading the page.
302FPDF_EXPORT FPDF_PAGEOBJECTMARK FPDF_CALLCONV
303FPDFPageObj_GetMark(FPDF_PAGEOBJECT page_object, unsigned long index);
304
305// Get name of a content mark. |buffer| is only modified if |buflen| is longer
306// than the length of the name.
307//
308// mark - handle to a content mark.
309// buffer - buffer for holding the returned name in UTF16-LE.
310// buflen - length of the buffer.
311//
312// Returns the length of the name.
313FPDF_EXPORT unsigned long FPDF_CALLCONV
314FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark,
315 void* buffer,
316 unsigned long buflen);
317
dsinclair5f597db2016-03-25 09:04:54 -0700318// Load an image from a JPEG image file and then set it into |image_object|.
319//
320// pages - pointer to the start of all loaded pages, may be NULL.
321// nCount - number of |pages|, may be 0.
322// image_object - handle to an image object.
323// fileAccess - file access handler which specifies the JPEG image file.
324//
325// Returns TRUE on success.
326//
327// The image object might already have an associated image, which is shared and
328// cached by the loaded pages. In that case, we need to clear the cached image
329// for all the loaded pages. Pass |pages| and page count (|nCount|) to this API
330// to clear the image cache. If the image is not previously shared, or NULL is a
331// valid |pages| value.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400332FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
334 int nCount,
335 FPDF_PAGEOBJECT image_object,
336 FPDF_FILEACCESS* fileAccess);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700337
rbpotterf085db32016-12-14 11:44:31 -0800338// Load an image from a JPEG image file and then set it into |image_object|.
339//
340// pages - pointer to the start of all loaded pages, may be NULL.
341// nCount - number of |pages|, may be 0.
342// image_object - handle to an image object.
343// fileAccess - file access handler which specifies the JPEG image file.
344//
345// Returns TRUE on success.
346//
347// The image object might already have an associated image, which is shared and
348// cached by the loaded pages. In that case, we need to clear the cached image
349// for all the loaded pages. Pass |pages| and page count (|nCount|) to this API
350// to clear the image cache. If the image is not previously shared, or NULL is a
351// valid |pages| value. This function loads the JPEG image inline, so the image
352// content is copied to the file. This allows |fileAccess| and its associated
353// data to be deleted after this function returns.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400354FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
rbpotterf085db32016-12-14 11:44:31 -0800355FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages,
356 int nCount,
357 FPDF_PAGEOBJECT image_object,
358 FPDF_FILEACCESS* fileAccess);
359
dsinclair5f597db2016-03-25 09:04:54 -0700360// Set the transform matrix of |image_object|.
361//
362// image_object - handle to an image object.
363// a - matrix value.
364// b - matrix value.
365// c - matrix value.
366// d - matrix value.
367// e - matrix value.
368// f - matrix value.
369//
370// The matrix is composed as:
371// |a c e|
372// |b d f|
373// and can be used to scale, rotate, shear and translate the |page| annotations.
374//
375// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400376FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
377FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
378 double a,
379 double b,
380 double c,
381 double d,
382 double e,
383 double f);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700384
dsinclair5f597db2016-03-25 09:04:54 -0700385// Set |bitmap| to |image_object|.
386//
387// pages - pointer to the start of all loaded pages, may be NULL.
388// nCount - number of |pages|, may be 0.
389// image_object - handle to an image object.
390// bitmap - handle of the bitmap.
391//
392// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400393FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
394FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
395 int nCount,
396 FPDF_PAGEOBJECT image_object,
397 FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700398
Jane Liu28fb7ba2017-08-02 21:45:57 -0400399// Get a bitmap rasterisation of |image_object|. The returned bitmap will be
400// owned by the caller, and FPDFBitmap_Destroy() must be called on the returned
401// bitmap when it is no longer needed.
402//
403// image_object - handle to an image object.
404//
405// Returns the bitmap.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400406FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
Jane Liu28fb7ba2017-08-02 21:45:57 -0400407FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object);
408
Jane Liu548334e2017-08-03 16:33:40 -0400409// Get the decoded image data of |image_object|. The decoded data is the
410// uncompressed image data, i.e. the raw image data after having all filters
411// applied. |buffer| is only modified if |buflen| is longer than the length of
412// the decoded image data.
413//
414// image_object - handle to an image object.
415// buffer - buffer for holding the decoded image data in raw bytes.
416// buflen - length of the buffer.
417//
418// Returns the length of the decoded image data.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400419FPDF_EXPORT unsigned long FPDF_CALLCONV
Jane Liu548334e2017-08-03 16:33:40 -0400420FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
421 void* buffer,
422 unsigned long buflen);
423
424// Get the raw image data of |image_object|. The raw data is the image data as
425// stored in the PDF without applying any filters. |buffer| is only modified if
426// |buflen| is longer than the length of the raw image data.
427//
428// image_object - handle to an image object.
429// buffer - buffer for holding the raw image data in raw bytes.
430// buflen - length of the buffer.
431//
432// Returns the length of the raw image data.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400433FPDF_EXPORT unsigned long FPDF_CALLCONV
Jane Liu548334e2017-08-03 16:33:40 -0400434FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object,
435 void* buffer,
436 unsigned long buflen);
437
Jane Liube63ab92017-08-09 14:09:34 -0400438// Get the number of filters (i.e. decoders) of the image in |image_object|.
439//
440// image_object - handle to an image object.
441//
442// Returns the number of |image_object|'s filters.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400443FPDF_EXPORT int FPDF_CALLCONV
Jane Liube63ab92017-08-09 14:09:34 -0400444FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object);
445
446// Get the filter at |index| of |image_object|'s list of filters. Note that the
447// filters need to be applied in order, i.e. the first filter should be applied
448// first, then the second, etc. |buffer| is only modified if |buflen| is longer
449// than the length of the filter string.
450//
451// image_object - handle to an image object.
452// index - the index of the filter requested.
Lei Zhang0733a1b2017-08-31 12:36:31 -0700453// buffer - buffer for holding filter string, encoded in UTF-8.
Jane Liube63ab92017-08-09 14:09:34 -0400454// buflen - length of the buffer.
455//
456// Returns the length of the filter string.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400457FPDF_EXPORT unsigned long FPDF_CALLCONV
Jane Liube63ab92017-08-09 14:09:34 -0400458FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object,
459 int index,
460 void* buffer,
461 unsigned long buflen);
462
Jane Liuca898292017-08-16 11:25:35 -0400463// Get the image metadata of |image_object|, including dimension, DPI, bits per
464// pixel, and colorspace. If the |image_object| is not an image object or if it
465// does not have an image, then the return value will be false. Otherwise,
466// failure to retrieve any specific parameter would result in its value being 0.
467//
468// image_object - handle to an image object.
469// page - handle to the page that |image_object| is on. Required for
470// retrieving the image's bits per pixel and colorspace.
471// metadata - receives the image metadata; must not be NULL.
472//
473// Returns true if successful.
474FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
475FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object,
476 FPDF_PAGE page,
477 FPDF_IMAGEOBJ_METADATA* metadata);
478
Nicolas Pena55e026b2017-02-07 14:59:23 -0500479// Create a new path object at an initial position.
480//
481// x - initial horizontal position.
482// y - initial vertical position.
483//
484// Returns a handle to a new path object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400485FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x,
486 float y);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500487
488// Create a closed path consisting of a rectangle.
489//
490// x - horizontal position for the left boundary of the rectangle.
491// y - vertical position for the bottom boundary of the rectangle.
492// w - width of the rectangle.
493// h - height of the rectangle.
494//
495// Returns a handle to the new path object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400496FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x,
497 float y,
498 float w,
499 float h);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500500
Nicolas Pena603a31d2017-06-14 11:41:18 -0400501// Get the bounding box of |page_object|.
wileyryaf1697fa2017-05-26 12:27:40 -0500502//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400503// page_object - handle to a page object.
504// left - pointer where the left coordinate will be stored
505// bottom - pointer where the bottom coordinate will be stored
506// right - pointer where the right coordinate will be stored
507// top - pointer where the top coordinate will be stored
wileyryaf1697fa2017-05-26 12:27:40 -0500508//
509// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400510FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
511FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object,
512 float* left,
513 float* bottom,
514 float* right,
515 float* top);
wileyryaf1697fa2017-05-26 12:27:40 -0500516
Nicolas Pena603a31d2017-06-14 11:41:18 -0400517// Set the blend mode of |page_object|.
wileyrya06bbdef2017-05-26 15:20:23 -0500518//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400519// page_object - handle to a page object.
520// blend_mode - string containing the blend mode.
wileyrya06bbdef2017-05-26 15:20:23 -0500521//
522// Blend mode can be one of following: Color, ColorBurn, ColorDodge, Darken,
523// Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply, Normal,
524// Overlay, Saturation, Screen, SoftLight
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400525FPDF_EXPORT void FPDF_CALLCONV
526FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object,
527 FPDF_BYTESTRING blend_mode);
wileyrya06bbdef2017-05-26 15:20:23 -0500528
Nicolas Pena55e026b2017-02-07 14:59:23 -0500529// Set the stroke RGBA of a path. Range of values: 0 - 255.
530//
531// path - the handle to the path object.
532// R - the red component for the path stroke color.
533// G - the green component for the path stroke color.
534// B - the blue component for the path stroke color.
535// A - the stroke alpha for the path.
536//
537// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400538FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
539FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path,
540 unsigned int R,
541 unsigned int G,
542 unsigned int B,
543 unsigned int A);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500544
Jane Liu3b057432017-06-19 10:44:01 -0400545// Get the stroke RGBA of a path. Range of values: 0 - 255.
546//
547// path - the handle to the path object.
548// R - the red component of the path stroke color.
549// G - the green component of the path stroke color.
550// B - the blue component of the path stroke color.
551// A - the stroke alpha of the path.
552//
553// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400554FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
555FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path,
556 unsigned int* R,
557 unsigned int* G,
558 unsigned int* B,
559 unsigned int* A);
Jane Liu3b057432017-06-19 10:44:01 -0400560
Nicolas Pena2eb1a702017-02-09 18:17:33 -0500561// Set the stroke width of a path.
562//
563// path - the handle to the path object.
564// width - the width of the stroke.
565//
566// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400567FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
568FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width);
Nicolas Pena2eb1a702017-02-09 18:17:33 -0500569
Nicolas Pena603a31d2017-06-14 11:41:18 -0400570// Set the line join of |page_object|.
wileyrya22a237f2017-05-26 09:26:27 -0500571//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400572// page_object - handle to a page object.
573// line_join - line join
wileyrya22a237f2017-05-26 09:26:27 -0500574//
wileyrya5be0b292017-05-31 19:13:37 -0500575// Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND,
576// FPDF_LINEJOIN_BEVEL
Lei Zhang9ccf0872017-12-19 18:50:15 +0000577FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT page_object,
578 int line_join);
wileyrya22a237f2017-05-26 09:26:27 -0500579
Nicolas Pena603a31d2017-06-14 11:41:18 -0400580// Set the line cap of |page_object|.
wileyrya22a237f2017-05-26 09:26:27 -0500581//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400582// page_object - handle to a page object.
583// line_cap - line cap
wileyrya22a237f2017-05-26 09:26:27 -0500584//
wileyrya5be0b292017-05-31 19:13:37 -0500585// Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND,
586// FPDF_LINECAP_PROJECTING_SQUARE
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400587FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT page_object,
588 int line_cap);
wileyrya22a237f2017-05-26 09:26:27 -0500589
Nicolas Pena55e026b2017-02-07 14:59:23 -0500590// Set the fill RGBA of a path. Range of values: 0 - 255.
591//
592// path - the handle to the path object.
593// R - the red component for the path fill color.
594// G - the green component for the path fill color.
595// B - the blue component for the path fill color.
596// A - the fill alpha for the path.
597//
598// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400599FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
600 unsigned int R,
601 unsigned int G,
602 unsigned int B,
603 unsigned int A);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500604
Miklos Vajnaed4705b2017-04-05 09:24:50 +0200605// Get the fill RGBA of a path. Range of values: 0 - 255.
606//
607// path - the handle to the path object.
608// R - the red component of the path fill color.
609// G - the green component of the path fill color.
610// B - the blue component of the path fill color.
611// A - the fill alpha of the path.
612//
613// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400614FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetFillColor(FPDF_PAGEOBJECT path,
615 unsigned int* R,
616 unsigned int* G,
617 unsigned int* B,
618 unsigned int* A);
Miklos Vajnaed4705b2017-04-05 09:24:50 +0200619
Miklos Vajna36eed872017-09-20 22:52:43 +0200620// Experimental API.
Miklos Vajna0150a542017-09-21 21:46:56 +0200621// Get number of segments inside |path|.
Miklos Vajna12abfd02017-09-15 07:49:03 +0200622//
623// path - handle to a path.
624//
Miklos Vajna0150a542017-09-21 21:46:56 +0200625// A segment is a command, created by e.g. FPDFPath_MoveTo(),
626// FPDFPath_LineTo() or FPDFPath_BezierTo().
Miklos Vajna12abfd02017-09-15 07:49:03 +0200627//
628// Returns the number of objects in |path| or -1 on failure.
Miklos Vajna0150a542017-09-21 21:46:56 +0200629FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path);
Miklos Vajna12abfd02017-09-15 07:49:03 +0200630
Miklos Vajna36eed872017-09-20 22:52:43 +0200631// Experimental API.
632// Get segment in |path| at |index|.
633//
634// path - handle to a path.
635// index - the index of a segment.
636//
637// Returns the handle to the segment, or NULL on faiure.
638FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
639FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index);
640
641// Experimental API.
642// Get coordinates of |segment|.
643//
644// segment - handle to a segment.
645// x - the horizontal position of the segment.
646// y - the vertical position of the segment.
647//
648// Returns TRUE on success, otherwise |x| and |y| is not set.
649FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
650FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y);
651
652// Experimental API.
653// Get type of |segment|.
654//
655// segment - handle to a segment.
656//
657// Returns one of the FPDF_SEGMENT_* values on success,
658// FPDF_SEGMENT_UNKNOWN on error.
659FPDF_EXPORT int FPDF_CALLCONV FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment);
660
661// Experimental API.
662// Gets if the |segment| closes the current subpath of a given path.
663//
664// segment - handle to a segment.
665//
666// Returns close flag for non-NULL segment, FALSE otherwise.
667FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
668FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment);
669
Nicolas Pena55e026b2017-02-07 14:59:23 -0500670// Move a path's current point.
671//
672// path - the handle to the path object.
673// x - the horizontal position of the new current point.
674// y - the vertical position of the new current point.
675//
676// Note that no line will be created between the previous current point and the
677// new one.
678//
679// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400680FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path,
681 float x,
682 float y);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500683
684// Add a line between the current point and a new point in the path.
685//
686// path - the handle to the path object.
687// x - the horizontal position of the new point.
688// y - the vertical position of the new point.
689//
690// The path's current point is changed to (x, y).
691//
692// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400693FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path,
694 float x,
695 float y);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500696
697// Add a cubic Bezier curve to the given path, starting at the current point.
698//
699// path - the handle to the path object.
700// x1 - the horizontal position of the first Bezier control point.
701// y1 - the vertical position of the first Bezier control point.
702// x2 - the horizontal position of the second Bezier control point.
703// y2 - the vertical position of the second Bezier control point.
704// x3 - the horizontal position of the ending point of the Bezier curve.
705// y3 - the vertical position of the ending point of the Bezier curve.
706//
707// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400708FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path,
709 float x1,
710 float y1,
711 float x2,
712 float y2,
713 float x3,
714 float y3);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500715
716// Close the current subpath of a given path.
717//
718// path - the handle to the path object.
719//
720// This will add a line between the current point and the initial point of the
721// subpath, thus terminating the current subpath.
722//
723// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400724FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500725
726// Set the drawing mode of a path.
727//
728// path - the handle to the path object.
729// fillmode - the filling mode to be set: 0 for no fill, 1 for alternate, 2 for
730// winding.
731// stroke - a boolean specifying if the path should be stroked or not.
732//
733// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400734FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
735 int fillmode,
736 FPDF_BOOL stroke);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500737
Nicolas Pena49058402017-02-14 18:26:20 -0500738// Create a new text object using one of the standard PDF fonts.
739//
740// document - handle to the document.
741// font - string containing the font name, without spaces.
742// font_size - the font size for the new text object.
743//
744// Returns a handle to a new text object, or NULL on failure
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400745FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
746FPDFPageObj_NewTextObj(FPDF_DOCUMENT document,
747 FPDF_BYTESTRING font,
748 float font_size);
Nicolas Pena49058402017-02-14 18:26:20 -0500749
750// Set the text for a textobject. If it had text, it will be replaced.
751//
752// text_object - handle to the text object.
Nicolas Penab3161852017-05-02 14:12:50 -0400753// text - the UTF-16LE encoded string containing the text to be added.
Nicolas Pena49058402017-02-14 18:26:20 -0500754//
755// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400756FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
757FPDFText_SetText(FPDF_PAGEOBJECT text_object, FPDF_WIDESTRING text);
Nicolas Pena49058402017-02-14 18:26:20 -0500758
Nicolas Penad03ca422017-03-06 13:54:33 -0500759// Returns a font object loaded from a stream of data. The font is loaded
Nicolas Pena46abb662017-05-17 17:23:22 -0400760// into the document.
Nicolas Penabe90aae2017-02-27 10:41:41 -0500761//
Nicolas Penad03ca422017-03-06 13:54:33 -0500762// document - handle to the document.
763// data - the stream of data, which will be copied by the font object.
764// size - size of the stream, in bytes.
765// font_type - FPDF_FONT_TYPE1 or FPDF_FONT_TRUETYPE depending on the font
766// type.
767// cid - a boolean specifying if the font is a CID font or not.
Nicolas Penabe90aae2017-02-27 10:41:41 -0500768//
Nicolas Penab3161852017-05-02 14:12:50 -0400769// The loaded font can be closed using FPDF_Font_Close.
770//
Nicolas Penabe90aae2017-02-27 10:41:41 -0500771// Returns NULL on failure
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400772FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document,
773 const uint8_t* data,
774 uint32_t size,
775 int font_type,
776 FPDF_BOOL cid);
Nicolas Penabe90aae2017-02-27 10:41:41 -0500777
wileyrya864e9fb2017-05-26 11:38:14 -0500778// Set the fill RGBA of a text object. Range of values: 0 - 255.
779//
780// text_object - handle to the text object.
781// R - the red component for the path fill color.
782// G - the green component for the path fill color.
783// B - the blue component for the path fill color.
784// A - the fill alpha for the path.
785//
786// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400787FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
788FPDFText_SetFillColor(FPDF_PAGEOBJECT text_object,
789 unsigned int R,
790 unsigned int G,
791 unsigned int B,
792 unsigned int A);
wileyrya864e9fb2017-05-26 11:38:14 -0500793
Nicolas Penab3161852017-05-02 14:12:50 -0400794// Close a loaded PDF font.
795//
796// font - Handle to the loaded font.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400797FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font);
Nicolas Penab3161852017-05-02 14:12:50 -0400798
799// Create a new text object using a loaded font.
800//
801// document - handle to the document.
802// font - handle to the font object.
803// font_size - the font size for the new text object.
804//
805// Returns a handle to a new text object, or NULL on failure
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400806FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
Nicolas Penab3161852017-05-02 14:12:50 -0400807FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
808 FPDF_FONT font,
809 float font_size);
810
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700811#ifdef __cplusplus
dsinclair5f597db2016-03-25 09:04:54 -0700812} // extern "C"
813#endif // __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -0700814
815#endif // PUBLIC_FPDF_EDIT_H_