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