## PopplerDocument

PopplerDocument — Information about a document

## Synopsis

    enum                PopplerPageLayout;
    enum                PopplerPageMode;
    enum                PopplerFontType;
    enum                PopplerViewerPreferences;
    enum                PopplerPermissions;
    PopplerDocument *   poppler_document_new_from_file      (const char *uri,
                                                             const char *password,
                                                             GError **error);
    PopplerDocument *   poppler_document_new_from_data      (char *data,
                                                             int length,
                                                             const char *password,
                                                             GError **error);
    gboolean            poppler_document_save               (PopplerDocument *document,
                                                             const char *uri,
                                                             GError **error);
    int                 poppler_document_get_n_pages        (PopplerDocument *document);
    PopplerPage *       poppler_document_get_page           (PopplerDocument *document,
                                                             int index);
    PopplerPage *       poppler_document_get_page_by_label  (PopplerDocument *document,
                                                             const char *label);
    PopplerDest *       poppler_document_find_dest          (PopplerDocument *document,
                                                             const gchar *link_name);
    gboolean            poppler_document_has_attachments    (PopplerDocument *document);
    GList *             poppler_document_get_attachments    (PopplerDocument *document);
    PopplerFormField *  poppler_document_get_form_field     (PopplerDocument *document,
                                                             gint id);
    GType               poppler_index_iter_get_type         (void);
    PopplerIndexIter *  poppler_index_iter_new              (PopplerDocument *document);
    PopplerIndexIter *  poppler_index_iter_copy             (PopplerIndexIter *iter);
    void                poppler_index_iter_free             (PopplerIndexIter *iter);
    PopplerIndexIter *  poppler_index_iter_get_child        (PopplerIndexIter *parent);
    gboolean            poppler_index_iter_is_open          (PopplerIndexIter *iter);
    PopplerAction *     poppler_index_iter_get_action       (PopplerIndexIter *iter);
    gboolean            poppler_index_iter_next             (PopplerIndexIter *iter);
    PopplerFontInfo *   poppler_font_info_new               (PopplerDocument *document);
    gboolean            poppler_font_info_scan              (PopplerFontInfo *font_info,
                                                             int n_pages,
                                                             PopplerFontsIter **iter);
    void                poppler_font_info_free              (PopplerFontInfo *font_info);
    GType               poppler_fonts_iter_get_type         (void);
    PopplerFontsIter *  poppler_fonts_iter_copy             (PopplerFontsIter *iter);
    void                poppler_fonts_iter_free             (PopplerFontsIter *iter);
    const char *        poppler_fonts_iter_get_name         (PopplerFontsIter *iter);
    const char *        poppler_fonts_iter_get_full_name    (PopplerFontsIter *iter);
    PopplerFontType     poppler_fonts_iter_get_font_type    (PopplerFontsIter *iter);
    gboolean            poppler_fonts_iter_is_embedded      (PopplerFontsIter *iter);
    gboolean            poppler_fonts_iter_is_subset        (PopplerFontsIter *iter);
    gboolean            poppler_fonts_iter_next             (PopplerFontsIter *iter);
    PopplerPSFile *     poppler_ps_file_new                 (PopplerDocument *document,
                                                             const char *filename,
                                                             int first_page,
                                                             int n_pages);
    void                poppler_ps_file_set_paper_size      (PopplerPSFile *ps_file,
                                                             double width,
                                                             double height);
    void                poppler_ps_file_set_duplex          (PopplerPSFile *ps_file,
                                                             gboolean duplex);
    void                poppler_ps_file_free                (PopplerPSFile *ps_file);

## Description

The PopplerDocument is an object used to refer to a main document.

## Details

### enum PopplerPageLayout

    typedef enum
    {
      POPPLER_PAGE_LAYOUT_UNSET,
      POPPLER_PAGE_LAYOUT_SINGLE_PAGE,
      POPPLER_PAGE_LAYOUT_ONE_COLUMN,
      POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT,
      POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT,
      POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT,
      POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT
    } PopplerPageLayout;

### enum PopplerPageMode

    typedef enum
    {
      POPPLER_PAGE_MODE_UNSET,
      POPPLER_PAGE_MODE_NONE,
      POPPLER_PAGE_MODE_USE_OUTLINES,
      POPPLER_PAGE_MODE_USE_THUMBS,
      POPPLER_PAGE_MODE_FULL_SCREEN,
      POPPLER_PAGE_MODE_USE_OC,
      POPPLER_PAGE_MODE_USE_ATTACHMENTS
    } PopplerPageMode;

