1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 // NOTE: External docs refer to this file as "fpdfview.h", so do not rename
8 // despite lack of consistency with other public files.
9 
10 #ifndef PUBLIC_FPDFVIEW_H_
11 #define PUBLIC_FPDFVIEW_H_
12 
13 // clang-format off
14 
15 #include <stddef.h>
16 
17 #if defined(_WIN32) && !defined(__WINDOWS__)
18 #include <windows.h>
19 #endif
20 
21 #ifdef PDF_ENABLE_XFA
22 // PDF_USE_XFA is set in confirmation that this version of PDFium can support
23 // XFA forms as requested by the PDF_ENABLE_XFA setting.
24 #define PDF_USE_XFA
25 #endif  // PDF_ENABLE_XFA
26 
27 // PDF object types
28 #define FPDF_OBJECT_UNKNOWN 0
29 #define FPDF_OBJECT_BOOLEAN 1
30 #define FPDF_OBJECT_NUMBER 2
31 #define FPDF_OBJECT_STRING 3
32 #define FPDF_OBJECT_NAME 4
33 #define FPDF_OBJECT_ARRAY 5
34 #define FPDF_OBJECT_DICTIONARY 6
35 #define FPDF_OBJECT_STREAM 7
36 #define FPDF_OBJECT_NULLOBJ 8
37 #define FPDF_OBJECT_REFERENCE 9
38 
39 // PDF text rendering modes
40 typedef enum {
41   FPDF_TEXTRENDERMODE_UNKNOWN = -1,
42   FPDF_TEXTRENDERMODE_FILL = 0,
43   FPDF_TEXTRENDERMODE_STROKE = 1,
44   FPDF_TEXTRENDERMODE_FILL_STROKE = 2,
45   FPDF_TEXTRENDERMODE_INVISIBLE = 3,
46   FPDF_TEXTRENDERMODE_FILL_CLIP = 4,
47   FPDF_TEXTRENDERMODE_STROKE_CLIP = 5,
48   FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP = 6,
49   FPDF_TEXTRENDERMODE_CLIP = 7,
50   FPDF_TEXTRENDERMODE_LAST = FPDF_TEXTRENDERMODE_CLIP,
51 } FPDF_TEXT_RENDERMODE;
52 
53 // PDF types - use incomplete types (never completed) just for API type safety.
54 typedef struct fpdf_action_t__* FPDF_ACTION;
55 typedef struct fpdf_annotation_t__* FPDF_ANNOTATION;
56 typedef struct fpdf_attachment_t__* FPDF_ATTACHMENT;
57 typedef struct fpdf_bitmap_t__* FPDF_BITMAP;
58 typedef struct fpdf_bookmark_t__* FPDF_BOOKMARK;
59 typedef struct fpdf_clippath_t__* FPDF_CLIPPATH;
60 typedef struct fpdf_dest_t__* FPDF_DEST;
61 typedef struct fpdf_document_t__* FPDF_DOCUMENT;
62 typedef struct fpdf_font_t__* FPDF_FONT;
63 typedef struct fpdf_form_handle_t__* FPDF_FORMHANDLE;
64 typedef struct fpdf_javascript_action_t* FPDF_JAVASCRIPT_ACTION;
65 typedef struct fpdf_link_t__* FPDF_LINK;
66 typedef struct fpdf_page_t__* FPDF_PAGE;
67 typedef struct fpdf_pagelink_t__* FPDF_PAGELINK;
68 typedef struct fpdf_pageobject_t__* FPDF_PAGEOBJECT;  // (text, path, etc.)
69 typedef struct fpdf_pageobjectmark_t__* FPDF_PAGEOBJECTMARK;
70 typedef struct fpdf_pagerange_t__* FPDF_PAGERANGE;
71 typedef const struct fpdf_pathsegment_t* FPDF_PATHSEGMENT;
72 typedef void* FPDF_RECORDER;  // Passed into skia.
73 typedef struct fpdf_schhandle_t__* FPDF_SCHHANDLE;
74 typedef struct fpdf_structelement_t__* FPDF_STRUCTELEMENT;
75 typedef struct fpdf_structtree_t__* FPDF_STRUCTTREE;
76 typedef struct fpdf_textpage_t__* FPDF_TEXTPAGE;
77 typedef struct fpdf_widget_t__* FPDF_WIDGET;
78 
79 // Basic data types
80 typedef int FPDF_BOOL;
81 typedef int FPDF_RESULT;
82 typedef unsigned long FPDF_DWORD;
83 typedef float FS_FLOAT;
84 
85 // Duplex types
86 typedef enum _FPDF_DUPLEXTYPE_ {
87   DuplexUndefined = 0,
88   Simplex,
89   DuplexFlipShortEdge,
90   DuplexFlipLongEdge
91 } FPDF_DUPLEXTYPE;
92 
93 // String types
94 typedef unsigned short FPDF_WCHAR;
95 
96 // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
97 // encoded), and platform dependent string
98 typedef const char* FPDF_BYTESTRING;
99 
100 // FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2
101 // bytes (except surrogation), with the low byte first.
102 typedef const unsigned short* FPDF_WIDESTRING;
103 
104 // Structure for persisting a string beyond the duration of a callback.
105 // Note: although represented as a char*, string may be interpreted as
106 // a UTF-16LE formated string. Used only by XFA callbacks.
107 typedef struct FPDF_BSTR_ {
108   char* str;  // String buffer, manipulate only with FPDF_BStr_* methods.
109   int len;    // Length of the string, in bytes.
110 } FPDF_BSTR;
111 
112 // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
113 // Windows unicode string, however, special care needs to be taken if you
114 // expect to process Unicode larger than 0xffff.
115 //
116 // For Linux/Unix programmers: most compiler/library environments use 4 bytes
117 // for a Unicode character, and you have to convert between FPDF_WIDESTRING and
118 // system wide string by yourself.
119 typedef const char* FPDF_STRING;
120 
121 // Matrix for transformation, in the form [a b c d e f], equivalent to:
122 // | a  b  0 |
123 // | c  d  0 |
124 // | e  f  1 |
125 //
126 // Translation is performed with [1 0 0 1 tx ty].
127 // Scaling is performed with [sx 0 0 sy 0 0].
128 // See PDF Reference 1.7, 4.2.2 Common Transformations for more.
129 typedef struct _FS_MATRIX_ {
130   float a;
131   float b;
132   float c;
133   float d;
134   float e;
135   float f;
136 } FS_MATRIX;
137 
138 // Rectangle area(float) in device or page coordinate system.
139 typedef struct _FS_RECTF_ {
140   // The x-coordinate of the left-top corner.
141   float left;
142   // The y-coordinate of the left-top corner.
143   float top;
144   // The x-coordinate of the right-bottom corner.
145   float right;
146   // The y-coordinate of the right-bottom corner.
147   float bottom;
148 } * FS_LPRECTF, FS_RECTF;
149 
150 // Const Pointer to FS_RECTF structure.
151 typedef const FS_RECTF* FS_LPCRECTF;
152 
153 // Rectangle size. Coordinate system agnostic.
154 typedef struct FS_SIZEF_ {
155   float width;
156   float height;
157 } * FS_LPSIZEF, FS_SIZEF;
158 
159 // Const Pointer to FS_SIZEF structure.
160 typedef const FS_SIZEF* FS_LPCSIZEF;
161 
162 // 2D Point. Coordinate system agnostic.
163 typedef struct FS_POINTF_ {
164   float x;
165   float y;
166 } * FS_LPPOINTF, FS_POINTF;
167 
168 // Const Pointer to FS_POINTF structure.
169 typedef const FS_POINTF* FS_LPCPOINTF;
170 
171 // Annotation enums.
172 typedef int FPDF_ANNOTATION_SUBTYPE;
173 typedef int FPDF_ANNOT_APPEARANCEMODE;
174 
175 // Dictionary value types.
176 typedef int FPDF_OBJECT_TYPE;
177 
178 #if defined(COMPONENT_BUILD)
179 // FPDF_EXPORT should be consistent with |export| in the pdfium_fuzzer
180 // template in testing/fuzzers/BUILD.gn.
181 #if defined(WIN32)
182 #if defined(FPDF_IMPLEMENTATION)
183 #define FPDF_EXPORT __declspec(dllexport)
184 #else
185 #define FPDF_EXPORT __declspec(dllimport)
186 #endif  // defined(FPDF_IMPLEMENTATION)
187 #else
188 #if defined(FPDF_IMPLEMENTATION)
189 #define FPDF_EXPORT __attribute__((visibility("default")))
190 #else
191 #define FPDF_EXPORT
192 #endif  // defined(FPDF_IMPLEMENTATION)
193 #endif  // defined(WIN32)
194 #else
195 #define FPDF_EXPORT
196 #endif  // defined(COMPONENT_BUILD)
197 
198 #if defined(WIN32) && defined(FPDFSDK_EXPORTS)
199 #define FPDF_CALLCONV __stdcall
200 #else
201 #define FPDF_CALLCONV
202 #endif
203 
204 // Exported Functions
205 #ifdef __cplusplus
206 extern "C" {
207 #endif
208 
209 // Function: FPDF_InitLibrary
210 //          Initialize the FPDFSDK library
211 // Parameters:
212 //          None
213 // Return value:
214 //          None.
215 // Comments:
216 //          Convenience function to call FPDF_InitLibraryWithConfig() for
217 //          backwards compatibility purposes. This will be deprecated in the
218 //          future.
219 FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary();
220 
221 // Process-wide options for initializing the library.
222 typedef struct FPDF_LIBRARY_CONFIG_ {
223   // Version number of the interface. Currently must be 2.
224   // Support for version 1 will be deprecated in the future.
225   int version;
226 
227   // Array of paths to scan in place of the defaults when using built-in
228   // FXGE font loading code. The array is terminated by a NULL pointer.
229   // The Array may be NULL itself to use the default paths. May be ignored
230   // entirely depending upon the platform.
231   const char** m_pUserFontPaths;
232 
233   // Version 2.
234 
235   // pointer to the v8::Isolate to use, or NULL to force PDFium to create one.
236   void* m_pIsolate;
237 
238   // The embedder data slot to use in the v8::Isolate to store PDFium's
239   // per-isolate data. The value needs to be in the range
240   // [0, |v8::Internals::kNumIsolateDataLots|). Note that 0 is fine for most
241   // embedders.
242   unsigned int m_v8EmbedderSlot;
243 } FPDF_LIBRARY_CONFIG;
244 
245 // Function: FPDF_InitLibraryWithConfig
246 //          Initialize the FPDFSDK library
247 // Parameters:
248 //          config - configuration information as above.
249 // Return value:
250 //          None.
251 // Comments:
252 //          You have to call this function before you can call any PDF
253 //          processing functions.
254 FPDF_EXPORT void FPDF_CALLCONV
255 FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config);
256 
257 // Function: FPDF_DestroyLibary
258 //          Release all resources allocated by the FPDFSDK library.
259 // Parameters:
260 //          None.
261 // Return value:
262 //          None.
263 // Comments:
264 //          You can call this function to release all memory blocks allocated by
265 //          the library.
266 //          After this function is called, you should not call any PDF
267 //          processing functions.
268 FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary();
269 
270 // Policy for accessing the local machine time.
271 #define FPDF_POLICY_MACHINETIME_ACCESS 0
272 
273 // Function: FPDF_SetSandBoxPolicy
274 //          Set the policy for the sandbox environment.
275 // Parameters:
276 //          policy -   The specified policy for setting, for example:
277 //                     FPDF_POLICY_MACHINETIME_ACCESS.
278 //          enable -   True to enable, false to disable the policy.
279 // Return value:
280 //          None.
281 FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
282                                                      FPDF_BOOL enable);
283 
284 #if defined(_WIN32)
285 #if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
286 // Pointer to a helper function to make |font| with |text| of |text_length|
287 // accessible when printing text with GDI. This is useful in sandboxed
288 // environments where PDFium's access to GDI may be restricted.
289 typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
290                                                          const wchar_t* text,
291                                                          size_t text_length);
292 
293 // Function: FPDF_SetTypefaceAccessibleFunc
294 //          Set the function pointer that makes GDI fonts available in sandboxed
295 //          environments. Experimental API.
296 // Parameters:
297 //          func -   A function pointer. See description above.
298 // Return value:
299 //          None.
300 FPDF_EXPORT void FPDF_CALLCONV
301 FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func);
302 
303 // Function: FPDF_SetPrintTextWithGDI
304 //          Set whether to use GDI to draw fonts when printing on Windows.
305 //          Experimental API.
306 // Parameters:
307 //          use_gdi -   Set to true to enable printing text with GDI.
308 // Return value:
309 //          None.
310 FPDF_EXPORT void FPDF_CALLCONV FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi);
311 #endif  // PDFIUM_PRINT_TEXT_WITH_GDI
312 
313 // Function: FPDF_SetPrintMode
314 //          Set printing mode when printing on Windows.
315 //          Experimental API.
316 // Parameters:
317 //          mode - FPDF_PRINTMODE_EMF to output EMF (default)
318 //                 FPDF_PRINTMODE_TEXTONLY to output text only (for charstream
319 //                 devices)
320 //                 FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 PostScript into
321 //                 EMF as a series of GDI comments.
322 //                 FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 PostScript into
323 //                 EMF as a series of GDI comments.
324 //                 FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH to output level 2
325 //                 PostScript via ExtEscape() in PASSTHROUGH mode.
326 //                 FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH to output level 3
327 //                 PostScript via ExtEscape() in PASSTHROUGH mode.
328 // Return value:
329 //          True if successful, false if unsuccessful (typically invalid input).
330 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SetPrintMode(int mode);
331 #endif  // defined(_WIN32)
332 
333 // Function: FPDF_LoadDocument
334 //          Open and load a PDF document.
335 // Parameters:
336 //          file_path -  Path to the PDF file (including extension).
337 //          password  -  A string used as the password for the PDF file.
338 //                       If no password is needed, empty or NULL can be used.
339 //                       See comments below regarding the encoding.
340 // Return value:
341 //          A handle to the loaded document, or NULL on failure.
342 // Comments:
343 //          Loaded document can be closed by FPDF_CloseDocument().
344 //          If this function fails, you can use FPDF_GetLastError() to retrieve
345 //          the reason why it failed.
346 //
347 //          The encoding for |password| can be either UTF-8 or Latin-1. PDFs,
348 //          depending on the security handler revision, will only accept one or
349 //          the other encoding. If |password|'s encoding and the PDF's expected
350 //          encoding do not match, FPDF_LoadDocument() will automatically
351 //          convert |password| to the other encoding.
352 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
353 FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password);
354 
355 // Function: FPDF_LoadMemDocument
356 //          Open and load a PDF document from memory.
357 // Parameters:
358 //          data_buf    -   Pointer to a buffer containing the PDF document.
359 //          size        -   Number of bytes in the PDF document.
360 //          password    -   A string used as the password for the PDF file.
361 //                          If no password is needed, empty or NULL can be used.
362 // Return value:
363 //          A handle to the loaded document, or NULL on failure.
364 // Comments:
365 //          The memory buffer must remain valid when the document is open.
366 //          The loaded document can be closed by FPDF_CloseDocument.
367 //          If this function fails, you can use FPDF_GetLastError() to retrieve
368 //          the reason why it failed.
369 //
370 //          See the comments for FPDF_LoadDocument() regarding the encoding for
371 //          |password|.
372 // Notes:
373 //          If PDFium is built with the XFA module, the application should call
374 //          FPDF_LoadXFA() function after the PDF document loaded to support XFA
375 //          fields defined in the fpdfformfill.h file.
376 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
377 FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password);
378 
379 // Structure for custom file access.
380 typedef struct {
381   // File length, in bytes.
382   unsigned long m_FileLen;
383 
384   // A function pointer for getting a block of data from a specific position.
385   // Position is specified by byte offset from the beginning of the file.
386   // The pointer to the buffer is never NULL and the size is never 0.
387   // The position and size will never go out of range of the file length.
388   // It may be possible for FPDFSDK to call this function multiple times for
389   // the same position.
390   // Return value: should be non-zero if successful, zero for error.
391   int (*m_GetBlock)(void* param,
392                     unsigned long position,
393                     unsigned char* pBuf,
394                     unsigned long size);
395 
396   // A custom pointer for all implementation specific data.  This pointer will
397   // be used as the first parameter to the m_GetBlock callback.
398   void* m_Param;
399 } FPDF_FILEACCESS;
400 
401 /*
402  * Structure for file reading or writing (I/O).
403  *
404  * Note: This is a handler and should be implemented by callers,
405  * and is only used from XFA.
406  */
407 typedef struct FPDF_FILEHANDLER_ {
408   /*
409    * User-defined data.
410    * Note: Callers can use this field to track controls.
411    */
412   void* clientData;
413 
414   /*
415    * Callback function to release the current file stream object.
416    *
417    * Parameters:
418    *       clientData   -  Pointer to user-defined data.
419    * Returns:
420    *       None.
421    */
422   void (*Release)(void* clientData);
423 
424   /*
425    * Callback function to retrieve the current file stream size.
426    *
427    * Parameters:
428    *       clientData   -  Pointer to user-defined data.
429    * Returns:
430    *       Size of file stream.
431    */
432   FPDF_DWORD (*GetSize)(void* clientData);
433 
434   /*
435    * Callback function to read data from the current file stream.
436    *
437    * Parameters:
438    *       clientData   -  Pointer to user-defined data.
439    *       offset       -  Offset position starts from the beginning of file
440    *                       stream. This parameter indicates reading position.
441    *       buffer       -  Memory buffer to store data which are read from
442    *                       file stream. This parameter should not be NULL.
443    *       size         -  Size of data which should be read from file stream,
444    *                       in bytes. The buffer indicated by |buffer| must be
445    *                       large enough to store specified data.
446    * Returns:
447    *       0 for success, other value for failure.
448    */
449   FPDF_RESULT (*ReadBlock)(void* clientData,
450                            FPDF_DWORD offset,
451                            void* buffer,
452                            FPDF_DWORD size);
453 
454   /*
455    * Callback function to write data into the current file stream.
456    *
457    * Parameters:
458    *       clientData   -  Pointer to user-defined data.
459    *       offset       -  Offset position starts from the beginning of file
460    *                       stream. This parameter indicates writing position.
461    *       buffer       -  Memory buffer contains data which is written into
462    *                       file stream. This parameter should not be NULL.
463    *       size         -  Size of data which should be written into file
464    *                       stream, in bytes.
465    * Returns:
466    *       0 for success, other value for failure.
467    */
468   FPDF_RESULT (*WriteBlock)(void* clientData,
469                             FPDF_DWORD offset,
470                             const void* buffer,
471                             FPDF_DWORD size);
472   /*
473    * Callback function to flush all internal accessing buffers.
474    *
475    * Parameters:
476    *       clientData   -  Pointer to user-defined data.
477    * Returns:
478    *       0 for success, other value for failure.
479    */
480   FPDF_RESULT (*Flush)(void* clientData);
481 
482   /*
483    * Callback function to change file size.
484    *
485    * Description:
486    *       This function is called under writing mode usually. Implementer
487    *       can determine whether to realize it based on application requests.
488    * Parameters:
489    *       clientData   -  Pointer to user-defined data.
490    *       size         -  New size of file stream, in bytes.
491    * Returns:
492    *       0 for success, other value for failure.
493    */
494   FPDF_RESULT (*Truncate)(void* clientData, FPDF_DWORD size);
495 } FPDF_FILEHANDLER;
496 
497 // Function: FPDF_LoadCustomDocument
498 //          Load PDF document from a custom access descriptor.
499 // Parameters:
500 //          pFileAccess -   A structure for accessing the file.
501 //          password    -   Optional password for decrypting the PDF file.
502 // Return value:
503 //          A handle to the loaded document, or NULL on failure.
504 // Comments:
505 //          The application must keep the file resources |pFileAccess| points to
506 //          valid until the returned FPDF_DOCUMENT is closed. |pFileAccess|
507 //          itself does not need to outlive the FPDF_DOCUMENT.
508 //
509 //          The loaded document can be closed with FPDF_CloseDocument().
510 //
511 //          See the comments for FPDF_LoadDocument() regarding the encoding for
512 //          |password|.
513 // Notes:
514 //          If PDFium is built with the XFA module, the application should call
515 //          FPDF_LoadXFA() function after the PDF document loaded to support XFA
516 //          fields defined in the fpdfformfill.h file.
517 FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
518 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
519 
520 // Function: FPDF_GetFileVersion
521 //          Get the file version of the given PDF document.
522 // Parameters:
523 //          doc         -   Handle to a document.
524 //          fileVersion -   The PDF file version. File version: 14 for 1.4, 15
525 //                          for 1.5, ...
526 // Return value:
527 //          True if succeeds, false otherwise.
528 // Comments:
529 //          If the document was created by FPDF_CreateNewDocument,
530 //          then this function will always fail.
531 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc,
532                                                         int* fileVersion);
533 
534 #define FPDF_ERR_SUCCESS 0    // No error.
535 #define FPDF_ERR_UNKNOWN 1    // Unknown error.
536 #define FPDF_ERR_FILE 2       // File not found or could not be opened.
537 #define FPDF_ERR_FORMAT 3     // File not in PDF format or corrupted.
538 #define FPDF_ERR_PASSWORD 4   // Password required or incorrect password.
539 #define FPDF_ERR_SECURITY 5   // Unsupported security scheme.
540 #define FPDF_ERR_PAGE 6       // Page not found or content error.
541 #ifdef PDF_ENABLE_XFA
542 #define FPDF_ERR_XFALOAD 7    // Load XFA error.
543 #define FPDF_ERR_XFALAYOUT 8  // Layout XFA error.
544 #endif  // PDF_ENABLE_XFA
545 
546 // Function: FPDF_GetLastError
547 //          Get last error code when a function fails.
548 // Parameters:
549 //          None.
550 // Return value:
551 //          A 32-bit integer indicating error code as defined above.
552 // Comments:
553 //          If the previous SDK call succeeded, the return value of this
554 //          function is not defined.
555 FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError();
556 
557 // Function: FPDF_DocumentHasValidCrossReferenceTable
558 //          Whether the document's cross reference table is valid or not.
559 //          Experimental API.
560 // Parameters:
561 //          document    -   Handle to a document. Returned by FPDF_LoadDocument.
562 // Return value:
563 //          True if the PDF parser did not encounter problems parsing the cross
564 //          reference table. False if the parser could not parse the cross
565 //          reference table and the table had to be rebuild from other data
566 //          within the document.
567 // Comments:
568 //          The return value can change over time as the PDF parser evolves.
569 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
570 FPDF_DocumentHasValidCrossReferenceTable(FPDF_DOCUMENT document);
571 
572 // Function: FPDF_GetDocPermission
573 //          Get file permission flags of the document.
574 // Parameters:
575 //          document    -   Handle to a document. Returned by FPDF_LoadDocument.
576 // Return value:
577 //          A 32-bit integer indicating permission flags. Please refer to the
578 //          PDF Reference for detailed descriptions. If the document is not
579 //          protected, 0xffffffff will be returned.
580 FPDF_EXPORT unsigned long FPDF_CALLCONV
581 FPDF_GetDocPermissions(FPDF_DOCUMENT document);
582 
583 // Function: FPDF_GetSecurityHandlerRevision
584 //          Get the revision for the security handler.
585 // Parameters:
586 //          document    -   Handle to a document. Returned by FPDF_LoadDocument.
587 // Return value:
588 //          The security handler revision number. Please refer to the PDF
589 //          Reference for a detailed description. If the document is not
590 //          protected, -1 will be returned.
591 FPDF_EXPORT int FPDF_CALLCONV
592 FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
593 
594 // Function: FPDF_GetPageCount
595 //          Get total number of pages in the document.
596 // Parameters:
597 //          document    -   Handle to document. Returned by FPDF_LoadDocument.
598 // Return value:
599 //          Total number of pages in the document.
600 FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document);
601 
602 // Function: FPDF_LoadPage
603 //          Load a page inside the document.
604 // Parameters:
605 //          document    -   Handle to document. Returned by FPDF_LoadDocument
606 //          page_index  -   Index number of the page. 0 for the first page.
607 // Return value:
608 //          A handle to the loaded page, or NULL if page load fails.
609 // Comments:
610 //          The loaded page can be rendered to devices using FPDF_RenderPage.
611 //          The loaded page can be closed using FPDF_ClosePage.
612 FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document,
613                                                   int page_index);
614 
615 // Experimental API
616 // Function: FPDF_GetPageWidthF
617 //          Get page width.
618 // Parameters:
619 //          page        -   Handle to the page. Returned by FPDF_LoadPage().
620 // Return value:
621 //          Page width (excluding non-displayable area) measured in points.
622 //          One point is 1/72 inch (around 0.3528 mm).
623 FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageWidthF(FPDF_PAGE page);
624 
625 // Function: FPDF_GetPageWidth
626 //          Get page width.
627 // Parameters:
628 //          page        -   Handle to the page. Returned by FPDF_LoadPage.
629 // Return value:
630 //          Page width (excluding non-displayable area) measured in points.
631 //          One point is 1/72 inch (around 0.3528 mm).
632 // Note:
633 //          Prefer FPDF_GetPageWidthF() above. This will be deprecated in the
634 //          future.
635 FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page);
636 
637 // Experimental API
638 // Function: FPDF_GetPageHeightF
639 //          Get page height.
640 // Parameters:
641 //          page        -   Handle to the page. Returned by FPDF_LoadPage().
642 // Return value:
643 //          Page height (excluding non-displayable area) measured in points.
644 //          One point is 1/72 inch (around 0.3528 mm)
645 FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageHeightF(FPDF_PAGE page);
646 
647 // Function: FPDF_GetPageHeight
648 //          Get page height.
649 // Parameters:
650 //          page        -   Handle to the page. Returned by FPDF_LoadPage.
651 // Return value:
652 //          Page height (excluding non-displayable area) measured in points.
653 //          One point is 1/72 inch (around 0.3528 mm)
654 // Note:
655 //          Prefer FPDF_GetPageHeightF() above. This will be deprecated in the
656 //          future.
657 FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page);
658 
659 // Experimental API.
660 // Function: FPDF_GetPageBoundingBox
661 //          Get the bounding box of the page. This is the intersection between
662 //          its media box and its crop box.
663 // Parameters:
664 //          page        -   Handle to the page. Returned by FPDF_LoadPage.
665 //          rect        -   Pointer to a rect to receive the page bounding box.
666 //                          On an error, |rect| won't be filled.
667 // Return value:
668 //          True for success.
669 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetPageBoundingBox(FPDF_PAGE page,
670                                                             FS_RECTF* rect);
671 
672 // Experimental API.
673 // Function: FPDF_GetPageSizeByIndexF
674 //          Get the size of the page at the given index.
675 // Parameters:
676 //          document    -   Handle to document. Returned by FPDF_LoadDocument().
677 //          page_index  -   Page index, zero for the first page.
678 //          size        -   Pointer to a FS_SIZEF to receive the page size.
679 //                          (in points).
680 // Return value:
681 //          Non-zero for success. 0 for error (document or page not found).
682 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
683 FPDF_GetPageSizeByIndexF(FPDF_DOCUMENT document,
684                          int page_index,
685                          FS_SIZEF* size);
686 
687 // Function: FPDF_GetPageSizeByIndex
688 //          Get the size of the page at the given index.
689 // Parameters:
690 //          document    -   Handle to document. Returned by FPDF_LoadDocument.
691 //          page_index  -   Page index, zero for the first page.
692 //          width       -   Pointer to a double to receive the page width
693 //                          (in points).
694 //          height      -   Pointer to a double to receive the page height
695 //                          (in points).
696 // Return value:
697 //          Non-zero for success. 0 for error (document or page not found).
698 // Note:
699 //          Prefer FPDF_GetPageSizeByIndexF() above. This will be deprecated in
700 //          the future.
701 FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
702                                                       int page_index,
703                                                       double* width,
704                                                       double* height);
705 
706 // Page rendering flags. They can be combined with bit-wise OR.
707 //
708 // Set if annotations are to be rendered.
709 #define FPDF_ANNOT 0x01
710 // Set if using text rendering optimized for LCD display.
711 #define FPDF_LCD_TEXT 0x02
712 // Don't use the native text output available on some platforms
713 #define FPDF_NO_NATIVETEXT 0x04
714 // Grayscale output.
715 #define FPDF_GRAYSCALE 0x08
716 // Obsolete, has no effect, retained for compatibility.
717 #define FPDF_DEBUG_INFO 0x80
718 // Obsolete, has no effect, retained for compatibility.
719 #define FPDF_NO_CATCH 0x100
720 // Limit image cache size.
721 #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
722 // Always use halftone for image stretching.
723 #define FPDF_RENDER_FORCEHALFTONE 0x400
724 // Render for printing.
725 #define FPDF_PRINTING 0x800
726 // Set to disable anti-aliasing on text.
727 #define FPDF_RENDER_NO_SMOOTHTEXT 0x1000
728 // Set to disable anti-aliasing on images.
729 #define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000
730 // Set to disable anti-aliasing on paths.
731 #define FPDF_RENDER_NO_SMOOTHPATH 0x4000
732 // Set whether to render in a reverse Byte order, this flag is only used when
733 // rendering to a bitmap.
734 #define FPDF_REVERSE_BYTE_ORDER 0x10
735 
736 #ifdef _WIN32
737 // Function: FPDF_RenderPage
738 //          Render contents of a page to a device (screen, bitmap, or printer).
739 //          This function is only supported on Windows.
740 // Parameters:
741 //          dc          -   Handle to the device context.
742 //          page        -   Handle to the page. Returned by FPDF_LoadPage.
743 //          start_x     -   Left pixel position of the display area in
744 //                          device coordinates.
745 //          start_y     -   Top pixel position of the display area in device
746 //                          coordinates.
747 //          size_x      -   Horizontal size (in pixels) for displaying the page.
748 //          size_y      -   Vertical size (in pixels) for displaying the page.
749 //          rotate      -   Page orientation:
750 //                            0 (normal)
751 //                            1 (rotated 90 degrees clockwise)
752 //                            2 (rotated 180 degrees)
753 //                            3 (rotated 90 degrees counter-clockwise)
754 //          flags       -   0 for normal display, or combination of flags
755 //                          defined above.
756 // Return value:
757 //          None.
758 FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc,
759                                                FPDF_PAGE page,
760                                                int start_x,
761                                                int start_y,
762                                                int size_x,
763                                                int size_y,
764                                                int rotate,
765                                                int flags);
766 #endif
767 
768 // Function: FPDF_RenderPageBitmap
769 //          Render contents of a page to a device independent bitmap.
770 // Parameters:
771 //          bitmap      -   Handle to the device independent bitmap (as the
772 //                          output buffer). The bitmap handle can be created
773 //                          by FPDFBitmap_Create or retrieved from an image
774 //                          object by FPDFImageObj_GetBitmap.
775 //          page        -   Handle to the page. Returned by FPDF_LoadPage
776 //          start_x     -   Left pixel position of the display area in
777 //                          bitmap coordinates.
778 //          start_y     -   Top pixel position of the display area in bitmap
779 //                          coordinates.
780 //          size_x      -   Horizontal size (in pixels) for displaying the page.
781 //          size_y      -   Vertical size (in pixels) for displaying the page.
782 //          rotate      -   Page orientation:
783 //                            0 (normal)
784 //                            1 (rotated 90 degrees clockwise)
785 //                            2 (rotated 180 degrees)
786 //                            3 (rotated 90 degrees counter-clockwise)
787 //          flags       -   0 for normal display, or combination of the Page
788 //                          Rendering flags defined above. With the FPDF_ANNOT
789 //                          flag, it renders all annotations that do not require
790 //                          user-interaction, which are all annotations except
791 //                          widget and popup annotations.
792 // Return value:
793 //          None.
794 FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
795                                                      FPDF_PAGE page,
796                                                      int start_x,
797                                                      int start_y,
798                                                      int size_x,
799                                                      int size_y,
800                                                      int rotate,
801                                                      int flags);
802 
803 // Function: FPDF_RenderPageBitmapWithMatrix
804 //          Render contents of a page to a device independent bitmap.
805 // Parameters:
806 //          bitmap      -   Handle to the device independent bitmap (as the
807 //                          output buffer). The bitmap handle can be created
808 //                          by FPDFBitmap_Create or retrieved by
809 //                          FPDFImageObj_GetBitmap.
810 //          page        -   Handle to the page. Returned by FPDF_LoadPage.
811 //          matrix      -   The transform matrix, which must be invertible.
812 //                          See PDF Reference 1.7, 4.2.2 Common Transformations.
813 //          clipping    -   The rect to clip to in device coords.
814 //          flags       -   0 for normal display, or combination of the Page
815 //                          Rendering flags defined above. With the FPDF_ANNOT
816 //                          flag, it renders all annotations that do not require
817 //                          user-interaction, which are all annotations except
818 //                          widget and popup annotations.
819 // Return value:
820 //          None. Note that behavior is undefined if det of |matrix| is 0.
821 FPDF_EXPORT void FPDF_CALLCONV
822 FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap,
823                                 FPDF_PAGE page,
824                                 const FS_MATRIX* matrix,
825                                 const FS_RECTF* clipping,
826                                 int flags);
827 
828 #ifdef _SKIA_SUPPORT_
829 FPDF_EXPORT FPDF_RECORDER FPDF_CALLCONV FPDF_RenderPageSkp(FPDF_PAGE page,
830                                                            int size_x,
831                                                            int size_y);
832 #endif
833 
834 // Function: FPDF_ClosePage
835 //          Close a loaded PDF page.
836 // Parameters:
837 //          page        -   Handle to the loaded page.
838 // Return value:
839 //          None.
840 FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page);
841 
842 // Function: FPDF_CloseDocument
843 //          Close a loaded PDF document.
844 // Parameters:
845 //          document    -   Handle to the loaded document.
846 // Return value:
847 //          None.
848 FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document);
849 
850 // Function: FPDF_DeviceToPage
851 //          Convert the screen coordinates of a point to page coordinates.
852 // Parameters:
853 //          page        -   Handle to the page. Returned by FPDF_LoadPage.
854 //          start_x     -   Left pixel position of the display area in
855 //                          device coordinates.
856 //          start_y     -   Top pixel position of the display area in device
857 //                          coordinates.
858 //          size_x      -   Horizontal size (in pixels) for displaying the page.
859 //          size_y      -   Vertical size (in pixels) for displaying the page.
860 //          rotate      -   Page orientation:
861 //                            0 (normal)
862 //                            1 (rotated 90 degrees clockwise)
863 //                            2 (rotated 180 degrees)
864 //                            3 (rotated 90 degrees counter-clockwise)
865 //          device_x    -   X value in device coordinates to be converted.
866 //          device_y    -   Y value in device coordinates to be converted.
867 //          page_x      -   A pointer to a double receiving the converted X
868 //                          value in page coordinates.
869 //          page_y      -   A pointer to a double receiving the converted Y
870 //                          value in page coordinates.
871 // Return value:
872 //          Returns true if the conversion succeeds, and |page_x| and |page_y|
873 //          successfully receives the converted coordinates.
874 // Comments:
875 //          The page coordinate system has its origin at the left-bottom corner
876 //          of the page, with the X-axis on the bottom going to the right, and
877 //          the Y-axis on the left side going up.
878 //
879 //          NOTE: this coordinate system can be altered when you zoom, scroll,
880 //          or rotate a page, however, a point on the page should always have
881 //          the same coordinate values in the page coordinate system.
882 //
883 //          The device coordinate system is device dependent. For screen device,
884 //          its origin is at the left-top corner of the window. However this
885 //          origin can be altered by the Windows coordinate transformation
886 //          utilities.
887 //
888 //          You must make sure the start_x, start_y, size_x, size_y
889 //          and rotate parameters have exactly same values as you used in
890 //          the FPDF_RenderPage() function call.
891 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page,
892                                                       int start_x,
893                                                       int start_y,
894                                                       int size_x,
895                                                       int size_y,
896                                                       int rotate,
897                                                       int device_x,
898                                                       int device_y,
899                                                       double* page_x,
900                                                       double* page_y);
901 
902 // Function: FPDF_PageToDevice
903 //          Convert the page coordinates of a point to screen coordinates.
904 // Parameters:
905 //          page        -   Handle to the page. Returned by FPDF_LoadPage.
906 //          start_x     -   Left pixel position of the display area in
907 //                          device coordinates.
908 //          start_y     -   Top pixel position of the display area in device
909 //                          coordinates.
910 //          size_x      -   Horizontal size (in pixels) for displaying the page.
911 //          size_y      -   Vertical size (in pixels) for displaying the page.
912 //          rotate      -   Page orientation:
913 //                            0 (normal)
914 //                            1 (rotated 90 degrees clockwise)
915 //                            2 (rotated 180 degrees)
916 //                            3 (rotated 90 degrees counter-clockwise)
917 //          page_x      -   X value in page coordinates.
918 //          page_y      -   Y value in page coordinate.
919 //          device_x    -   A pointer to an integer receiving the result X
920 //                          value in device coordinates.
921 //          device_y    -   A pointer to an integer receiving the result Y
922 //                          value in device coordinates.
923 // Return value:
924 //          Returns true if the conversion succeeds, and |device_x| and
925 //          |device_y| successfully receives the converted coordinates.
926 // Comments:
927 //          See comments for FPDF_DeviceToPage().
928 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page,
929                                                       int start_x,
930                                                       int start_y,
931                                                       int size_x,
932                                                       int size_y,
933                                                       int rotate,
934                                                       double page_x,
935                                                       double page_y,
936                                                       int* device_x,
937                                                       int* device_y);
938 
939 // Function: FPDFBitmap_Create
940 //          Create a device independent bitmap (FXDIB).
941 // Parameters:
942 //          width       -   The number of pixels in width for the bitmap.
943 //                          Must be greater than 0.
944 //          height      -   The number of pixels in height for the bitmap.
945 //                          Must be greater than 0.
946 //          alpha       -   A flag indicating whether the alpha channel is used.
947 //                          Non-zero for using alpha, zero for not using.
948 // Return value:
949 //          The created bitmap handle, or NULL if a parameter error or out of
950 //          memory.
951 // Comments:
952 //          The bitmap always uses 4 bytes per pixel. The first byte is always
953 //          double word aligned.
954 //
955 //          The byte order is BGRx (the last byte unused if no alpha channel) or
956 //          BGRA.
957 //
958 //          The pixels in a horizontal line are stored side by side, with the
959 //          left most pixel stored first (with lower memory address).
960 //          Each line uses width * 4 bytes.
961 //
962 //          Lines are stored one after another, with the top most line stored
963 //          first. There is no gap between adjacent lines.
964 //
965 //          This function allocates enough memory for holding all pixels in the
966 //          bitmap, but it doesn't initialize the buffer. Applications can use
967 //          FPDFBitmap_FillRect() to fill the bitmap using any color. If the OS
968 //          allows it, this function can allocate up to 4 GB of memory.
969 FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width,
970                                                         int height,
971                                                         int alpha);
972 
973 // More DIB formats
974 // Unknown or unsupported format.
975 #define FPDFBitmap_Unknown 0
976 // Gray scale bitmap, one byte per pixel.
977 #define FPDFBitmap_Gray 1
978 // 3 bytes per pixel, byte order: blue, green, red.
979 #define FPDFBitmap_BGR 2
980 // 4 bytes per pixel, byte order: blue, green, red, unused.
981 #define FPDFBitmap_BGRx 3
982 // 4 bytes per pixel, byte order: blue, green, red, alpha.
983 #define FPDFBitmap_BGRA 4
984 
985 // Function: FPDFBitmap_CreateEx
986 //          Create a device independent bitmap (FXDIB)
987 // Parameters:
988 //          width       -   The number of pixels in width for the bitmap.
989 //                          Must be greater than 0.
990 //          height      -   The number of pixels in height for the bitmap.
991 //                          Must be greater than 0.
992 //          format      -   A number indicating for bitmap format, as defined
993 //                          above.
994 //          first_scan  -   A pointer to the first byte of the first line if
995 //                          using an external buffer. If this parameter is NULL,
996 //                          then the a new buffer will be created.
997 //          stride      -   Number of bytes for each scan line, for external
998 //                          buffer only.
999 // Return value:
1000 //          The bitmap handle, or NULL if parameter error or out of memory.
1001 // Comments:
1002 //          Similar to FPDFBitmap_Create function, but allows for more formats
1003 //          and an external buffer is supported. The bitmap created by this
1004 //          function can be used in any place that a FPDF_BITMAP handle is
1005 //          required.
1006 //
1007 //          If an external buffer is used, then the application should destroy
1008 //          the buffer by itself. FPDFBitmap_Destroy function will not destroy
1009 //          the buffer.
1010 FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
1011                                                           int height,
1012                                                           int format,
1013                                                           void* first_scan,
1014                                                           int stride);
1015 
1016 // Function: FPDFBitmap_GetFormat
1017 //          Get the format of the bitmap.
1018 // Parameters:
1019 //          bitmap      -   Handle to the bitmap. Returned by FPDFBitmap_Create
1020 //                          or FPDFImageObj_GetBitmap.
1021 // Return value:
1022 //          The format of the bitmap.
1023 // Comments:
1024 //          Only formats supported by FPDFBitmap_CreateEx are supported by this
1025 //          function; see the list of such formats above.
1026 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
1027 
1028 // Function: FPDFBitmap_FillRect
1029 //          Fill a rectangle in a bitmap.
1030 // Parameters:
1031 //          bitmap      -   The handle to the bitmap. Returned by
1032 //                          FPDFBitmap_Create.
1033 //          left        -   The left position. Starting from 0 at the
1034 //                          left-most pixel.
1035 //          top         -   The top position. Starting from 0 at the
1036 //                          top-most line.
1037 //          width       -   Width in pixels to be filled.
1038 //          height      -   Height in pixels to be filled.
1039 //          color       -   A 32-bit value specifing the color, in 8888 ARGB
1040 //                          format.
1041 // Return value:
1042 //          None.
1043 // Comments:
1044 //          This function sets the color and (optionally) alpha value in the
1045 //          specified region of the bitmap.
1046 //
1047 //          NOTE: If the alpha channel is used, this function does NOT
1048 //          composite the background with the source color, instead the
1049 //          background will be replaced by the source color and the alpha.
1050 //
1051 //          If the alpha channel is not used, the alpha parameter is ignored.
1052 FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
1053                                                    int left,
1054                                                    int top,
1055                                                    int width,
1056                                                    int height,
1057                                                    FPDF_DWORD color);
1058 
1059 // Function: FPDFBitmap_GetBuffer
1060 //          Get data buffer of a bitmap.
1061 // Parameters:
1062 //          bitmap      -   Handle to the bitmap. Returned by FPDFBitmap_Create
1063 //                          or FPDFImageObj_GetBitmap.
1064 // Return value:
1065 //          The pointer to the first byte of the bitmap buffer.
1066 // Comments:
1067 //          The stride may be more than width * number of bytes per pixel
1068 //
1069 //          Applications can use this function to get the bitmap buffer pointer,
1070 //          then manipulate any color and/or alpha values for any pixels in the
1071 //          bitmap.
1072 //
1073 //          The data is in BGRA format. Where the A maybe unused if alpha was
1074 //          not specified.
1075 FPDF_EXPORT void* FPDF_CALLCONV FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap);
1076 
1077 // Function: FPDFBitmap_GetWidth
1078 //          Get width of a bitmap.
1079 // Parameters:
1080 //          bitmap      -   Handle to the bitmap. Returned by FPDFBitmap_Create
1081 //                          or FPDFImageObj_GetBitmap.
1082 // Return value:
1083 //          The width of the bitmap in pixels.
1084 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap);
1085 
1086 // Function: FPDFBitmap_GetHeight
1087 //          Get height of a bitmap.
1088 // Parameters:
1089 //          bitmap      -   Handle to the bitmap. Returned by FPDFBitmap_Create
1090 //                          or FPDFImageObj_GetBitmap.
1091 // Return value:
1092 //          The height of the bitmap in pixels.
1093 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap);
1094 
1095 // Function: FPDFBitmap_GetStride
1096 //          Get number of bytes for each line in the bitmap buffer.
1097 // Parameters:
1098 //          bitmap      -   Handle to the bitmap. Returned by FPDFBitmap_Create
1099 //                          or FPDFImageObj_GetBitmap.
1100 // Return value:
1101 //          The number of bytes for each line in the bitmap buffer.
1102 // Comments:
1103 //          The stride may be more than width * number of bytes per pixel.
1104 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap);
1105 
1106 // Function: FPDFBitmap_Destroy
1107 //          Destroy a bitmap and release all related buffers.
1108 // Parameters:
1109 //          bitmap      -   Handle to the bitmap. Returned by FPDFBitmap_Create
1110 //                          or FPDFImageObj_GetBitmap.
1111 // Return value:
1112 //          None.
1113 // Comments:
1114 //          This function will not destroy any external buffers provided when
1115 //          the bitmap was created.
1116 FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
1117 
1118 // Function: FPDF_VIEWERREF_GetPrintScaling
1119 //          Whether the PDF document prefers to be scaled or not.
1120 // Parameters:
1121 //          document    -   Handle to the loaded document.
1122 // Return value:
1123 //          None.
1124 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1125 FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
1126 
1127 // Function: FPDF_VIEWERREF_GetNumCopies
1128 //          Returns the number of copies to be printed.
1129 // Parameters:
1130 //          document    -   Handle to the loaded document.
1131 // Return value:
1132 //          The number of copies to be printed.
1133 FPDF_EXPORT int FPDF_CALLCONV
1134 FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document);
1135 
1136 // Function: FPDF_VIEWERREF_GetPrintPageRange
1137 //          Page numbers to initialize print dialog box when file is printed.
1138 // Parameters:
1139 //          document    -   Handle to the loaded document.
1140 // Return value:
1141 //          The print page range to be used for printing.
1142 FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV
1143 FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document);
1144 
1145 // Function: FPDF_VIEWERREF_GetPrintPageRangeCount
1146 //          Returns the number of elements in a FPDF_PAGERANGE.
1147 //          Experimental API.
1148 // Parameters:
1149 //          pagerange   -   Handle to the page range.
1150 // Return value:
1151 //          The number of elements in the page range. Returns 0 on error.
1152 FPDF_EXPORT size_t FPDF_CALLCONV
1153 FPDF_VIEWERREF_GetPrintPageRangeCount(FPDF_PAGERANGE pagerange);
1154 
1155 // Function: FPDF_VIEWERREF_GetPrintPageRangeElement
1156 //          Returns an element from a FPDF_PAGERANGE.
1157 //          Experimental API.
1158 // Parameters:
1159 //          pagerange   -   Handle to the page range.
1160 //          index       -   Index of the element.
1161 // Return value:
1162 //          The value of the element in the page range at a given index.
1163 //          Returns -1 on error.
1164 FPDF_EXPORT int FPDF_CALLCONV
1165 FPDF_VIEWERREF_GetPrintPageRangeElement(FPDF_PAGERANGE pagerange, size_t index);
1166 
1167 // Function: FPDF_VIEWERREF_GetDuplex
1168 //          Returns the paper handling option to be used when printing from
1169 //          the print dialog.
1170 // Parameters:
1171 //          document    -   Handle to the loaded document.
1172 // Return value:
1173 //          The paper handling option to be used when printing.
1174 FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV
1175 FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document);
1176 
1177 // Function: FPDF_VIEWERREF_GetName
1178 //          Gets the contents for a viewer ref, with a given key. The value must
1179 //          be of type "name".
1180 // Parameters:
1181 //          document    -   Handle to the loaded document.
1182 //          key         -   Name of the key in the viewer pref dictionary,
1183 //                          encoded in UTF-8.
1184 //          buffer      -   A string to write the contents of the key to.
1185 //          length      -   Length of the buffer.
1186 // Return value:
1187 //          The number of bytes in the contents, including the NULL terminator.
1188 //          Thus if the return value is 0, then that indicates an error, such
1189 //          as when |document| is invalid or |buffer| is NULL. If |length| is
1190 //          less than the returned length, or |buffer| is NULL, |buffer| will
1191 //          not be modified.
1192 FPDF_EXPORT unsigned long FPDF_CALLCONV
1193 FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
1194                        FPDF_BYTESTRING key,
1195                        char* buffer,
1196                        unsigned long length);
1197 
1198 // Function: FPDF_CountNamedDests
1199 //          Get the count of named destinations in the PDF document.
1200 // Parameters:
1201 //          document    -   Handle to a document
1202 // Return value:
1203 //          The count of named destinations.
1204 FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV
1205 FPDF_CountNamedDests(FPDF_DOCUMENT document);
1206 
1207 // Function: FPDF_GetNamedDestByName
1208 //          Get a the destination handle for the given name.
1209 // Parameters:
1210 //          document    -   Handle to the loaded document.
1211 //          name        -   The name of a destination.
1212 // Return value:
1213 //          The handle to the destination.
1214 FPDF_EXPORT FPDF_DEST FPDF_CALLCONV
1215 FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name);
1216 
1217 // Function: FPDF_GetNamedDest
1218 //          Get the named destination by index.
1219 // Parameters:
1220 //          document        -   Handle to a document
1221 //          index           -   The index of a named destination.
1222 //          buffer          -   The buffer to store the destination name,
1223 //                              used as wchar_t*.
1224 //          buflen [in/out] -   Size of the buffer in bytes on input,
1225 //                              length of the result in bytes on output
1226 //                              or -1 if the buffer is too small.
1227 // Return value:
1228 //          The destination handle for a given index, or NULL if there is no
1229 //          named destination corresponding to |index|.
1230 // Comments:
1231 //          Call this function twice to get the name of the named destination:
1232 //            1) First time pass in |buffer| as NULL and get buflen.
1233 //            2) Second time pass in allocated |buffer| and buflen to retrieve
1234 //               |buffer|, which should be used as wchar_t*.
1235 //
1236 //         If buflen is not sufficiently large, it will be set to -1 upon
1237 //         return.
1238 FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document,
1239                                                       int index,
1240                                                       void* buffer,
1241                                                       long* buflen);
1242 
1243 #ifdef PDF_ENABLE_V8
1244 // Function: FPDF_GetRecommendedV8Flags
1245 //          Returns a space-separated string of command line flags that are
1246 //          recommended to be passed into V8 via V8::SetFlagsFromString()
1247 //          prior to initializing the PDFium library.
1248 // Parameters:
1249 //          None.
1250 // Return value:
1251 //          NUL-terminated string of the form "--flag1 --flag2".
1252 //          The caller must not attempt to modify or free the result.
1253 FPDF_EXPORT const char* FPDF_CALLCONV FPDF_GetRecommendedV8Flags();
1254 #endif  // PDF_ENABLE_V8
1255 
1256 #ifdef PDF_ENABLE_XFA
1257 // Function: FPDF_BStr_Init
1258 //          Helper function to initialize a FPDF_BSTR.
1259 FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* bstr);
1260 
1261 // Function: FPDF_BStr_Set
1262 //          Helper function to copy string data into the FPDF_BSTR.
1263 FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* bstr,
1264                                                     const char* cstr,
1265                                                     int length);
1266 
1267 // Function: FPDF_BStr_Clear
1268 //          Helper function to clear a FPDF_BSTR.
1269 FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* bstr);
1270 #endif  // PDF_ENABLE_XFA
1271 
1272 #ifdef __cplusplus
1273 }
1274 #endif
1275 
1276 #endif  // PUBLIC_FPDFVIEW_H_
1277