blob: f2dad739ca9ca2341002042a8cb8336b1916f43d [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;
83} FPDF_IMAGEOBJ_METADATA;
84
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070085#ifdef __cplusplus
86extern "C" {
dsinclair5f597db2016-03-25 09:04:54 -070087#endif // __cplusplus
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070088
dsinclair5f597db2016-03-25 09:04:54 -070089// Create a new PDF document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070090//
dsinclair5f597db2016-03-25 09:04:54 -070091// Returns a handle to a new document, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -040092FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070093
dsinclair5f597db2016-03-25 09:04:54 -070094// Create a new PDF page.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070095//
dsinclair5f597db2016-03-25 09:04:54 -070096// document - handle to document.
weili9b777de2016-08-19 16:19:46 -070097// page_index - suggested index of the page to create. If it is larger than
98// document's current last index(L), the created page index is
99// the next available index -- L+1.
dsinclair5f597db2016-03-25 09:04:54 -0700100// width - the page width.
101// height - the page height.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700102//
dsinclair5f597db2016-03-25 09:04:54 -0700103// Returns the handle to the new page.
104//
weili9b777de2016-08-19 16:19:46 -0700105// The page should be closed with CPDF_ClosePage() when finished as
106// with any other page in the document.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400107FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
108 int page_index,
109 double width,
110 double height);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700111
dsinclair5f597db2016-03-25 09:04:54 -0700112// Delete the page at |page_index|.
113//
114// document - handle to document.
115// page_index - the index of the page to delete.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400116FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document,
117 int page_index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118
dsinclair5f597db2016-03-25 09:04:54 -0700119// Get the rotation of |page|.
120//
121// page - handle to a page
122//
123// Returns one of the following indicating the page rotation:
124// 0 - No rotation.
125// 1 - Rotated 90 degrees clockwise.
126// 2 - Rotated 180 degrees clockwise.
127// 3 - Rotated 270 degrees clockwise.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400128FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetRotation(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700129
dsinclair5f597db2016-03-25 09:04:54 -0700130// Set rotation for |page|.
Tom Sepez9857e202015-05-13 17:09:26 -0700131//
dsinclair5f597db2016-03-25 09:04:54 -0700132// page - handle to a page.
133// rotate - the rotation value, one of:
134// 0 - No rotation.
135// 1 - Rotated 90 degrees clockwise.
136// 2 - Rotated 180 degrees clockwise.
137// 3 - Rotated 270 degrees clockwise.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400138FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
Bo Xu394010d2014-06-12 13:41:50 -0700139
dsinclair5f597db2016-03-25 09:04:54 -0700140// Insert |page_obj| into |page|.
141//
142// page - handle to a page
143// page_obj - handle to a page object. The |page_obj| will be automatically
144// freed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400145FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page,
146 FPDF_PAGEOBJECT page_obj);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700147
dsinclair5f597db2016-03-25 09:04:54 -0700148// Get number of page objects inside |page|.
149//
150// page - handle to a page.
151//
152// Returns the number of objects in |page|.
Miklos Vajna92627612017-09-25 12:59:29 +0200153//
154// DEPRECATED. Please use FPDFPage_CountObjects.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400155FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObject(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700156
Miklos Vajna92627612017-09-25 12:59:29 +0200157// Get number of page objects inside |page|.
158//
159// page - handle to a page.
160//
161// Returns the number of objects in |page|.
162FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page);
163
dsinclair5f597db2016-03-25 09:04:54 -0700164// Get object in |page| at |index|.
165//
166// page - handle to a page.
167// index - the index of a page object.
168//
169// Returns the handle to the page object, or NULL on failed.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400170FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page,
171 int index);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700172
dsinclair5f597db2016-03-25 09:04:54 -0700173// Checks if |page| contains transparency.
174//
175// page - handle to a page.
176//
177// Returns TRUE if |page| contains transparency.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400178FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700179
dsinclair5f597db2016-03-25 09:04:54 -0700180// Generate the content of |page|.
181//
182// page - handle to a page.
183//
184// Returns TRUE on success.
185//
186// Before you save the page to a file, or reload the page, you must call
187// |FPDFPage_GenerateContent| or any changes to |page| will be lost.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400188FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189
Jane Liu2e5f0ae2017-08-08 15:23:27 -0400190// Destroy |page_obj| by releasing its resources. |page_obj| must have been
191// created by FPDFPageObj_CreateNew{Path|Rect}() or
192// FPDFPageObj_New{Text|Image}Obj(). This function must be called on
193// newly-created objects if they are not added to a page through
194// FPDFPage_InsertObject() or to an annotation through FPDFAnnot_AppendObject().
195//
196// page_obj - handle to a page object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400197FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj);
Jane Liu2e5f0ae2017-08-08 15:23:27 -0400198
Nicolas Pena603a31d2017-06-14 11:41:18 -0400199// Checks if |page_object| contains transparency.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700200//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400201// page_object - handle to a page object.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700202//
dsinclair5f597db2016-03-25 09:04:54 -0700203// Returns TRUE if |pageObject| contains transparency.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400204FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Nicolas Pena603a31d2017-06-14 11:41:18 -0400205FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT page_object);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700206
Nicolas Pena603a31d2017-06-14 11:41:18 -0400207// Get type of |page_object|.
Miklos Vajna14233192017-04-03 16:02:39 +0200208//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400209// page_object - handle to a page object.
Miklos Vajna14233192017-04-03 16:02:39 +0200210//
211// Returns one of the FPDF_PAGEOBJ_* values on success, FPDF_PAGEOBJ_UNKNOWN on
212// error.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400213FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object);
Miklos Vajna14233192017-04-03 16:02:39 +0200214
Nicolas Pena603a31d2017-06-14 11:41:18 -0400215// Transform |page_object| by the given matrix.
dsinclair5f597db2016-03-25 09:04:54 -0700216//
217// page_object - handle to a page object.
218// a - matrix value.
219// b - matrix value.
220// c - matrix value.
221// d - matrix value.
222// e - matrix value.
223// f - matrix value.
224//
225// The matrix is composed as:
226// |a c e|
227// |b d f|
228// and can be used to scale, rotate, shear and translate the |page_object|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400229FPDF_EXPORT void FPDF_CALLCONV
230FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
231 double a,
232 double b,
233 double c,
234 double d,
235 double e,
236 double f);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700237
dsinclair5f597db2016-03-25 09:04:54 -0700238// Transform all annotations in |page|.
239//
240// page - handle to a page.
241// a - matrix value.
242// b - matrix value.
243// c - matrix value.
244// d - matrix value.
245// e - matrix value.
246// f - matrix value.
247//
248// The matrix is composed as:
249// |a c e|
250// |b d f|
251// and can be used to scale, rotate, shear and translate the |page| annotations.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400252FPDF_EXPORT void FPDF_CALLCONV FPDFPage_TransformAnnots(FPDF_PAGE page,
253 double a,
254 double b,
255 double c,
256 double d,
257 double e,
258 double f);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700259
dsinclair5f597db2016-03-25 09:04:54 -0700260// Create a new image object.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700261//
dsinclair5f597db2016-03-25 09:04:54 -0700262// document - handle to a document.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700263//
dsinclair5f597db2016-03-25 09:04:54 -0700264// Returns a handle to a new image object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400265FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
Lei Zhangcbd89572017-03-15 17:35:47 -0700266FPDFPageObj_NewImageObj(FPDF_DOCUMENT document);
267
dsinclair5f597db2016-03-25 09:04:54 -0700268// Load an image from a JPEG image file and then set it into |image_object|.
269//
270// pages - pointer to the start of all loaded pages, may be NULL.
271// nCount - number of |pages|, may be 0.
272// image_object - handle to an image object.
273// fileAccess - file access handler which specifies the JPEG image file.
274//
275// Returns TRUE on success.
276//
277// The image object might already have an associated image, which is shared and
278// cached by the loaded pages. In that case, we need to clear the cached image
279// for all the loaded pages. Pass |pages| and page count (|nCount|) to this API
280// to clear the image cache. If the image is not previously shared, or NULL is a
281// valid |pages| value.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400282FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700283FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
284 int nCount,
285 FPDF_PAGEOBJECT image_object,
286 FPDF_FILEACCESS* fileAccess);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700287
rbpotterf085db32016-12-14 11:44:31 -0800288// Load an image from a JPEG image file and then set it into |image_object|.
289//
290// pages - pointer to the start of all loaded pages, may be NULL.
291// nCount - number of |pages|, may be 0.
292// image_object - handle to an image object.
293// fileAccess - file access handler which specifies the JPEG image file.
294//
295// Returns TRUE on success.
296//
297// The image object might already have an associated image, which is shared and
298// cached by the loaded pages. In that case, we need to clear the cached image
299// for all the loaded pages. Pass |pages| and page count (|nCount|) to this API
300// to clear the image cache. If the image is not previously shared, or NULL is a
301// valid |pages| value. This function loads the JPEG image inline, so the image
302// content is copied to the file. This allows |fileAccess| and its associated
303// data to be deleted after this function returns.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400304FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
rbpotterf085db32016-12-14 11:44:31 -0800305FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages,
306 int nCount,
307 FPDF_PAGEOBJECT image_object,
308 FPDF_FILEACCESS* fileAccess);
309
dsinclair5f597db2016-03-25 09:04:54 -0700310// Set the transform matrix of |image_object|.
311//
312// image_object - handle to an image object.
313// a - matrix value.
314// b - matrix value.
315// c - matrix value.
316// d - matrix value.
317// e - matrix value.
318// f - matrix value.
319//
320// The matrix is composed as:
321// |a c e|
322// |b d f|
323// and can be used to scale, rotate, shear and translate the |page| annotations.
324//
325// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400326FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
327FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
328 double a,
329 double b,
330 double c,
331 double d,
332 double e,
333 double f);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700334
dsinclair5f597db2016-03-25 09:04:54 -0700335// Set |bitmap| to |image_object|.
336//
337// pages - pointer to the start of all loaded pages, may be NULL.
338// nCount - number of |pages|, may be 0.
339// image_object - handle to an image object.
340// bitmap - handle of the bitmap.
341//
342// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400343FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
344FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
345 int nCount,
346 FPDF_PAGEOBJECT image_object,
347 FPDF_BITMAP bitmap);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700348
Jane Liu28fb7ba2017-08-02 21:45:57 -0400349// Get a bitmap rasterisation of |image_object|. The returned bitmap will be
350// owned by the caller, and FPDFBitmap_Destroy() must be called on the returned
351// bitmap when it is no longer needed.
352//
353// image_object - handle to an image object.
354//
355// Returns the bitmap.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400356FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
Jane Liu28fb7ba2017-08-02 21:45:57 -0400357FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object);
358
Jane Liu548334e2017-08-03 16:33:40 -0400359// Get the decoded image data of |image_object|. The decoded data is the
360// uncompressed image data, i.e. the raw image data after having all filters
361// applied. |buffer| is only modified if |buflen| is longer than the length of
362// the decoded image data.
363//
364// image_object - handle to an image object.
365// buffer - buffer for holding the decoded image data in raw bytes.
366// buflen - length of the buffer.
367//
368// Returns the length of the decoded image data.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400369FPDF_EXPORT unsigned long FPDF_CALLCONV
Jane Liu548334e2017-08-03 16:33:40 -0400370FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
371 void* buffer,
372 unsigned long buflen);
373
374// Get the raw image data of |image_object|. The raw data is the image data as
375// stored in the PDF without applying any filters. |buffer| is only modified if
376// |buflen| is longer than the length of the raw image data.
377//
378// image_object - handle to an image object.
379// buffer - buffer for holding the raw image data in raw bytes.
380// buflen - length of the buffer.
381//
382// Returns the length of the raw image data.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400383FPDF_EXPORT unsigned long FPDF_CALLCONV
Jane Liu548334e2017-08-03 16:33:40 -0400384FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object,
385 void* buffer,
386 unsigned long buflen);
387
Jane Liube63ab92017-08-09 14:09:34 -0400388// Get the number of filters (i.e. decoders) of the image in |image_object|.
389//
390// image_object - handle to an image object.
391//
392// Returns the number of |image_object|'s filters.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400393FPDF_EXPORT int FPDF_CALLCONV
Jane Liube63ab92017-08-09 14:09:34 -0400394FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object);
395
396// Get the filter at |index| of |image_object|'s list of filters. Note that the
397// filters need to be applied in order, i.e. the first filter should be applied
398// first, then the second, etc. |buffer| is only modified if |buflen| is longer
399// than the length of the filter string.
400//
401// image_object - handle to an image object.
402// index - the index of the filter requested.
Lei Zhang0733a1b2017-08-31 12:36:31 -0700403// buffer - buffer for holding filter string, encoded in UTF-8.
Jane Liube63ab92017-08-09 14:09:34 -0400404// buflen - length of the buffer.
405//
406// Returns the length of the filter string.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400407FPDF_EXPORT unsigned long FPDF_CALLCONV
Jane Liube63ab92017-08-09 14:09:34 -0400408FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object,
409 int index,
410 void* buffer,
411 unsigned long buflen);
412
Jane Liuca898292017-08-16 11:25:35 -0400413// Get the image metadata of |image_object|, including dimension, DPI, bits per
414// pixel, and colorspace. If the |image_object| is not an image object or if it
415// does not have an image, then the return value will be false. Otherwise,
416// failure to retrieve any specific parameter would result in its value being 0.
417//
418// image_object - handle to an image object.
419// page - handle to the page that |image_object| is on. Required for
420// retrieving the image's bits per pixel and colorspace.
421// metadata - receives the image metadata; must not be NULL.
422//
423// Returns true if successful.
424FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
425FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object,
426 FPDF_PAGE page,
427 FPDF_IMAGEOBJ_METADATA* metadata);
428
Nicolas Pena55e026b2017-02-07 14:59:23 -0500429// Create a new path object at an initial position.
430//
431// x - initial horizontal position.
432// y - initial vertical position.
433//
434// Returns a handle to a new path object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400435FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x,
436 float y);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500437
438// Create a closed path consisting of a rectangle.
439//
440// x - horizontal position for the left boundary of the rectangle.
441// y - vertical position for the bottom boundary of the rectangle.
442// w - width of the rectangle.
443// h - height of the rectangle.
444//
445// Returns a handle to the new path object.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400446FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x,
447 float y,
448 float w,
449 float h);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500450
Nicolas Pena603a31d2017-06-14 11:41:18 -0400451// Get the bounding box of |page_object|.
wileyryaf1697fa2017-05-26 12:27:40 -0500452//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400453// page_object - handle to a page object.
454// left - pointer where the left coordinate will be stored
455// bottom - pointer where the bottom coordinate will be stored
456// right - pointer where the right coordinate will be stored
457// top - pointer where the top coordinate will be stored
wileyryaf1697fa2017-05-26 12:27:40 -0500458//
459// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400460FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
461FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object,
462 float* left,
463 float* bottom,
464 float* right,
465 float* top);
wileyryaf1697fa2017-05-26 12:27:40 -0500466
Nicolas Pena603a31d2017-06-14 11:41:18 -0400467// Set the blend mode of |page_object|.
wileyrya06bbdef2017-05-26 15:20:23 -0500468//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400469// page_object - handle to a page object.
470// blend_mode - string containing the blend mode.
wileyrya06bbdef2017-05-26 15:20:23 -0500471//
472// Blend mode can be one of following: Color, ColorBurn, ColorDodge, Darken,
473// Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply, Normal,
474// Overlay, Saturation, Screen, SoftLight
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400475FPDF_EXPORT void FPDF_CALLCONV
476FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object,
477 FPDF_BYTESTRING blend_mode);
wileyrya06bbdef2017-05-26 15:20:23 -0500478
Nicolas Pena55e026b2017-02-07 14:59:23 -0500479// Set the stroke RGBA of a path. Range of values: 0 - 255.
480//
481// path - the handle to the path object.
482// R - the red component for the path stroke color.
483// G - the green component for the path stroke color.
484// B - the blue component for the path stroke color.
485// A - the stroke alpha for the path.
486//
487// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400488FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
489FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path,
490 unsigned int R,
491 unsigned int G,
492 unsigned int B,
493 unsigned int A);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500494
Jane Liu3b057432017-06-19 10:44:01 -0400495// Get the stroke RGBA of a path. Range of values: 0 - 255.
496//
497// path - the handle to the path object.
498// R - the red component of the path stroke color.
499// G - the green component of the path stroke color.
500// B - the blue component of the path stroke color.
501// A - the stroke alpha of the path.
502//
503// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400504FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
505FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path,
506 unsigned int* R,
507 unsigned int* G,
508 unsigned int* B,
509 unsigned int* A);
Jane Liu3b057432017-06-19 10:44:01 -0400510
Nicolas Pena2eb1a702017-02-09 18:17:33 -0500511// Set the stroke width of a path.
512//
513// path - the handle to the path object.
514// width - the width of the stroke.
515//
516// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400517FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
518FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width);
Nicolas Pena2eb1a702017-02-09 18:17:33 -0500519
Nicolas Pena603a31d2017-06-14 11:41:18 -0400520// Set the line join of |page_object|.
wileyrya22a237f2017-05-26 09:26:27 -0500521//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400522// page_object - handle to a page object.
523// line_join - line join
wileyrya22a237f2017-05-26 09:26:27 -0500524//
wileyrya5be0b292017-05-31 19:13:37 -0500525// Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND,
526// FPDF_LINEJOIN_BEVEL
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400527FPDF_EXPORT void FPDF_CALLCONV FPDF_CALLCONV
528FPDFPath_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join);
wileyrya22a237f2017-05-26 09:26:27 -0500529
Nicolas Pena603a31d2017-06-14 11:41:18 -0400530// Set the line cap of |page_object|.
wileyrya22a237f2017-05-26 09:26:27 -0500531//
Nicolas Pena603a31d2017-06-14 11:41:18 -0400532// page_object - handle to a page object.
533// line_cap - line cap
wileyrya22a237f2017-05-26 09:26:27 -0500534//
wileyrya5be0b292017-05-31 19:13:37 -0500535// Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND,
536// FPDF_LINECAP_PROJECTING_SQUARE
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400537FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT page_object,
538 int line_cap);
wileyrya22a237f2017-05-26 09:26:27 -0500539
Nicolas Pena55e026b2017-02-07 14:59:23 -0500540// Set the fill RGBA of a path. Range of values: 0 - 255.
541//
542// path - the handle to the path object.
543// R - the red component for the path fill color.
544// G - the green component for the path fill color.
545// B - the blue component for the path fill color.
546// A - the fill alpha for the path.
547//
548// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400549FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
550 unsigned int R,
551 unsigned int G,
552 unsigned int B,
553 unsigned int A);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500554
Miklos Vajnaed4705b2017-04-05 09:24:50 +0200555// Get the fill RGBA of a path. Range of values: 0 - 255.
556//
557// path - the handle to the path object.
558// R - the red component of the path fill color.
559// G - the green component of the path fill color.
560// B - the blue component of the path fill color.
561// A - the fill alpha of the path.
562//
563// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400564FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetFillColor(FPDF_PAGEOBJECT path,
565 unsigned int* R,
566 unsigned int* G,
567 unsigned int* B,
568 unsigned int* A);
Miklos Vajnaed4705b2017-04-05 09:24:50 +0200569
Miklos Vajna36eed872017-09-20 22:52:43 +0200570// Experimental API.
Miklos Vajna0150a542017-09-21 21:46:56 +0200571// Get number of segments inside |path|.
Miklos Vajna12abfd02017-09-15 07:49:03 +0200572//
573// path - handle to a path.
574//
Miklos Vajna0150a542017-09-21 21:46:56 +0200575// A segment is a command, created by e.g. FPDFPath_MoveTo(),
576// FPDFPath_LineTo() or FPDFPath_BezierTo().
Miklos Vajna12abfd02017-09-15 07:49:03 +0200577//
578// Returns the number of objects in |path| or -1 on failure.
Miklos Vajna0150a542017-09-21 21:46:56 +0200579FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path);
Miklos Vajna12abfd02017-09-15 07:49:03 +0200580
Miklos Vajna36eed872017-09-20 22:52:43 +0200581// Experimental API.
582// Get segment in |path| at |index|.
583//
584// path - handle to a path.
585// index - the index of a segment.
586//
587// Returns the handle to the segment, or NULL on faiure.
588FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
589FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index);
590
591// Experimental API.
592// Get coordinates of |segment|.
593//
594// segment - handle to a segment.
595// x - the horizontal position of the segment.
596// y - the vertical position of the segment.
597//
598// Returns TRUE on success, otherwise |x| and |y| is not set.
599FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
600FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y);
601
602// Experimental API.
603// Get type of |segment|.
604//
605// segment - handle to a segment.
606//
607// Returns one of the FPDF_SEGMENT_* values on success,
608// FPDF_SEGMENT_UNKNOWN on error.
609FPDF_EXPORT int FPDF_CALLCONV FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment);
610
611// Experimental API.
612// Gets if the |segment| closes the current subpath of a given path.
613//
614// segment - handle to a segment.
615//
616// Returns close flag for non-NULL segment, FALSE otherwise.
617FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
618FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment);
619
Nicolas Pena55e026b2017-02-07 14:59:23 -0500620// Move a path's current point.
621//
622// path - the handle to the path object.
623// x - the horizontal position of the new current point.
624// y - the vertical position of the new current point.
625//
626// Note that no line will be created between the previous current point and the
627// new one.
628//
629// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400630FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path,
631 float x,
632 float y);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500633
634// Add a line between the current point and a new point in the path.
635//
636// path - the handle to the path object.
637// x - the horizontal position of the new point.
638// y - the vertical position of the new point.
639//
640// The path's current point is changed to (x, y).
641//
642// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400643FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path,
644 float x,
645 float y);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500646
647// Add a cubic Bezier curve to the given path, starting at the current point.
648//
649// path - the handle to the path object.
650// x1 - the horizontal position of the first Bezier control point.
651// y1 - the vertical position of the first Bezier control point.
652// x2 - the horizontal position of the second Bezier control point.
653// y2 - the vertical position of the second Bezier control point.
654// x3 - the horizontal position of the ending point of the Bezier curve.
655// y3 - the vertical position of the ending point of the Bezier curve.
656//
657// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400658FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path,
659 float x1,
660 float y1,
661 float x2,
662 float y2,
663 float x3,
664 float y3);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500665
666// Close the current subpath of a given path.
667//
668// path - the handle to the path object.
669//
670// This will add a line between the current point and the initial point of the
671// subpath, thus terminating the current subpath.
672//
673// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400674FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500675
676// Set the drawing mode of a path.
677//
678// path - the handle to the path object.
679// fillmode - the filling mode to be set: 0 for no fill, 1 for alternate, 2 for
680// winding.
681// stroke - a boolean specifying if the path should be stroked or not.
682//
683// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400684FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
685 int fillmode,
686 FPDF_BOOL stroke);
Nicolas Pena55e026b2017-02-07 14:59:23 -0500687
Nicolas Pena49058402017-02-14 18:26:20 -0500688// Create a new text object using one of the standard PDF fonts.
689//
690// document - handle to the document.
691// font - string containing the font name, without spaces.
692// font_size - the font size for the new text object.
693//
694// Returns a handle to a new text object, or NULL on failure
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400695FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
696FPDFPageObj_NewTextObj(FPDF_DOCUMENT document,
697 FPDF_BYTESTRING font,
698 float font_size);
Nicolas Pena49058402017-02-14 18:26:20 -0500699
700// Set the text for a textobject. If it had text, it will be replaced.
701//
702// text_object - handle to the text object.
Nicolas Penab3161852017-05-02 14:12:50 -0400703// text - the UTF-16LE encoded string containing the text to be added.
Nicolas Pena49058402017-02-14 18:26:20 -0500704//
705// Returns TRUE on success
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400706FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
707FPDFText_SetText(FPDF_PAGEOBJECT text_object, FPDF_WIDESTRING text);
Nicolas Pena49058402017-02-14 18:26:20 -0500708
Nicolas Penad03ca422017-03-06 13:54:33 -0500709// Returns a font object loaded from a stream of data. The font is loaded
Nicolas Pena46abb662017-05-17 17:23:22 -0400710// into the document.
Nicolas Penabe90aae2017-02-27 10:41:41 -0500711//
Nicolas Penad03ca422017-03-06 13:54:33 -0500712// document - handle to the document.
713// data - the stream of data, which will be copied by the font object.
714// size - size of the stream, in bytes.
715// font_type - FPDF_FONT_TYPE1 or FPDF_FONT_TRUETYPE depending on the font
716// type.
717// cid - a boolean specifying if the font is a CID font or not.
Nicolas Penabe90aae2017-02-27 10:41:41 -0500718//
Nicolas Penab3161852017-05-02 14:12:50 -0400719// The loaded font can be closed using FPDF_Font_Close.
720//
Nicolas Penabe90aae2017-02-27 10:41:41 -0500721// Returns NULL on failure
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400722FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document,
723 const uint8_t* data,
724 uint32_t size,
725 int font_type,
726 FPDF_BOOL cid);
Nicolas Penabe90aae2017-02-27 10:41:41 -0500727
wileyrya864e9fb2017-05-26 11:38:14 -0500728// Set the fill RGBA of a text object. Range of values: 0 - 255.
729//
730// text_object - handle to the text object.
731// R - the red component for the path fill color.
732// G - the green component for the path fill color.
733// B - the blue component for the path fill color.
734// A - the fill alpha for the path.
735//
736// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400737FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
738FPDFText_SetFillColor(FPDF_PAGEOBJECT text_object,
739 unsigned int R,
740 unsigned int G,
741 unsigned int B,
742 unsigned int A);
wileyrya864e9fb2017-05-26 11:38:14 -0500743
Nicolas Penab3161852017-05-02 14:12:50 -0400744// Close a loaded PDF font.
745//
746// font - Handle to the loaded font.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400747FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font);
Nicolas Penab3161852017-05-02 14:12:50 -0400748
749// Create a new text object using a loaded font.
750//
751// document - handle to the document.
752// font - handle to the font object.
753// font_size - the font size for the new text object.
754//
755// Returns a handle to a new text object, or NULL on failure
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400756FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
Nicolas Penab3161852017-05-02 14:12:50 -0400757FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
758 FPDF_FONT font,
759 float font_size);
760
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700761#ifdef __cplusplus
dsinclair5f597db2016-03-25 09:04:54 -0700762} // extern "C"
763#endif // __cplusplus
Tom Sepez9857e202015-05-13 17:09:26 -0700764
765#endif // PUBLIC_FPDF_EDIT_H_