### enum PopplerFontType

    typedef enum
    {
      POPPLER_FONT_TYPE_UNKNOWN,
      POPPLER_FONT_TYPE_TYPE1,
      POPPLER_FONT_TYPE_TYPE1C,
      POPPLER_FONT_TYPE_TYPE1COT,
      POPPLER_FONT_TYPE_TYPE3,
      POPPLER_FONT_TYPE_TRUETYPE,
      POPPLER_FONT_TYPE_TRUETYPEOT,
      POPPLER_FONT_TYPE_CID_TYPE0,
      POPPLER_FONT_TYPE_CID_TYPE0C,
      POPPLER_FONT_TYPE_CID_TYPE0COT,
      POPPLER_FONT_TYPE_CID_TYPE2,
      POPPLER_FONT_TYPE_CID_TYPE2OT
    } PopplerFontType;

### enum PopplerViewerPreferences

    typedef enum /*< flags >*/
    {
      POPPLER_VIEWER_PREFERENCES_UNSET = 0,
      POPPLER_VIEWER_PREFERENCES_HIDE_TOOLBAR = 1 << 0,
      POPPLER_VIEWER_PREFERENCES_HIDE_MENUBAR = 1 << 1,
      POPPLER_VIEWER_PREFERENCES_HIDE_WINDOWUI = 1 << 2,
      POPPLER_VIEWER_PREFERENCES_FIT_WINDOW = 1 << 3,
      POPPLER_VIEWER_PREFERENCES_CENTER_WINDOW = 1 << 4,
      POPPLER_VIEWER_PREFERENCES_DISPLAY_DOC_TITLE = 1 << 5,
      POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL = 1 << 6
    } PopplerViewerPreferences;

### enum PopplerPermissions

    typedef enum /*< flags >*/
    {
      POPPLER_PERMISSIONS_OK_TO_PRINT = 1 << 0,
      POPPLER_PERMISSIONS_OK_TO_MODIFY = 1 << 1,
      POPPLER_PERMISSIONS_OK_TO_COPY = 1 << 2,
      POPPLER_PERMISSIONS_OK_TO_ADD_NOTES = 1 << 3,
      POPPLER_PERMISSIONS_OK_TO_FILL_FORM = 1 << 4,
      POPPLER_PERMISSIONS_FULL = (POPPLER_PERMISSIONS_OK_TO_PRINT | POPPLER_PERMISSIONS_OK_TO_MODIFY | POPPLER_PERMISSIONS_OK_TO_COPY | POPPLER_PERMISSIONS_OK_TO_ADD_NOTES | POPPLER_PERMISSIONS_OK_TO_FILL_FORM)

    } PopplerPermissions;

### poppler_document_new_from_file ()

    PopplerDocument *   poppler_document_new_from_file      (const char *uri,
                                                             const char *password,
                                                             GError **error);

Creates a new PopplerDocument. If `NULL` is returned, then `error` will be set. Possible errors include those in the POPPLER_ERROR and G_FILE_ERROR domains.

`uri` : | uri of the file to load
`password` : | password to unlock the file with, or `NULL`
`error` : | Return location for an error, or `NULL`
Returns : | A newly created PopplerDocument, or `NULL`

### poppler_document_new_from_data ()

    PopplerDocument *   poppler_document_new_from_data      (char *data,
                                                             int length,
                                                             const char *password,
                                                             GError **error);

Creates a new PopplerDocument. If `NULL` is returned, then `error` will be set. Possible errors include those in the POPPLER_ERROR and G_FILE_ERROR domains.

`data` : | the pdf data contained in a char array
`length` : | the length of data
`password` : | password to unlock the file with, or `NULL`
`error` : | Return location for an error, or `NULL`
Returns : | A newly created PopplerDocument, or `NULL`

### poppler_document_save ()

    gboolean            poppler_document_save               (PopplerDocument *document,
                                                             const char *uri,
                                                             GError **error);

Saves `document`. Any change made in the document such as form fields filled by the user will be saved. If `error` is set, `FALSE` will be returned. Possible errors include those in the G_FILE_ERROR domain.

`document` : | a PopplerDocument
`uri` : | uri of file to save
`error` : | return location for an error, or `NULL`
Returns : | `TRUE`, if the document was successfully saved

