xref: /aosp_15_r20/external/pdfium/public/fpdf_edit.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2014 The PDFium Authors
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_NONE 0
52 #define FPDF_FILLMODE_ALTERNATE 1
53 #define FPDF_FILLMODE_WINDING 2
54 
55 #define FPDF_FONT_TYPE1 1
56 #define FPDF_FONT_TRUETYPE 2
57 
58 #define FPDF_LINECAP_BUTT 0
59 #define FPDF_LINECAP_ROUND 1
60 #define FPDF_LINECAP_PROJECTING_SQUARE 2
61 
62 #define FPDF_LINEJOIN_MITER 0
63 #define FPDF_LINEJOIN_ROUND 1
64 #define FPDF_LINEJOIN_BEVEL 2
65 
66 // See FPDF_SetPrintMode() for descriptions.
67 #define FPDF_PRINTMODE_EMF 0
68 #define FPDF_PRINTMODE_TEXTONLY 1
69 #define FPDF_PRINTMODE_POSTSCRIPT2 2
70 #define FPDF_PRINTMODE_POSTSCRIPT3 3
71 #define FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH 4
72 #define FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH 5
73 #define FPDF_PRINTMODE_EMF_IMAGE_MASKS 6
74 #define FPDF_PRINTMODE_POSTSCRIPT3_TYPE42 7
75 #define FPDF_PRINTMODE_POSTSCRIPT3_TYPE42_PASSTHROUGH 8
76 
77 typedef struct FPDF_IMAGEOBJ_METADATA {
78   // The image width in pixels.
79   unsigned int width;
80   // The image height in pixels.
81   unsigned int height;
82   // The image's horizontal pixel-per-inch.
83   float horizontal_dpi;
84   // The image's vertical pixel-per-inch.
85   float vertical_dpi;
86   // The number of bits used to represent each pixel.
87   unsigned int bits_per_pixel;
88   // The image's colorspace. See above for the list of FPDF_COLORSPACE_*.
89   int colorspace;
90   // The image's marked content ID. Useful for pairing with associated alt-text.
91   // A value of -1 indicates no ID.
92   int marked_content_id;
93 } FPDF_IMAGEOBJ_METADATA;
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif  // __cplusplus
98 
99 // Create a new PDF document.
100 //
101 // Returns a handle to a new document, or NULL on failure.
102 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument();
103 
104 // Create a new PDF page.
105 //
106 //   document   - handle to document.
107 //   page_index - suggested 0-based index of the page to create. If it is larger
108 //                than document's current last index(L), the created page index
109 //                is the next available index -- L+1.
110 //   width      - the page width in points.
111 //   height     - the page height in points.
112 //
113 // Returns the handle to the new page or NULL on failure.
114 //
115 // The page should be closed with FPDF_ClosePage() when finished as
116 // with any other page in the document.
117 FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
118                                                  int page_index,
119                                                  double width,
120                                                  double height);
121 
122 // Delete the page at |page_index|.
123 //
124 //   document   - handle to document.
125 //   page_index - the index of the page to delete.
126 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document,
127                                                int page_index);
128 
129 // Get the rotation of |page|.
130 //
131 //   page - handle to a page
132 //
133 // Returns one of the following indicating the page rotation:
134 //   0 - No rotation.
135 //   1 - Rotated 90 degrees clockwise.
136 //   2 - Rotated 180 degrees clockwise.
137 //   3 - Rotated 270 degrees clockwise.
138 FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetRotation(FPDF_PAGE page);
139 
140 // Set rotation for |page|.
141 //
142 //   page   - handle to a page.
143 //   rotate - the rotation value, one of:
144 //              0 - No rotation.
145 //              1 - Rotated 90 degrees clockwise.
146 //              2 - Rotated 180 degrees clockwise.
147 //              3 - Rotated 270 degrees clockwise.
148 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
149 
150 // Insert |page_obj| into |page|.
151 //
152 //   page     - handle to a page
153 //   page_obj - handle to a page object. The |page_obj| will be automatically
154 //              freed.
155 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page,
156                                                      FPDF_PAGEOBJECT page_obj);
157 
158 // Experimental API.
159 // Remove |page_obj| from |page|.
160 //
161 //   page     - handle to a page
162 //   page_obj - handle to a page object to be removed.
163 //
164 // Returns TRUE on success.
165 //
166 // Ownership is transferred to the caller. Call FPDFPageObj_Destroy() to free
167 // it.
168 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
169 FPDFPage_RemoveObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj);
170 
171 // Get number of page objects inside |page|.
172 //
173 //   page - handle to a page.
174 //
175 // Returns the number of objects in |page|.
176 FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page);
177 
178 // Get object in |page| at |index|.
179 //
180 //   page  - handle to a page.
181 //   index - the index of a page object.
182 //
183 // Returns the handle to the page object, or NULL on failed.
184 FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page,
185                                                              int index);
186 
187 // Checks if |page| contains transparency.
188 //
189 //   page - handle to a page.
190 //
191 // Returns TRUE if |page| contains transparency.
192 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page);
193 
194 // Generate the content of |page|.
195 //
196 //   page - handle to a page.
197 //
198 // Returns TRUE on success.
199 //
200 // Before you save the page to a file, or reload the page, you must call
201 // |FPDFPage_GenerateContent| or any changes to |page| will be lost.
202 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page);
203 
204 // Destroy |page_obj| by releasing its resources. |page_obj| must have been
205 // created by FPDFPageObj_CreateNew{Path|Rect}() or
206 // FPDFPageObj_New{Text|Image}Obj(). This function must be called on
207 // newly-created objects if they are not added to a page through
208 // FPDFPage_InsertObject() or to an annotation through FPDFAnnot_AppendObject().
209 //
210 //   page_obj - handle to a page object.
211 FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj);
212 
213 // Checks if |page_object| contains transparency.
214 //
215 //   page_object - handle to a page object.
216 //
217 // Returns TRUE if |page_object| contains transparency.
218 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
219 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT page_object);
220 
221 // Get type of |page_object|.
222 //
223 //   page_object - handle to a page object.
224 //
225 // Returns one of the FPDF_PAGEOBJ_* values on success, FPDF_PAGEOBJ_UNKNOWN on
226 // error.
227 FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object);
228 
229 // Transform |page_object| by the given matrix.
230 //
231 //   page_object - handle to a page object.
232 //   a           - matrix value.
233 //   b           - matrix value.
234 //   c           - matrix value.
235 //   d           - matrix value.
236 //   e           - matrix value.
237 //   f           - matrix value.
238 //
239 // The matrix is composed as:
240 //   |a c e|
241 //   |b d f|
242 // and can be used to scale, rotate, shear and translate the |page_object|.
243 FPDF_EXPORT void FPDF_CALLCONV
244 FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
245                       double a,
246                       double b,
247                       double c,
248                       double d,
249                       double e,
250                       double f);
251 
252 // Experimental API.
253 // Get the transform matrix of a page object.
254 //
255 //   page_object - handle to a page object.
256 //   matrix      - pointer to struct to receive the matrix value.
257 //
258 // The matrix is composed as:
259 //   |a c e|
260 //   |b d f|
261 // and used to scale, rotate, shear and translate the page object.
262 //
263 // Returns TRUE on success.
264 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
265 FPDFPageObj_GetMatrix(FPDF_PAGEOBJECT page_object, FS_MATRIX* matrix);
266 
267 // Experimental API.
268 // Set the transform matrix of a page object.
269 //
270 //   page_object - handle to a page object.
271 //   matrix      - pointer to struct with the matrix value.
272 //
273 // The matrix is composed as:
274 //   |a c e|
275 //   |b d f|
276 // and can be used to scale, rotate, shear and translate the page object.
277 //
278 // Returns TRUE on success.
279 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
280 FPDFPageObj_SetMatrix(FPDF_PAGEOBJECT path, const FS_MATRIX* matrix);
281 
282 // Transform all annotations in |page|.
283 //
284 //   page - handle to a page.
285 //   a    - matrix value.
286 //   b    - matrix value.
287 //   c    - matrix value.
288 //   d    - matrix value.
289 //   e    - matrix value.
290 //   f    - matrix value.
291 //
292 // The matrix is composed as:
293 //   |a c e|
294 //   |b d f|
295 // and can be used to scale, rotate, shear and translate the |page| annotations.
296 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_TransformAnnots(FPDF_PAGE page,
297                                                         double a,
298                                                         double b,
299                                                         double c,
300                                                         double d,
301                                                         double e,
302                                                         double f);
303 
304 // Create a new image object.
305 //
306 //   document - handle to a document.
307 //
308 // Returns a handle to a new image object.
309 FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
310 FPDFPageObj_NewImageObj(FPDF_DOCUMENT document);
311 
312 // Experimental API.
313 // Get number of content marks in |page_object|.
314 //
315 //   page_object - handle to a page object.
316 //
317 // Returns the number of content marks in |page_object|, or -1 in case of
318 // failure.
319 FPDF_EXPORT int FPDF_CALLCONV
320 FPDFPageObj_CountMarks(FPDF_PAGEOBJECT page_object);
321 
322 // Experimental API.
323 // Get content mark in |page_object| at |index|.
324 //
325 //   page_object - handle to a page object.
326 //   index       - the index of a page object.
327 //
328 // Returns the handle to the content mark, or NULL on failure. The handle is
329 // still owned by the library, and it should not be freed directly. It becomes
330 // invalid if the page object is destroyed, either directly or indirectly by
331 // unloading the page.
332 FPDF_EXPORT FPDF_PAGEOBJECTMARK FPDF_CALLCONV
333 FPDFPageObj_GetMark(FPDF_PAGEOBJECT page_object, unsigned long index);
334 
335 // Experimental API.
336 // Add a new content mark to a |page_object|.
337 //
338 //   page_object - handle to a page object.
339 //   name        - the name (tag) of the mark.
340 //
341 // Returns the handle to the content mark, or NULL on failure. The handle is
342 // still owned by the library, and it should not be freed directly. It becomes
343 // invalid if the page object is destroyed, either directly or indirectly by
344 // unloading the page.
345 FPDF_EXPORT FPDF_PAGEOBJECTMARK FPDF_CALLCONV
346 FPDFPageObj_AddMark(FPDF_PAGEOBJECT page_object, FPDF_BYTESTRING name);
347 
348 // Experimental API.
349 // Removes a content |mark| from a |page_object|.
350 // The mark handle will be invalid after the removal.
351 //
352 //   page_object - handle to a page object.
353 //   mark        - handle to a content mark in that object to remove.
354 //
355 // Returns TRUE if the operation succeeded, FALSE if it failed.
356 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
357 FPDFPageObj_RemoveMark(FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark);
358 
359 // Experimental API.
360 // Get the name of a content mark.
361 //
362 //   mark       - handle to a content mark.
363 //   buffer     - buffer for holding the returned name in UTF-16LE. This is only
364 //                modified if |buflen| is longer than the length of the name.
365 //                Optional, pass null to just retrieve the size of the buffer
366 //                needed.
367 //   buflen     - length of the buffer.
368 //   out_buflen - pointer to variable that will receive the minimum buffer size
369 //                to contain the name. Not filled if FALSE is returned.
370 //
371 // Returns TRUE if the operation succeeded, FALSE if it failed.
372 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
373 FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark,
374                         void* buffer,
375                         unsigned long buflen,
376                         unsigned long* out_buflen);
377 
378 // Experimental API.
379 // Get the number of key/value pair parameters in |mark|.
380 //
381 //   mark   - handle to a content mark.
382 //
383 // Returns the number of key/value pair parameters |mark|, or -1 in case of
384 // failure.
385 FPDF_EXPORT int FPDF_CALLCONV
386 FPDFPageObjMark_CountParams(FPDF_PAGEOBJECTMARK mark);
387 
388 // Experimental API.
389 // Get the key of a property in a content mark.
390 //
391 //   mark       - handle to a content mark.
392 //   index      - index of the property.
393 //   buffer     - buffer for holding the returned key in UTF-16LE. This is only
394 //                modified if |buflen| is longer than the length of the key.
395 //                Optional, pass null to just retrieve the size of the buffer
396 //                needed.
397 //   buflen     - length of the buffer.
398 //   out_buflen - pointer to variable that will receive the minimum buffer size
399 //                to contain the key. Not filled if FALSE is returned.
400 //
401 // Returns TRUE if the operation was successful, FALSE otherwise.
402 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
403 FPDFPageObjMark_GetParamKey(FPDF_PAGEOBJECTMARK mark,
404                             unsigned long index,
405                             void* buffer,
406                             unsigned long buflen,
407                             unsigned long* out_buflen);
408 
409 // Experimental API.
410 // Get the type of the value of a property in a content mark by key.
411 //
412 //   mark   - handle to a content mark.
413 //   key    - string key of the property.
414 //
415 // Returns the type of the value, or FPDF_OBJECT_UNKNOWN in case of failure.
416 FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
417 FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark,
418                                   FPDF_BYTESTRING key);
419 
420 // Experimental API.
421 // Get the value of a number property in a content mark by key as int.
422 // FPDFPageObjMark_GetParamValueType() should have returned FPDF_OBJECT_NUMBER
423 // for this property.
424 //
425 //   mark      - handle to a content mark.
426 //   key       - string key of the property.
427 //   out_value - pointer to variable that will receive the value. Not filled if
428 //               false is returned.
429 //
430 // Returns TRUE if the key maps to a number value, FALSE otherwise.
431 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
432 FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark,
433                                  FPDF_BYTESTRING key,
434                                  int* out_value);
435 
436 // Experimental API.
437 // Get the value of a string property in a content mark by key.
438 //
439 //   mark       - handle to a content mark.
440 //   key        - string key of the property.
441 //   buffer     - buffer for holding the returned value in UTF-16LE. This is
442 //                only modified if |buflen| is longer than the length of the
443 //                value.
444 //                Optional, pass null to just retrieve the size of the buffer
445 //                needed.
446 //   buflen     - length of the buffer.
447 //   out_buflen - pointer to variable that will receive the minimum buffer size
448 //                to contain the value. Not filled if FALSE is returned.
449 //
450 // Returns TRUE if the key maps to a string/blob value, FALSE otherwise.
451 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
452 FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark,
453                                     FPDF_BYTESTRING key,
454                                     void* buffer,
455                                     unsigned long buflen,
456                                     unsigned long* out_buflen);
457 
458 // Experimental API.
459 // Get the value of a blob property in a content mark by key.
460 //
461 //   mark       - handle to a content mark.
462 //   key        - string key of the property.
463 //   buffer     - buffer for holding the returned value. This is only modified
464 //                if |buflen| is at least as long as the length of the value.
465 //                Optional, pass null to just retrieve the size of the buffer
466 //                needed.
467 //   buflen     - length of the buffer.
468 //   out_buflen - pointer to variable that will receive the minimum buffer size
469 //                to contain the value. Not filled if FALSE is returned.
470 //
471 // Returns TRUE if the key maps to a string/blob value, FALSE otherwise.
472 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
473 FPDFPageObjMark_GetParamBlobValue(FPDF_PAGEOBJECTMARK mark,
474                                   FPDF_BYTESTRING key,
475                                   void* buffer,
476                                   unsigned long buflen,
477                                   unsigned long* out_buflen);
478 
479 // Experimental API.
480 // Set the value of an int property in a content mark by key. If a parameter
481 // with key |key| exists, its value is set to |value|. Otherwise, it is added as
482 // a new parameter.
483 //
484 //   document    - handle to the document.
485 //   page_object - handle to the page object with the mark.
486 //   mark        - handle to a content mark.
487 //   key         - string key of the property.
488 //   value       - int value to set.
489 //
490 // Returns TRUE if the operation succeeded, FALSE otherwise.
491 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
492 FPDFPageObjMark_SetIntParam(FPDF_DOCUMENT document,
493                             FPDF_PAGEOBJECT page_object,
494                             FPDF_PAGEOBJECTMARK mark,
495                             FPDF_BYTESTRING key,
496                             int value);
497 
498 // Experimental API.
499 // Set the value of a string property in a content mark by key. If a parameter
500 // with key |key| exists, its value is set to |value|. Otherwise, it is added as
501 // a new parameter.
502 //
503 //   document    - handle to the document.
504 //   page_object - handle to the page object with the mark.
505 //   mark        - handle to a content mark.
506 //   key         - string key of the property.
507 //   value       - string value to set.
508 //
509 // Returns TRUE if the operation succeeded, FALSE otherwise.
510 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
511 FPDFPageObjMark_SetStringParam(FPDF_DOCUMENT document,
512                                FPDF_PAGEOBJECT page_object,
513                                FPDF_PAGEOBJECTMARK mark,
514                                FPDF_BYTESTRING key,
515                                FPDF_BYTESTRING value);
516 
517 // Experimental API.
518 // Set the value of a blob property in a content mark by key. If a parameter
519 // with key |key| exists, its value is set to |value|. Otherwise, it is added as
520 // a new parameter.
521 //
522 //   document    - handle to the document.
523 //   page_object - handle to the page object with the mark.
524 //   mark        - handle to a content mark.
525 //   key         - string key of the property.
526 //   value       - pointer to blob value to set.
527 //   value_len   - size in bytes of |value|.
528 //
529 // Returns TRUE if the operation succeeded, FALSE otherwise.
530 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
531 FPDFPageObjMark_SetBlobParam(FPDF_DOCUMENT document,
532                              FPDF_PAGEOBJECT page_object,
533                              FPDF_PAGEOBJECTMARK mark,
534                              FPDF_BYTESTRING key,
535                              void* value,
536                              unsigned long value_len);
537 
538 // Experimental API.
539 // Removes a property from a content mark by key.
540 //
541 //   page_object - handle to the page object with the mark.
542 //   mark        - handle to a content mark.
543 //   key         - string key of the property.
544 //
545 // Returns TRUE if the operation succeeded, FALSE otherwise.
546 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
547 FPDFPageObjMark_RemoveParam(FPDF_PAGEOBJECT page_object,
548                             FPDF_PAGEOBJECTMARK mark,
549                             FPDF_BYTESTRING key);
550 
551 // Load an image from a JPEG image file and then set it into |image_object|.
552 //
553 //   pages        - pointer to the start of all loaded pages, may be NULL.
554 //   count        - number of |pages|, may be 0.
555 //   image_object - handle to an image object.
556 //   file_access  - file access handler which specifies the JPEG image file.
557 //
558 // Returns TRUE on success.
559 //
560 // The image object might already have an associated image, which is shared and
561 // cached by the loaded pages. In that case, we need to clear the cached image
562 // for all the loaded pages. Pass |pages| and page count (|count|) to this API
563 // to clear the image cache. If the image is not previously shared, or NULL is a
564 // valid |pages| value.
565 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
566 FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
567                           int count,
568                           FPDF_PAGEOBJECT image_object,
569                           FPDF_FILEACCESS* file_access);
570 
571 // Load an image from a JPEG image file and then set it into |image_object|.
572 //
573 //   pages        - pointer to the start of all loaded pages, may be NULL.
574 //   count        - number of |pages|, may be 0.
575 //   image_object - handle to an image object.
576 //   file_access  - file access handler which specifies the JPEG image file.
577 //
578 // Returns TRUE on success.
579 //
580 // The image object might already have an associated image, which is shared and
581 // cached by the loaded pages. In that case, we need to clear the cached image
582 // for all the loaded pages. Pass |pages| and page count (|count|) to this API
583 // to clear the image cache. If the image is not previously shared, or NULL is a
584 // valid |pages| value. This function loads the JPEG image inline, so the image
585 // content is copied to the file. This allows |file_access| and its associated
586 // data to be deleted after this function returns.
587 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
588 FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages,
589                                 int count,
590                                 FPDF_PAGEOBJECT image_object,
591                                 FPDF_FILEACCESS* file_access);
592 
593 // TODO(thestig): Start deprecating this once FPDFPageObj_SetMatrix() is stable.
594 //
595 // Set the transform matrix of |image_object|.
596 //
597 //   image_object - handle to an image object.
598 //   a            - matrix value.
599 //   b            - matrix value.
600 //   c            - matrix value.
601 //   d            - matrix value.
602 //   e            - matrix value.
603 //   f            - matrix value.
604 //
605 // The matrix is composed as:
606 //   |a c e|
607 //   |b d f|
608 // and can be used to scale, rotate, shear and translate the |image_object|.
609 //
610 // Returns TRUE on success.
611 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
612 FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
613                        double a,
614                        double b,
615                        double c,
616                        double d,
617                        double e,
618                        double f);
619 
620 // Set |bitmap| to |image_object|.
621 //
622 //   pages        - pointer to the start of all loaded pages, may be NULL.
623 //   count        - number of |pages|, may be 0.
624 //   image_object - handle to an image object.
625 //   bitmap       - handle of the bitmap.
626 //
627 // Returns TRUE on success.
628 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
629 FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
630                        int count,
631                        FPDF_PAGEOBJECT image_object,
632                        FPDF_BITMAP bitmap);
633 
634 // Get a bitmap rasterization of |image_object|. FPDFImageObj_GetBitmap() only
635 // operates on |image_object| and does not take the associated image mask into
636 // account. It also ignores the matrix for |image_object|.
637 // The returned bitmap will be owned by the caller, and FPDFBitmap_Destroy()
638 // must be called on the returned bitmap when it is no longer needed.
639 //
640 //   image_object - handle to an image object.
641 //
642 // Returns the bitmap.
643 FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
644 FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object);
645 
646 // Experimental API.
647 // Get a bitmap rasterization of |image_object| that takes the image mask and
648 // image matrix into account. To render correctly, the caller must provide the
649 // |document| associated with |image_object|. If there is a |page| associated
650 // with |image_object|, the caller should provide that as well.
651 // The returned bitmap will be owned by the caller, and FPDFBitmap_Destroy()
652 // must be called on the returned bitmap when it is no longer needed.
653 //
654 //   document     - handle to a document associated with |image_object|.
655 //   page         - handle to an optional page associated with |image_object|.
656 //   image_object - handle to an image object.
657 //
658 // Returns the bitmap or NULL on failure.
659 FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
660 FPDFImageObj_GetRenderedBitmap(FPDF_DOCUMENT document,
661                                FPDF_PAGE page,
662                                FPDF_PAGEOBJECT image_object);
663 
664 // Get the decoded image data of |image_object|. The decoded data is the
665 // uncompressed image data, i.e. the raw image data after having all filters
666 // applied. |buffer| is only modified if |buflen| is longer than the length of
667 // the decoded image data.
668 //
669 //   image_object - handle to an image object.
670 //   buffer       - buffer for holding the decoded image data.
671 //   buflen       - length of the buffer in bytes.
672 //
673 // Returns the length of the decoded image data.
674 FPDF_EXPORT unsigned long FPDF_CALLCONV
675 FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
676                                  void* buffer,
677                                  unsigned long buflen);
678 
679 // Get the raw image data of |image_object|. The raw data is the image data as
680 // stored in the PDF without applying any filters. |buffer| is only modified if
681 // |buflen| is longer than the length of the raw image data.
682 //
683 //   image_object - handle to an image object.
684 //   buffer       - buffer for holding the raw image data.
685 //   buflen       - length of the buffer in bytes.
686 //
687 // Returns the length of the raw image data.
688 FPDF_EXPORT unsigned long FPDF_CALLCONV
689 FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object,
690                              void* buffer,
691                              unsigned long buflen);
692 
693 // Get the number of filters (i.e. decoders) of the image in |image_object|.
694 //
695 //   image_object - handle to an image object.
696 //
697 // Returns the number of |image_object|'s filters.
698 FPDF_EXPORT int FPDF_CALLCONV
699 FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object);
700 
701 // Get the filter at |index| of |image_object|'s list of filters. Note that the
702 // filters need to be applied in order, i.e. the first filter should be applied
703 // first, then the second, etc. |buffer| is only modified if |buflen| is longer
704 // than the length of the filter string.
705 //
706 //   image_object - handle to an image object.
707 //   index        - the index of the filter requested.
708 //   buffer       - buffer for holding filter string, encoded in UTF-8.
709 //   buflen       - length of the buffer.
710 //
711 // Returns the length of the filter string.
712 FPDF_EXPORT unsigned long FPDF_CALLCONV
713 FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object,
714                             int index,
715                             void* buffer,
716                             unsigned long buflen);
717 
718 // Get the image metadata of |image_object|, including dimension, DPI, bits per
719 // pixel, and colorspace. If the |image_object| is not an image object or if it
720 // does not have an image, then the return value will be false. Otherwise,
721 // failure to retrieve any specific parameter would result in its value being 0.
722 //
723 //   image_object - handle to an image object.
724 //   page         - handle to the page that |image_object| is on. Required for
725 //                  retrieving the image's bits per pixel and colorspace.
726 //   metadata     - receives the image metadata; must not be NULL.
727 //
728 // Returns true if successful.
729 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
730 FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object,
731                               FPDF_PAGE page,
732                               FPDF_IMAGEOBJ_METADATA* metadata);
733 
734 // Experimental API.
735 // Get the image size in pixels. Faster method to get only image size.
736 //
737 //   image_object - handle to an image object.
738 //   width        - receives the image width in pixels; must not be NULL.
739 //   height       - receives the image height in pixels; must not be NULL.
740 //
741 // Returns true if successful.
742 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
743 FPDFImageObj_GetImagePixelSize(FPDF_PAGEOBJECT image_object,
744                                unsigned int* width,
745                                unsigned int* height);
746 
747 // Create a new path object at an initial position.
748 //
749 //   x - initial horizontal position.
750 //   y - initial vertical position.
751 //
752 // Returns a handle to a new path object.
753 FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x,
754                                                                     float y);
755 
756 // Create a closed path consisting of a rectangle.
757 //
758 //   x - horizontal position for the left boundary of the rectangle.
759 //   y - vertical position for the bottom boundary of the rectangle.
760 //   w - width of the rectangle.
761 //   h - height of the rectangle.
762 //
763 // Returns a handle to the new path object.
764 FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x,
765                                                                     float y,
766                                                                     float w,
767                                                                     float h);
768 
769 // Get the bounding box of |page_object|.
770 //
771 // page_object  - handle to a page object.
772 // left         - pointer where the left coordinate will be stored
773 // bottom       - pointer where the bottom coordinate will be stored
774 // right        - pointer where the right coordinate will be stored
775 // top          - pointer where the top coordinate will be stored
776 //
777 // On success, returns TRUE and fills in the 4 coordinates.
778 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
779 FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object,
780                       float* left,
781                       float* bottom,
782                       float* right,
783                       float* top);
784 
785 // Experimental API.
786 // Get the quad points that bounds |page_object|.
787 //
788 // page_object  - handle to a page object.
789 // quad_points  - pointer where the quadrilateral points will be stored.
790 //
791 // On success, returns TRUE and fills in |quad_points|.
792 //
793 // Similar to FPDFPageObj_GetBounds(), this returns the bounds of a page
794 // object. When the object is rotated by a non-multiple of 90 degrees, this API
795 // returns a tighter bound that cannot be represented with just the 4 sides of
796 // a rectangle.
797 //
798 // Currently only works the following |page_object| types: FPDF_PAGEOBJ_TEXT and
799 // FPDF_PAGEOBJ_IMAGE.
800 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
801 FPDFPageObj_GetRotatedBounds(FPDF_PAGEOBJECT page_object,
802                              FS_QUADPOINTSF* quad_points);
803 
804 // Set the blend mode of |page_object|.
805 //
806 // page_object  - handle to a page object.
807 // blend_mode   - string containing the blend mode.
808 //
809 // Blend mode can be one of following: Color, ColorBurn, ColorDodge, Darken,
810 // Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply, Normal,
811 // Overlay, Saturation, Screen, SoftLight
812 FPDF_EXPORT void FPDF_CALLCONV
813 FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object,
814                          FPDF_BYTESTRING blend_mode);
815 
816 // Set the stroke RGBA of a page object. Range of values: 0 - 255.
817 //
818 // page_object  - the handle to the page object.
819 // R            - the red component for the object's stroke color.
820 // G            - the green component for the object's stroke color.
821 // B            - the blue component for the object's stroke color.
822 // A            - the stroke alpha for the object.
823 //
824 // Returns TRUE on success.
825 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
826 FPDFPageObj_SetStrokeColor(FPDF_PAGEOBJECT page_object,
827                            unsigned int R,
828                            unsigned int G,
829                            unsigned int B,
830                            unsigned int A);
831 
832 // Get the stroke RGBA of a page object. Range of values: 0 - 255.
833 //
834 // page_object  - the handle to the page object.
835 // R            - the red component of the path stroke color.
836 // G            - the green component of the object's stroke color.
837 // B            - the blue component of the object's stroke color.
838 // A            - the stroke alpha of the object.
839 //
840 // Returns TRUE on success.
841 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
842 FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object,
843                            unsigned int* R,
844                            unsigned int* G,
845                            unsigned int* B,
846                            unsigned int* A);
847 
848 // Set the stroke width of a page object.
849 //
850 // path   - the handle to the page object.
851 // width  - the width of the stroke.
852 //
853 // Returns TRUE on success
854 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
855 FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width);
856 
857 // Get the stroke width of a page object.
858 //
859 // path   - the handle to the page object.
860 // width  - the width of the stroke.
861 //
862 // Returns TRUE on success
863 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
864 FPDFPageObj_GetStrokeWidth(FPDF_PAGEOBJECT page_object, float* width);
865 
866 // Get the line join of |page_object|.
867 //
868 // page_object  - handle to a page object.
869 //
870 // Returns the line join, or -1 on failure.
871 // Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND,
872 // FPDF_LINEJOIN_BEVEL
873 FPDF_EXPORT int FPDF_CALLCONV
874 FPDFPageObj_GetLineJoin(FPDF_PAGEOBJECT page_object);
875 
876 // Set the line join of |page_object|.
877 //
878 // page_object  - handle to a page object.
879 // line_join    - line join
880 //
881 // Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND,
882 // FPDF_LINEJOIN_BEVEL
883 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
884 FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join);
885 
886 // Get the line cap of |page_object|.
887 //
888 // page_object - handle to a page object.
889 //
890 // Returns the line cap, or -1 on failure.
891 // Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND,
892 // FPDF_LINECAP_PROJECTING_SQUARE
893 FPDF_EXPORT int FPDF_CALLCONV
894 FPDFPageObj_GetLineCap(FPDF_PAGEOBJECT page_object);
895 
896 // Set the line cap of |page_object|.
897 //
898 // page_object - handle to a page object.
899 // line_cap    - line cap
900 //
901 // Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND,
902 // FPDF_LINECAP_PROJECTING_SQUARE
903 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
904 FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap);
905 
906 // Set the fill RGBA of a page object. Range of values: 0 - 255.
907 //
908 // page_object  - the handle to the page object.
909 // R            - the red component for the object's fill color.
910 // G            - the green component for the object's fill color.
911 // B            - the blue component for the object's fill color.
912 // A            - the fill alpha for the object.
913 //
914 // Returns TRUE on success.
915 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
916 FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object,
917                          unsigned int R,
918                          unsigned int G,
919                          unsigned int B,
920                          unsigned int A);
921 
922 // Get the fill RGBA of a page object. Range of values: 0 - 255.
923 //
924 // page_object  - the handle to the page object.
925 // R            - the red component of the object's fill color.
926 // G            - the green component of the object's fill color.
927 // B            - the blue component of the object's fill color.
928 // A            - the fill alpha of the object.
929 //
930 // Returns TRUE on success.
931 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
932 FPDFPageObj_GetFillColor(FPDF_PAGEOBJECT page_object,
933                          unsigned int* R,
934                          unsigned int* G,
935                          unsigned int* B,
936                          unsigned int* A);
937 
938 // Experimental API.
939 // Get the line dash |phase| of |page_object|.
940 //
941 // page_object - handle to a page object.
942 // phase - pointer where the dashing phase will be stored.
943 //
944 // Returns TRUE on success.
945 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
946 FPDFPageObj_GetDashPhase(FPDF_PAGEOBJECT page_object, float* phase);
947 
948 // Experimental API.
949 // Set the line dash phase of |page_object|.
950 //
951 // page_object - handle to a page object.
952 // phase - line dash phase.
953 //
954 // Returns TRUE on success.
955 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
956 FPDFPageObj_SetDashPhase(FPDF_PAGEOBJECT page_object, float phase);
957 
958 // Experimental API.
959 // Get the line dash array of |page_object|.
960 //
961 // page_object - handle to a page object.
962 //
963 // Returns the line dash array size or -1 on failure.
964 FPDF_EXPORT int FPDF_CALLCONV
965 FPDFPageObj_GetDashCount(FPDF_PAGEOBJECT page_object);
966 
967 // Experimental API.
968 // Get the line dash array of |page_object|.
969 //
970 // page_object - handle to a page object.
971 // dash_array - pointer where the dashing array will be stored.
972 // dash_count - number of elements in |dash_array|.
973 //
974 // Returns TRUE on success.
975 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
976 FPDFPageObj_GetDashArray(FPDF_PAGEOBJECT page_object,
977                          float* dash_array,
978                          size_t dash_count);
979 
980 // Experimental API.
981 // Set the line dash array of |page_object|.
982 //
983 // page_object - handle to a page object.
984 // dash_array - the dash array.
985 // dash_count - number of elements in |dash_array|.
986 // phase - the line dash phase.
987 //
988 // Returns TRUE on success.
989 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
990 FPDFPageObj_SetDashArray(FPDF_PAGEOBJECT page_object,
991                          const float* dash_array,
992                          size_t dash_count,
993                          float phase);
994 
995 // Get number of segments inside |path|.
996 //
997 //   path - handle to a path.
998 //
999 // A segment is a command, created by e.g. FPDFPath_MoveTo(),
1000 // FPDFPath_LineTo() or FPDFPath_BezierTo().
1001 //
1002 // Returns the number of objects in |path| or -1 on failure.
1003 FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path);
1004 
1005 // Get segment in |path| at |index|.
1006 //
1007 //   path  - handle to a path.
1008 //   index - the index of a segment.
1009 //
1010 // Returns the handle to the segment, or NULL on faiure.
1011 FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
1012 FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index);
1013 
1014 // Get coordinates of |segment|.
1015 //
1016 //   segment  - handle to a segment.
1017 //   x      - the horizontal position of the segment.
1018 //   y      - the vertical position of the segment.
1019 //
1020 // Returns TRUE on success, otherwise |x| and |y| is not set.
1021 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1022 FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y);
1023 
1024 // Get type of |segment|.
1025 //
1026 //   segment - handle to a segment.
1027 //
1028 // Returns one of the FPDF_SEGMENT_* values on success,
1029 // FPDF_SEGMENT_UNKNOWN on error.
1030 FPDF_EXPORT int FPDF_CALLCONV FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment);
1031 
1032 // Gets if the |segment| closes the current subpath of a given path.
1033 //
1034 //   segment - handle to a segment.
1035 //
1036 // Returns close flag for non-NULL segment, FALSE otherwise.
1037 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1038 FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment);
1039 
1040 // Move a path's current point.
1041 //
1042 // path   - the handle to the path object.
1043 // x      - the horizontal position of the new current point.
1044 // y      - the vertical position of the new current point.
1045 //
1046 // Note that no line will be created between the previous current point and the
1047 // new one.
1048 //
1049 // Returns TRUE on success
1050 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path,
1051                                                     float x,
1052                                                     float y);
1053 
1054 // Add a line between the current point and a new point in the path.
1055 //
1056 // path   - the handle to the path object.
1057 // x      - the horizontal position of the new point.
1058 // y      - the vertical position of the new point.
1059 //
1060 // The path's current point is changed to (x, y).
1061 //
1062 // Returns TRUE on success
1063 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path,
1064                                                     float x,
1065                                                     float y);
1066 
1067 // Add a cubic Bezier curve to the given path, starting at the current point.
1068 //
1069 // path   - the handle to the path object.
1070 // x1     - the horizontal position of the first Bezier control point.
1071 // y1     - the vertical position of the first Bezier control point.
1072 // x2     - the horizontal position of the second Bezier control point.
1073 // y2     - the vertical position of the second Bezier control point.
1074 // x3     - the horizontal position of the ending point of the Bezier curve.
1075 // y3     - the vertical position of the ending point of the Bezier curve.
1076 //
1077 // Returns TRUE on success
1078 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path,
1079                                                       float x1,
1080                                                       float y1,
1081                                                       float x2,
1082                                                       float y2,
1083                                                       float x3,
1084                                                       float y3);
1085 
1086 // Close the current subpath of a given path.
1087 //
1088 // path   - the handle to the path object.
1089 //
1090 // This will add a line between the current point and the initial point of the
1091 // subpath, thus terminating the current subpath.
1092 //
1093 // Returns TRUE on success
1094 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path);
1095 
1096 // Set the drawing mode of a path.
1097 //
1098 // path     - the handle to the path object.
1099 // fillmode - the filling mode to be set: one of the FPDF_FILLMODE_* flags.
1100 // stroke   - a boolean specifying if the path should be stroked or not.
1101 //
1102 // Returns TRUE on success
1103 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
1104                                                          int fillmode,
1105                                                          FPDF_BOOL stroke);
1106 
1107 // Get the drawing mode of a path.
1108 //
1109 // path     - the handle to the path object.
1110 // fillmode - the filling mode of the path: one of the FPDF_FILLMODE_* flags.
1111 // stroke   - a boolean specifying if the path is stroked or not.
1112 //
1113 // Returns TRUE on success
1114 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path,
1115                                                          int* fillmode,
1116                                                          FPDF_BOOL* stroke);
1117 
1118 // Create a new text object using one of the standard PDF fonts.
1119 //
1120 // document   - handle to the document.
1121 // font       - string containing the font name, without spaces.
1122 // font_size  - the font size for the new text object.
1123 //
1124 // Returns a handle to a new text object, or NULL on failure
1125 FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
1126 FPDFPageObj_NewTextObj(FPDF_DOCUMENT document,
1127                        FPDF_BYTESTRING font,
1128                        float font_size);
1129 
1130 // Set the text for a text object. If it had text, it will be replaced.
1131 //
1132 // text_object  - handle to the text object.
1133 // text         - the UTF-16LE encoded string containing the text to be added.
1134 //
1135 // Returns TRUE on success
1136 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1137 FPDFText_SetText(FPDF_PAGEOBJECT text_object, FPDF_WIDESTRING text);
1138 
1139 // Experimental API.
1140 // Set the text using charcodes for a text object. If it had text, it will be
1141 // replaced.
1142 //
1143 // text_object  - handle to the text object.
1144 // charcodes    - pointer to an array of charcodes to be added.
1145 // count        - number of elements in |charcodes|.
1146 //
1147 // Returns TRUE on success
1148 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1149 FPDFText_SetCharcodes(FPDF_PAGEOBJECT text_object,
1150                       const uint32_t* charcodes,
1151                       size_t count);
1152 
1153 // Returns a font object loaded from a stream of data. The font is loaded
1154 // into the document.
1155 //
1156 // document   - handle to the document.
1157 // data       - the stream of data, which will be copied by the font object.
1158 // size       - size of the stream, in bytes.
1159 // font_type  - FPDF_FONT_TYPE1 or FPDF_FONT_TRUETYPE depending on the font
1160 // type.
1161 // cid        - a boolean specifying if the font is a CID font or not.
1162 //
1163 // The loaded font can be closed using FPDFFont_Close.
1164 //
1165 // Returns NULL on failure
1166 FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document,
1167                                                       const uint8_t* data,
1168                                                       uint32_t size,
1169                                                       int font_type,
1170                                                       FPDF_BOOL cid);
1171 
1172 // Experimental API.
1173 // Loads one of the standard 14 fonts per PDF spec 1.7 page 416. The preferred
1174 // way of using font style is using a dash to separate the name from the style,
1175 // for example 'Helvetica-BoldItalic'.
1176 //
1177 // document   - handle to the document.
1178 // font       - string containing the font name, without spaces.
1179 //
1180 // The loaded font can be closed using FPDFFont_Close.
1181 //
1182 // Returns NULL on failure.
1183 FPDF_EXPORT FPDF_FONT FPDF_CALLCONV
1184 FPDFText_LoadStandardFont(FPDF_DOCUMENT document, FPDF_BYTESTRING font);
1185 
1186 // Get the font size of a text object.
1187 //
1188 //   text - handle to a text.
1189 //   size - pointer to the font size of the text object, measured in points
1190 //   (about 1/72 inch)
1191 //
1192 // Returns TRUE on success.
1193 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1194 FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text, float* size);
1195 
1196 // Close a loaded PDF font.
1197 //
1198 // font   - Handle to the loaded font.
1199 FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font);
1200 
1201 // Create a new text object using a loaded font.
1202 //
1203 // document   - handle to the document.
1204 // font       - handle to the font object.
1205 // font_size  - the font size for the new text object.
1206 //
1207 // Returns a handle to a new text object, or NULL on failure
1208 FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
1209 FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
1210                           FPDF_FONT font,
1211                           float font_size);
1212 
1213 // Get the text rendering mode of a text object.
1214 //
1215 // text     - the handle to the text object.
1216 //
1217 // Returns one of the known FPDF_TEXT_RENDERMODE enum values on success,
1218 // FPDF_TEXTRENDERMODE_UNKNOWN on error.
1219 FPDF_EXPORT FPDF_TEXT_RENDERMODE FPDF_CALLCONV
1220 FPDFTextObj_GetTextRenderMode(FPDF_PAGEOBJECT text);
1221 
1222 // Experimental API.
1223 // Set the text rendering mode of a text object.
1224 //
1225 // text         - the handle to the text object.
1226 // render_mode  - the FPDF_TEXT_RENDERMODE enum value to be set (cannot set to
1227 //                FPDF_TEXTRENDERMODE_UNKNOWN).
1228 //
1229 // Returns TRUE on success.
1230 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1231 FPDFTextObj_SetTextRenderMode(FPDF_PAGEOBJECT text,
1232                               FPDF_TEXT_RENDERMODE render_mode);
1233 
1234 // Get the text of a text object.
1235 //
1236 // text_object      - the handle to the text object.
1237 // text_page        - the handle to the text page.
1238 // buffer           - the address of a buffer that receives the text.
1239 // length           - the size, in bytes, of |buffer|.
1240 //
1241 // Returns the number of bytes in the text (including the trailing NUL
1242 // character) on success, 0 on error.
1243 //
1244 // Regardless of the platform, the |buffer| is always in UTF-16LE encoding.
1245 // If |length| is less than the returned length, or |buffer| is NULL, |buffer|
1246 // will not be modified.
1247 FPDF_EXPORT unsigned long FPDF_CALLCONV
1248 FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
1249                     FPDF_TEXTPAGE text_page,
1250                     FPDF_WCHAR* buffer,
1251                     unsigned long length);
1252 
1253 // Experimental API.
1254 // Get a bitmap rasterization of |text_object|. To render correctly, the caller
1255 // must provide the |document| associated with |text_object|. If there is a
1256 // |page| associated with |text_object|, the caller should provide that as well.
1257 // The returned bitmap will be owned by the caller, and FPDFBitmap_Destroy()
1258 // must be called on the returned bitmap when it is no longer needed.
1259 //
1260 //   document    - handle to a document associated with |text_object|.
1261 //   page        - handle to an optional page associated with |text_object|.
1262 //   text_object - handle to a text object.
1263 //   scale       - the scaling factor, which must be greater than 0.
1264 //
1265 // Returns the bitmap or NULL on failure.
1266 FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
1267 FPDFTextObj_GetRenderedBitmap(FPDF_DOCUMENT document,
1268                               FPDF_PAGE page,
1269                               FPDF_PAGEOBJECT text_object,
1270                               float scale);
1271 
1272 // Experimental API.
1273 // Get the font of a text object.
1274 //
1275 // text - the handle to the text object.
1276 //
1277 // Returns a handle to the font object held by |text| which retains ownership.
1278 FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFTextObj_GetFont(FPDF_PAGEOBJECT text);
1279 
1280 // Experimental API.
1281 // Get the font name of a font.
1282 //
1283 // font   - the handle to the font object.
1284 // buffer - the address of a buffer that receives the font name.
1285 // length - the size, in bytes, of |buffer|.
1286 //
1287 // Returns the number of bytes in the font name (including the trailing NUL
1288 // character) on success, 0 on error.
1289 //
1290 // Regardless of the platform, the |buffer| is always in UTF-8 encoding.
1291 // If |length| is less than the returned length, or |buffer| is NULL, |buffer|
1292 // will not be modified.
1293 FPDF_EXPORT unsigned long FPDF_CALLCONV
1294 FPDFFont_GetFontName(FPDF_FONT font, char* buffer, unsigned long length);
1295 
1296 // Experimental API.
1297 // Get the decoded data from the |font| object.
1298 //
1299 // font       - The handle to the font object. (Required)
1300 // buffer     - The address of a buffer that receives the font data.
1301 // buflen     - Length of the buffer.
1302 // out_buflen - Pointer to variable that will receive the minimum buffer size
1303 //              to contain the font data. Not filled if the return value is
1304 //              FALSE. (Required)
1305 //
1306 // Returns TRUE on success. In which case, |out_buflen| will be filled, and
1307 // |buffer| will be filled if it is large enough. Returns FALSE if any of the
1308 // required parameters are null.
1309 //
1310 // The decoded data is the uncompressed font data. i.e. the raw font data after
1311 // having all stream filters applied, when the data is embedded.
1312 //
1313 // If the font is not embedded, then this API will instead return the data for
1314 // the substitution font it is using.
1315 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetFontData(FPDF_FONT font,
1316                                                          uint8_t* buffer,
1317                                                          size_t buflen,
1318                                                          size_t* out_buflen);
1319 
1320 // Experimental API.
1321 // Get whether |font| is embedded or not.
1322 //
1323 // font - the handle to the font object.
1324 //
1325 // Returns 1 if the font is embedded, 0 if it not, and -1 on failure.
1326 FPDF_EXPORT int FPDF_CALLCONV FPDFFont_GetIsEmbedded(FPDF_FONT font);
1327 
1328 // Experimental API.
1329 // Get the descriptor flags of a font.
1330 //
1331 // font - the handle to the font object.
1332 //
1333 // Returns the bit flags specifying various characteristics of the font as
1334 // defined in ISO 32000-1:2008, table 123, -1 on failure.
1335 FPDF_EXPORT int FPDF_CALLCONV FPDFFont_GetFlags(FPDF_FONT font);
1336 
1337 // Experimental API.
1338 // Get the font weight of a font.
1339 //
1340 // font - the handle to the font object.
1341 //
1342 // Returns the font weight, -1 on failure.
1343 // Typical values are 400 (normal) and 700 (bold).
1344 FPDF_EXPORT int FPDF_CALLCONV FPDFFont_GetWeight(FPDF_FONT font);
1345 
1346 // Experimental API.
1347 // Get the italic angle of a font.
1348 //
1349 // font  - the handle to the font object.
1350 // angle - pointer where the italic angle will be stored
1351 //
1352 // The italic angle of a |font| is defined as degrees counterclockwise
1353 // from vertical. For a font that slopes to the right, this will be negative.
1354 //
1355 // Returns TRUE on success; |angle| unmodified on failure.
1356 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetItalicAngle(FPDF_FONT font,
1357                                                             int* angle);
1358 
1359 // Experimental API.
1360 // Get ascent distance of a font.
1361 //
1362 // font       - the handle to the font object.
1363 // font_size  - the size of the |font|.
1364 // ascent     - pointer where the font ascent will be stored
1365 //
1366 // Ascent is the maximum distance in points above the baseline reached by the
1367 // glyphs of the |font|. One point is 1/72 inch (around 0.3528 mm).
1368 //
1369 // Returns TRUE on success; |ascent| unmodified on failure.
1370 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetAscent(FPDF_FONT font,
1371                                                        float font_size,
1372                                                        float* ascent);
1373 
1374 // Experimental API.
1375 // Get descent distance of a font.
1376 //
1377 // font       - the handle to the font object.
1378 // font_size  - the size of the |font|.
1379 // descent    - pointer where the font descent will be stored
1380 //
1381 // Descent is the maximum distance in points below the baseline reached by the
1382 // glyphs of the |font|. One point is 1/72 inch (around 0.3528 mm).
1383 //
1384 // Returns TRUE on success; |descent| unmodified on failure.
1385 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetDescent(FPDF_FONT font,
1386                                                         float font_size,
1387                                                         float* descent);
1388 
1389 // Experimental API.
1390 // Get the width of a glyph in a font.
1391 //
1392 // font       - the handle to the font object.
1393 // glyph      - the glyph.
1394 // font_size  - the size of the font.
1395 // width      - pointer where the glyph width will be stored
1396 //
1397 // Glyph width is the distance from the end of the prior glyph to the next
1398 // glyph. This will be the vertical distance for vertical writing.
1399 //
1400 // Returns TRUE on success; |width| unmodified on failure.
1401 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetGlyphWidth(FPDF_FONT font,
1402                                                            uint32_t glyph,
1403                                                            float font_size,
1404                                                            float* width);
1405 
1406 // Experimental API.
1407 // Get the glyphpath describing how to draw a font glyph.
1408 //
1409 // font       - the handle to the font object.
1410 // glyph      - the glyph being drawn.
1411 // font_size  - the size of the font.
1412 //
1413 // Returns the handle to the segment, or NULL on faiure.
1414 FPDF_EXPORT FPDF_GLYPHPATH FPDF_CALLCONV FPDFFont_GetGlyphPath(FPDF_FONT font,
1415                                                                uint32_t glyph,
1416                                                                float font_size);
1417 
1418 // Experimental API.
1419 // Get number of segments inside glyphpath.
1420 //
1421 // glyphpath - handle to a glyph path.
1422 //
1423 // Returns the number of objects in |glyphpath| or -1 on failure.
1424 FPDF_EXPORT int FPDF_CALLCONV
1425 FPDFGlyphPath_CountGlyphSegments(FPDF_GLYPHPATH glyphpath);
1426 
1427 // Experimental API.
1428 // Get segment in glyphpath at index.
1429 //
1430 // glyphpath  - handle to a glyph path.
1431 // index      - the index of a segment.
1432 //
1433 // Returns the handle to the segment, or NULL on faiure.
1434 FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
1435 FPDFGlyphPath_GetGlyphPathSegment(FPDF_GLYPHPATH glyphpath, int index);
1436 
1437 // Get number of page objects inside |form_object|.
1438 //
1439 //   form_object - handle to a form object.
1440 //
1441 // Returns the number of objects in |form_object| on success, -1 on error.
1442 FPDF_EXPORT int FPDF_CALLCONV
1443 FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object);
1444 
1445 // Get page object in |form_object| at |index|.
1446 //
1447 //   form_object - handle to a form object.
1448 //   index       - the 0-based index of a page object.
1449 //
1450 // Returns the handle to the page object, or NULL on error.
1451 FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
1452 FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index);
1453 
1454 #ifdef __cplusplus
1455 }  // extern "C"
1456 #endif  // __cplusplus
1457 
1458 #endif  // PUBLIC_FPDF_EDIT_H_
1459