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.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef PUBLIC_FPDF_EDIT_H_
8#define PUBLIC_FPDF_EDIT_H_
9
10#include <stdint.h>
11
12// NOLINTNEXTLINE(build/include)
13#include "fpdfview.h"
14
15#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)))
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))
22
23// 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
37// The page object constants.
38#define FPDF_PAGEOBJ_UNKNOWN 0
39#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
45// 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
51#define FPDF_FILLMODE_ALTERNATE 1
52#define FPDF_FILLMODE_WINDING 2
53
54#define FPDF_FONT_TYPE1 1
55#define FPDF_FONT_TRUETYPE 2
56
57#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
65#define FPDF_PRINTMODE_EMF 0
66#define FPDF_PRINTMODE_TEXTONLY 1
67#define FPDF_PRINTMODE_POSTSCRIPT2 2
68#define FPDF_PRINTMODE_POSTSCRIPT3 3
69
70typedef 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  // 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;
86} FPDF_IMAGEOBJ_METADATA;
87
88#ifdef __cplusplus
89extern "C" {
90#endif  // __cplusplus
91
92// Create a new PDF document.
93//
94// Returns a handle to a new document, or NULL on failure.
95FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument();
96
97// Create a new PDF page.
98//
99//   document   - handle to document.
100//   page_index - suggested index of the page to create. If it is larger than
101//                document's current last index(L), the created page index is
102//                the next available index -- L+1.
103//   width      - the page width.
104//   height     - the page height.
105//
106// Returns the handle to the new page.
107//
108// The page should be closed with CPDF_ClosePage() when finished as
109// with any other page in the document.
110FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
111                                                 int page_index,
112                                                 double width,
113                                                 double height);
114
115// Delete the page at |page_index|.
116//
117//   document   - handle to document.
118//   page_index - the index of the page to delete.
119FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document,
120                                               int page_index);
121
122// 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.
131FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetRotation(FPDF_PAGE page);
132
133// Set rotation for |page|.
134//
135//   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.
141FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
142
143// 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.
148FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page,
149                                                     FPDF_PAGEOBJECT page_obj);
150
151// Get number of page objects inside |page|.
152//
153//   page - handle to a page.
154//
155// Returns the number of objects in |page|.
156//
157// DEPRECATED. Please use FPDFPage_CountObjects.
158FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObject(FPDF_PAGE page);
159
160// Get number of page objects inside |page|.
161//
162//   page - handle to a page.
163//
164// Returns the number of objects in |page|.
165FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page);
166
167// Get object in |page| at |index|.
168//
169//   page  - handle to a page.
170//   index - the index of a page object.
171//
172// Returns the handle to the page object, or NULL on failed.
173FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page,
174                                                             int index);
175
176// Checks if |page| contains transparency.
177//
178//   page - handle to a page.
179//
180// Returns TRUE if |page| contains transparency.
181FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page);
182
183// Generate the content of |page|.
184//
185//   page - handle to a page.
186//
187// Returns TRUE on success.
188//
189// Before you save the page to a file, or reload the page, you must call
190// |FPDFPage_GenerateContent| or any changes to |page| will be lost.
191FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page);
192
193// Destroy |page_obj| by releasing its resources. |page_obj| must have been
194// created by FPDFPageObj_CreateNew{Path|Rect}() or
195// FPDFPageObj_New{Text|Image}Obj(). This function must be called on
196// newly-created objects if they are not added to a page through
197// FPDFPage_InsertObject() or to an annotation through FPDFAnnot_AppendObject().
198//
199//   page_obj - handle to a page object.
200FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj);
201
202// Checks if |page_object| contains transparency.
203//
204//   page_object - handle to a page object.
205//
206// Returns TRUE if |pageObject| contains transparency.
207FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
208FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT page_object);
209
210// Get type of |page_object|.
211//
212//   page_object - handle to a page object.
213//
214// Returns one of the FPDF_PAGEOBJ_* values on success, FPDF_PAGEOBJ_UNKNOWN on
215// error.
216FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object);
217
218// Transform |page_object| by the given matrix.
219//
220//   page_object - handle to a page object.
221//   a           - matrix value.
222//   b           - matrix value.
223//   c           - matrix value.
224//   d           - matrix value.
225//   e           - matrix value.
226//   f           - matrix value.
227//
228// The matrix is composed as:
229//   |a c e|
230//   |b d f|
231// and can be used to scale, rotate, shear and translate the |page_object|.
232FPDF_EXPORT void FPDF_CALLCONV
233FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
234                      double a,
235                      double b,
236                      double c,
237                      double d,
238                      double e,
239                      double f);
240
241// Transform all annotations in |page|.
242//
243//   page - handle to a page.
244//   a    - matrix value.
245//   b    - matrix value.
246//   c    - matrix value.
247//   d    - matrix value.
248//   e    - matrix value.
249//   f    - matrix value.
250//
251// The matrix is composed as:
252//   |a c e|
253//   |b d f|
254// and can be used to scale, rotate, shear and translate the |page| annotations.
255FPDF_EXPORT void FPDF_CALLCONV FPDFPage_TransformAnnots(FPDF_PAGE page,
256                                                        double a,
257                                                        double b,
258                                                        double c,
259                                                        double d,
260                                                        double e,
261                                                        double f);
262
263// Create a new image object.
264//
265//   document - handle to a document.
266//
267// Returns a handle to a new image object.
268FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
269FPDFPageObj_NewImageObj(FPDF_DOCUMENT document);
270
271// Load an image from a JPEG image file and then set it into |image_object|.
272//
273//   pages        - pointer to the start of all loaded pages, may be NULL.
274//   nCount       - number of |pages|, may be 0.
275//   image_object - handle to an image object.
276//   fileAccess   - file access handler which specifies the JPEG image file.
277//
278// Returns TRUE on success.
279//
280// The image object might already have an associated image, which is shared and
281// cached by the loaded pages. In that case, we need to clear the cached image
282// for all the loaded pages. Pass |pages| and page count (|nCount|) to this API
283// to clear the image cache. If the image is not previously shared, or NULL is a
284// valid |pages| value.
285FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
286FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
287                          int nCount,
288                          FPDF_PAGEOBJECT image_object,
289                          FPDF_FILEACCESS* fileAccess);
290
291// Load an image from a JPEG image file and then set it into |image_object|.
292//
293//   pages        - pointer to the start of all loaded pages, may be NULL.
294//   nCount       - number of |pages|, may be 0.
295//   image_object - handle to an image object.
296//   fileAccess   - file access handler which specifies the JPEG image file.
297//
298// Returns TRUE on success.
299//
300// The image object might already have an associated image, which is shared and
301// cached by the loaded pages. In that case, we need to clear the cached image
302// for all the loaded pages. Pass |pages| and page count (|nCount|) to this API
303// to clear the image cache. If the image is not previously shared, or NULL is a
304// valid |pages| value. This function loads the JPEG image inline, so the image
305// content is copied to the file. This allows |fileAccess| and its associated
306// data to be deleted after this function returns.
307FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
308FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages,
309                                int nCount,
310                                FPDF_PAGEOBJECT image_object,
311                                FPDF_FILEACCESS* fileAccess);
312
313// Set the transform matrix of |image_object|.
314//
315//   image_object - handle to an image object.
316//   a            - matrix value.
317//   b            - matrix value.
318//   c            - matrix value.
319//   d            - matrix value.
320//   e            - matrix value.
321//   f            - matrix value.
322//
323// The matrix is composed as:
324//   |a c e|
325//   |b d f|
326// and can be used to scale, rotate, shear and translate the |page| annotations.
327//
328// Returns TRUE on success.
329FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
330FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
331                       double a,
332                       double b,
333                       double c,
334                       double d,
335                       double e,
336                       double f);
337
338// Set |bitmap| to |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//   bitmap       - handle of the bitmap.
344//
345// Returns TRUE on success.
346FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
347FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
348                       int nCount,
349                       FPDF_PAGEOBJECT image_object,
350                       FPDF_BITMAP bitmap);
351
352// Get a bitmap rasterisation of |image_object|. The returned bitmap will be
353// owned by the caller, and FPDFBitmap_Destroy() must be called on the returned
354// bitmap when it is no longer needed.
355//
356//   image_object - handle to an image object.
357//
358// Returns the bitmap.
359FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
360FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object);
361
362// Get the decoded image data of |image_object|. The decoded data is the
363// uncompressed image data, i.e. the raw image data after having all filters
364// applied. |buffer| is only modified if |buflen| is longer than the length of
365// the decoded image data.
366//
367//   image_object - handle to an image object.
368//   buffer       - buffer for holding the decoded image data in raw bytes.
369//   buflen       - length of the buffer.
370//
371// Returns the length of the decoded image data.
372FPDF_EXPORT unsigned long FPDF_CALLCONV
373FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
374                                 void* buffer,
375                                 unsigned long buflen);
376
377// Get the raw image data of |image_object|. The raw data is the image data as
378// stored in the PDF without applying any filters. |buffer| is only modified if
379// |buflen| is longer than the length of the raw image data.
380//
381//   image_object - handle to an image object.
382//   buffer       - buffer for holding the raw image data in raw bytes.
383//   buflen       - length of the buffer.
384//
385// Returns the length of the raw image data.
386FPDF_EXPORT unsigned long FPDF_CALLCONV
387FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object,
388                             void* buffer,
389                             unsigned long buflen);
390
391// Get the number of filters (i.e. decoders) of the image in |image_object|.
392//
393//   image_object - handle to an image object.
394//
395// Returns the number of |image_object|'s filters.
396FPDF_EXPORT int FPDF_CALLCONV
397FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object);
398
399// Get the filter at |index| of |image_object|'s list of filters. Note that the
400// filters need to be applied in order, i.e. the first filter should be applied
401// first, then the second, etc. |buffer| is only modified if |buflen| is longer
402// than the length of the filter string.
403//
404//   image_object - handle to an image object.
405//   index        - the index of the filter requested.
406//   buffer       - buffer for holding filter string, encoded in UTF-8.
407//   buflen       - length of the buffer.
408//
409// Returns the length of the filter string.
410FPDF_EXPORT unsigned long FPDF_CALLCONV
411FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object,
412                            int index,
413                            void* buffer,
414                            unsigned long buflen);
415
416// Get the image metadata of |image_object|, including dimension, DPI, bits per
417// pixel, and colorspace. If the |image_object| is not an image object or if it
418// does not have an image, then the return value will be false. Otherwise,
419// failure to retrieve any specific parameter would result in its value being 0.
420//
421//   image_object - handle to an image object.
422//   page         - handle to the page that |image_object| is on. Required for
423//                  retrieving the image's bits per pixel and colorspace.
424//   metadata     - receives the image metadata; must not be NULL.
425//
426// Returns true if successful.
427FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
428FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object,
429                              FPDF_PAGE page,
430                              FPDF_IMAGEOBJ_METADATA* metadata);
431
432// Create a new path object at an initial position.
433//
434//   x - initial horizontal position.
435//   y - initial vertical position.
436//
437// Returns a handle to a new path object.
438FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x,
439                                                                    float y);
440
441// Create a closed path consisting of a rectangle.
442//
443//   x - horizontal position for the left boundary of the rectangle.
444//   y - vertical position for the bottom boundary of the rectangle.
445//   w - width of the rectangle.
446//   h - height of the rectangle.
447//
448// Returns a handle to the new path object.
449FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x,
450                                                                    float y,
451                                                                    float w,
452                                                                    float h);
453
454// Get the bounding box of |page_object|.
455//
456// page_object  - handle to a page object.
457// left         - pointer where the left coordinate will be stored
458// bottom       - pointer where the bottom coordinate will be stored
459// right        - pointer where the right coordinate will be stored
460// top          - pointer where the top coordinate will be stored
461//
462// Returns TRUE on success.
463FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
464FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object,
465                      float* left,
466                      float* bottom,
467                      float* right,
468                      float* top);
469
470// Set the blend mode of |page_object|.
471//
472// page_object  - handle to a page object.
473// blend_mode   - string containing the blend mode.
474//
475// Blend mode can be one of following: Color, ColorBurn, ColorDodge, Darken,
476// Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply, Normal,
477// Overlay, Saturation, Screen, SoftLight
478FPDF_EXPORT void FPDF_CALLCONV
479FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object,
480                         FPDF_BYTESTRING blend_mode);
481
482// Set the stroke RGBA of a path. Range of values: 0 - 255.
483//
484// path   - the handle to the path object.
485// R      - the red component for the path stroke color.
486// G      - the green component for the path stroke color.
487// B      - the blue component for the path stroke color.
488// A      - the stroke alpha for the path.
489//
490// Returns TRUE on success.
491FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
492FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path,
493                        unsigned int R,
494                        unsigned int G,
495                        unsigned int B,
496                        unsigned int A);
497
498// Get the stroke RGBA of a path. Range of values: 0 - 255.
499//
500// path   - the handle to the path object.
501// R      - the red component of the path stroke color.
502// G      - the green component of the path stroke color.
503// B      - the blue component of the path stroke color.
504// A      - the stroke alpha of the path.
505//
506// Returns TRUE on success.
507FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
508FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path,
509                        unsigned int* R,
510                        unsigned int* G,
511                        unsigned int* B,
512                        unsigned int* A);
513
514// Set the stroke width of a path.
515//
516// path   - the handle to the path object.
517// width  - the width of the stroke.
518//
519// Returns TRUE on success
520FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
521FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width);
522
523// Set the line join of |page_object|.
524//
525// page_object  - handle to a page object.
526// line_join    - line join
527//
528// Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND,
529// FPDF_LINEJOIN_BEVEL
530FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT page_object,
531                                                    int line_join);
532
533// Set the line cap of |page_object|.
534//
535// page_object - handle to a page object.
536// line_cap    - line cap
537//
538// Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND,
539// FPDF_LINECAP_PROJECTING_SQUARE
540FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT page_object,
541                                                   int line_cap);
542
543// Set the fill RGBA of a path. Range of values: 0 - 255.
544//
545// path   - the handle to the path object.
546// R      - the red component for the path fill color.
547// G      - the green component for the path fill color.
548// B      - the blue component for the path fill color.
549// A      - the fill alpha for the path.
550//
551// Returns TRUE on success.
552FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
553                                                          unsigned int R,
554                                                          unsigned int G,
555                                                          unsigned int B,
556                                                          unsigned int A);
557
558// Get the fill RGBA of a path. Range of values: 0 - 255.
559//
560// path   - the handle to the path object.
561// R      - the red component of the path fill color.
562// G      - the green component of the path fill color.
563// B      - the blue component of the path fill color.
564// A      - the fill alpha of the path.
565//
566// Returns TRUE on success.
567FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetFillColor(FPDF_PAGEOBJECT path,
568                                                          unsigned int* R,
569                                                          unsigned int* G,
570                                                          unsigned int* B,
571                                                          unsigned int* A);
572
573// Experimental API.
574// Get number of segments inside |path|.
575//
576//   path - handle to a path.
577//
578// A segment is a command, created by e.g. FPDFPath_MoveTo(),
579// FPDFPath_LineTo() or FPDFPath_BezierTo().
580//
581// Returns the number of objects in |path| or -1 on failure.
582FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path);
583
584// Experimental API.
585// Get segment in |path| at |index|.
586//
587//   path  - handle to a path.
588//   index - the index of a segment.
589//
590// Returns the handle to the segment, or NULL on faiure.
591FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
592FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index);
593
594// Experimental API.
595// Get coordinates of |segment|.
596//
597//   segment  - handle to a segment.
598//   x      - the horizontal position of the segment.
599//   y      - the vertical position of the segment.
600//
601// Returns TRUE on success, otherwise |x| and |y| is not set.
602FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
603FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y);
604
605// Experimental API.
606// Get type of |segment|.
607//
608//   segment - handle to a segment.
609//
610// Returns one of the FPDF_SEGMENT_* values on success,
611// FPDF_SEGMENT_UNKNOWN on error.
612FPDF_EXPORT int FPDF_CALLCONV FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment);
613
614// Experimental API.
615// Gets if the |segment| closes the current subpath of a given path.
616//
617//   segment - handle to a segment.
618//
619// Returns close flag for non-NULL segment, FALSE otherwise.
620FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
621FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment);
622
623// Move a path's current point.
624//
625// path   - the handle to the path object.
626// x      - the horizontal position of the new current point.
627// y      - the vertical position of the new current point.
628//
629// Note that no line will be created between the previous current point and the
630// new one.
631//
632// Returns TRUE on success
633FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path,
634                                                    float x,
635                                                    float y);
636
637// Add a line between the current point and a new point in the path.
638//
639// path   - the handle to the path object.
640// x      - the horizontal position of the new point.
641// y      - the vertical position of the new point.
642//
643// The path's current point is changed to (x, y).
644//
645// Returns TRUE on success
646FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path,
647                                                    float x,
648                                                    float y);
649
650// Add a cubic Bezier curve to the given path, starting at the current point.
651//
652// path   - the handle to the path object.
653// x1     - the horizontal position of the first Bezier control point.
654// y1     - the vertical position of the first Bezier control point.
655// x2     - the horizontal position of the second Bezier control point.
656// y2     - the vertical position of the second Bezier control point.
657// x3     - the horizontal position of the ending point of the Bezier curve.
658// y3     - the vertical position of the ending point of the Bezier curve.
659//
660// Returns TRUE on success
661FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path,
662                                                      float x1,
663                                                      float y1,
664                                                      float x2,
665                                                      float y2,
666                                                      float x3,
667                                                      float y3);
668
669// Close the current subpath of a given path.
670//
671// path   - the handle to the path object.
672//
673// This will add a line between the current point and the initial point of the
674// subpath, thus terminating the current subpath.
675//
676// Returns TRUE on success
677FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path);
678
679// Set the drawing mode of a path.
680//
681// path     - the handle to the path object.
682// fillmode - the filling mode to be set: 0 for no fill, 1 for alternate, 2 for
683// winding.
684// stroke   - a boolean specifying if the path should be stroked or not.
685//
686// Returns TRUE on success
687FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
688                                                         int fillmode,
689                                                         FPDF_BOOL stroke);
690
691// Create a new text object using one of the standard PDF fonts.
692//
693// document   - handle to the document.
694// font       - string containing the font name, without spaces.
695// font_size  - the font size for the new text object.
696//
697// Returns a handle to a new text object, or NULL on failure
698FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
699FPDFPageObj_NewTextObj(FPDF_DOCUMENT document,
700                       FPDF_BYTESTRING font,
701                       float font_size);
702
703// Set the text for a textobject. If it had text, it will be replaced.
704//
705// text_object  - handle to the text object.
706// text         - the UTF-16LE encoded string containing the text to be added.
707//
708// Returns TRUE on success
709FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
710FPDFText_SetText(FPDF_PAGEOBJECT text_object, FPDF_WIDESTRING text);
711
712// Returns a font object loaded from a stream of data. The font is loaded
713// into the document.
714//
715// document   - handle to the document.
716// data       - the stream of data, which will be copied by the font object.
717// size       - size of the stream, in bytes.
718// font_type  - FPDF_FONT_TYPE1 or FPDF_FONT_TRUETYPE depending on the font
719// type.
720// cid        - a boolean specifying if the font is a CID font or not.
721//
722// The loaded font can be closed using FPDF_Font_Close.
723//
724// Returns NULL on failure
725FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document,
726                                                      const uint8_t* data,
727                                                      uint32_t size,
728                                                      int font_type,
729                                                      FPDF_BOOL cid);
730
731// Set the fill RGBA of a text object. Range of values: 0 - 255.
732//
733// text_object  - handle to the text object.
734// R            - the red component for the path fill color.
735// G            - the green component for the path fill color.
736// B            - the blue component for the path fill color.
737// A            - the fill alpha for the path.
738//
739// Returns TRUE on success.
740FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
741FPDFText_SetFillColor(FPDF_PAGEOBJECT text_object,
742                      unsigned int R,
743                      unsigned int G,
744                      unsigned int B,
745                      unsigned int A);
746
747// Close a loaded PDF font.
748//
749// font   - Handle to the loaded font.
750FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font);
751
752// Create a new text object using a loaded font.
753//
754// document   - handle to the document.
755// font       - handle to the font object.
756// font_size  - the font size for the new text object.
757//
758// Returns a handle to a new text object, or NULL on failure
759FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
760FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
761                          FPDF_FONT font,
762                          float font_size);
763
764#ifdef __cplusplus
765}  // extern "C"
766#endif  // __cplusplus
767
768#endif  // PUBLIC_FPDF_EDIT_H_
769