### poppler_document_get_n_pages ()

    int                 poppler_document_get_n_pages        (PopplerDocument *document);

Returns the number of pages in a loaded document.

`document` : | A PopplerDocument
Returns : | Number of pages

### poppler_document_get_page ()

    PopplerPage *       poppler_document_get_page           (PopplerDocument *document,
                                                             int index);

Returns the PopplerPage indexed at `index`. This object is owned by the caller.

PopplerPages are indexed starting at 0.

`document` : | A PopplerDocument
`index` : | a page index
Returns : | The PopplerPage at `index`

### poppler_document_get_page_by_label ()

    PopplerPage *       poppler_document_get_page_by_label  (PopplerDocument *document,
                                                             const char *label);

Returns the PopplerPage reference by `label`. This object is owned by the caller. `label` is a human-readable string representation of the page number, and can be document specific. Typically, it is a value such as "iii" or "3".

By default, "1" refers to the first page.

`document` : | A PopplerDocument
`label` : | a page label
Returns : | The PopplerPage referenced by `label`

### poppler_document_find_dest ()

    PopplerDest *       poppler_document_find_dest          (PopplerDocument *document,
                                                             const gchar *link_name);

Finds named destination `link_name` in `document`

`document` : | A PopplerDocument
`link_name` : | a named destination
Returns : | The PopplerDest destination or `NULL` if `link_name` is not a destination. Returned value must be freed with poppler_dest_free

### poppler_document_has_attachments ()

    gboolean            poppler_document_has_attachments    (PopplerDocument *document);

Returns `TRUE` of `document` has any attachments.

`document` : | A PopplerDocument
Returns : | `TRUE`, if `document` has attachments.

### poppler_document_get_attachments ()

    GList *             poppler_document_get_attachments    (PopplerDocument *document);

Returns a GList containing PopplerAttachments. These attachments are unowned, and must be unreffed, and the list must be freed with `g_list_free()`.

`document` : | A PopplerDocument
Returns : | a list of available attachments.

### poppler_document_get_form_field ()

    PopplerFormField *  poppler_document_get_form_field     (PopplerDocument *document,
                                                             gint id);

Returns the PopplerFormField for the given `id`. It must be freed with `g_object_unref()`

`document` : | a PopplerDocument
`id` : | an id of a PopplerFormField
Returns : | a new PopplerFormField or NULL if not found

### poppler_index_iter_get_type ()

    GType               poppler_index_iter_get_type         (void);

Returns : |

### poppler_index_iter_new ()

    PopplerIndexIter *  poppler_index_iter_new              (PopplerDocument *document);

Returns the root PopplerIndexIter for `document`, or `NULL`. This must be freed with `poppler_index_iter_free()`.

Certain documents have an index associated with them. This index can be used to help the user navigate the document, and is similar to a table of contents. Each node in the index will contain a PopplerAction that can be displayed to the user — typically a POPPLER_ACTION_GOTO_DEST or a POPPLER_ACTION_URI.

Here is a simple example of some code that walks the full index:

    static void
    walk_index (PopplerIndexIter *iter)
    {
      do
        {
          /* Get the the action and do something with it */
          PopplerIndexIter *child = poppler_index_iter_get_child (iter);
          if (child)
            walk_index (child);
          poppler_index_iter_free (child);
        }
      while (poppler_index_iter_next (iter));
    }
    ...
    {
      iter = poppler_index_iter_new (document);
      walk_index (iter);
      poppler_index_iter_free (iter);
    }

`document` : | a PopplerDocument
Returns : | a new PopplerIndexIter

### poppler_index_iter_copy ()

    PopplerIndexIter *  poppler_index_iter_copy             (PopplerIndexIter *iter);

Creates a new PopplerIndexIter as a copy of `iter`. This must be freed with `poppler_index_iter_free()`.

`iter` : | a PopplerIndexIter
Returns : | a new PopplerIndexIter

### poppler_index_iter_free ()

    void                poppler_index_iter_free             (PopplerIndexIter *iter);

Frees `iter`.

`iter` : | a PopplerIndexIter

### poppler_index_iter_get_child ()

    PopplerIndexIter *  poppler_index_iter_get_child        (PopplerIndexIter *parent);

Returns a newly created child of `parent`, or `NULL` if the iter has no child. See `poppler_index_iter_new()` for more information on this function.

`parent` : | a PopplerIndexIter
Returns : | a new PopplerIndexIter

### poppler_index_iter_is_open ()

    gboolean            poppler_index_iter_is_open          (PopplerIndexIter *iter);

Returns whether this node should be expanded by default to the user. The document can provide a hint as to how the document's index should be expanded initially.

`iter` : | a PopplerIndexIter
Returns : | `TRUE`, if the document wants `iter` to be expanded

### poppler_index_iter_get_action ()

    PopplerAction *     poppler_index_iter_get_action       (PopplerIndexIter *iter);

Returns the PopplerAction associated with `iter`. It must be freed with `poppler_action_free()`.

`iter` : | a PopplerIndexIter
Returns : | a new PopplerAction

### poppler_index_iter_next ()

    gboolean            poppler_index_iter_next             (PopplerIndexIter *iter);

Sets `iter` to point to the next action at the current level, if valid. See `poppler_index_iter_new()` for more information.

`iter` : | a PopplerIndexIter
Returns : | `TRUE`, if `iter` was set to the next action

### poppler_font_info_new ()

    PopplerFontInfo *   poppler_font_info_new               (PopplerDocument *document);

`document` : |
Returns : |

### poppler_font_info_scan ()

    gboolean            poppler_font_info_scan              (PopplerFontInfo *font_info,
                                                             int n_pages,
                                                             PopplerFontsIter **iter);

`font_info` : |
`n_pages` : |
`iter` : |
Returns : |

### poppler_font_info_free ()

    void                poppler_font_info_free              (PopplerFontInfo *font_info);

`font_info` : |

### poppler_fonts_iter_get_type ()

    GType               poppler_fonts_iter_get_type         (void);

Returns : |

### poppler_fonts_iter_copy ()

    PopplerFontsIter *  poppler_fonts_iter_copy             (PopplerFontsIter *iter);

`iter` : |
Returns : |

### poppler_fonts_iter_free ()

    void                poppler_fonts_iter_free             (PopplerFontsIter *iter);

`iter` : |

### poppler_fonts_iter_get_name ()

    const char *        poppler_fonts_iter_get_name         (PopplerFontsIter *iter);

`iter` : |
Returns : |

### poppler_fonts_iter_get_full_name ()

    const char *        poppler_fonts_iter_get_full_name    (PopplerFontsIter *iter);

`iter` : |
Returns : |

### poppler_fonts_iter_get_font_type ()

    PopplerFontType     poppler_fonts_iter_get_font_type    (PopplerFontsIter *iter);

`iter` : |
Returns : |

### poppler_fonts_iter_is_embedded ()

    gboolean            poppler_fonts_iter_is_embedded      (PopplerFontsIter *iter);

`iter` : |
Returns : |

### poppler_fonts_iter_is_subset ()

    gboolean            poppler_fonts_iter_is_subset        (PopplerFontsIter *iter);

`iter` : |
Returns : |

### poppler_fonts_iter_next ()

    gboolean            poppler_fonts_iter_next             (PopplerFontsIter *iter);

`iter` : |
Returns : |

### poppler_ps_file_new ()

    PopplerPSFile *     poppler_ps_file_new                 (PopplerDocument *document,
                                                             const char *filename,
                                                             int first_page,
                                                             int n_pages);

Create a new postscript file to render to

`document` : | a PopplerDocument
`filename` : | the path of the output filename
`first_page` : | the first page to print
`n_pages` : | the number of pages to print
Returns : | a PopplerPSFile

### poppler_ps_file_set_paper_size ()

    void                poppler_ps_file_set_paper_size      (PopplerPSFile *ps_file,
                                                             double width,
                                                             double height);

Set the output paper size. These values will end up in the DocumentMedia, the BoundingBox DSC comments and other places in the generated PostScript.

`ps_file` : | a PopplerPSFile which was not yet printed to.
`width` : | the paper width in 1/72 inch
`height` : | the paper height in 1/72 inch

### poppler_ps_file_set_duplex ()

    void                poppler_ps_file_set_duplex          (PopplerPSFile *ps_file,
                                                             gboolean duplex);

Enable or disable Duplex printing.

`ps_file` : | a PopplerPSFile which was not yet printed to
`duplex` : | whether to force duplex printing (on printers which support this)

### poppler_ps_file_free ()

    void                poppler_ps_file_free                (PopplerPSFile *ps_file);

Frees `ps_file`

`ps_file` : | a PopplerPSFile