## PopplerAttachment PopplerAttachment — Attachments |

## Functions

gboolean | (*PopplerAttachmentSaveFunc) ()
const GString * | poppler_attachment_get_checksum ()
GDateTime * | poppler_attachment_get_ctime ()
const gchar * | poppler_attachment_get_description ()
GDateTime * | poppler_attachment_get_mtime ()
const gchar * | poppler_attachment_get_name ()
gsize | poppler_attachment_get_size ()
gboolean | poppler_attachment_save ()
gboolean | poppler_attachment_save_to_fd ()
gboolean | poppler_attachment_save_to_callback ()

## Types and Values

| PopplerAttachment

## Object Hierarchy

        GObject
        ╰── PopplerAttachment

## Includes

    #include <poppler.h>

## Description

## Functions

### PopplerAttachmentSaveFunc ()

    gboolean
    (*PopplerAttachmentSaveFunc) (const gchar *buf,
                                  gsize count,
                                  gpointer data,
                                  GError **error);

Specifies the type of the function passed to `poppler_attachment_save_to_callback()`. It is called once for each block of bytes that is "written" by `poppler_attachment_save_to_callback()`. If successful it should return `TRUE`. If an error occurs it should set `error` and return `FALSE`, in which case `poppler_attachment_save_to_callback()` will fail with the same error.

#### Parameters

buf | buffer containing bytes to be written. | [array length=count][element-type guint8]
count | number of bytes in `buf` . |
data | user data passed to `poppler_attachment_save_to_callback()`. | [closure]
error | GError to set on error, or `NULL` |

#### Returns

`TRUE` if successful, `FALSE` (with `error` set) if failed.

### poppler_attachment_get_checksum ()

    const GString *
    poppler_attachment_get_checksum (PopplerAttachment *attachment);

#### Parameters

attachment | a PopplerAttachment |

#### Returns

The attachment's checksum.

Since: 20.09.0

### poppler_attachment_get_ctime ()

    GDateTime *
    poppler_attachment_get_ctime (PopplerAttachment *attachment);

#### Parameters

attachment | a PopplerAttachment |

#### Returns

The attachment's creation date and time as a GDateTime, or `NULL` if the creation date and time is not available.

[transfer none][nullable]

Since: 20.09.0

### poppler_attachment_get_description ()

    const gchar *
    poppler_attachment_get_description (PopplerAttachment *attachment);

#### Parameters

attachment | a PopplerAttachment |

#### Returns

The attachment's descriptive text.

Since: 20.09.0

### poppler_attachment_get_mtime ()

    GDateTime *
    poppler_attachment_get_mtime (PopplerAttachment *attachment);

#### Parameters

attachment | a PopplerAttachment |

#### Returns

The attachment's modification date and time as a GDateTime, or `NULL` if the modification date and time is not available.

[transfer none][nullable]

Since: 20.09.0

### poppler_attachment_get_name ()

    const gchar *
    poppler_attachment_get_name (PopplerAttachment *attachment);

#### Parameters

attachment | a PopplerAttachment |

#### Returns

The attachment's name.

Since: 20.09.0

### poppler_attachment_get_size ()

    gsize
    poppler_attachment_get_size (PopplerAttachment *attachment);

#### Parameters

attachment | a PopplerAttachment |

#### Returns

The attachment's size.

Since: 20.09.0

### poppler_attachment_save ()

    gboolean
    poppler_attachment_save (PopplerAttachment *attachment,
                             const char *filename,
                             GError **error);

Saves `attachment` to a file indicated by `filename` . If `error` is set, `FALSE` will be returned. Possible errors include those in the G_FILE_ERROR domain and whatever the save function generates.

#### Parameters

attachment | A PopplerAttachment. |
filename | name of file to save |
error | return location for error, or `NULL`. | [allow-none]

#### Returns

`TRUE`, if the file successfully saved

### poppler_attachment_save_to_fd ()

    gboolean
    poppler_attachment_save_to_fd (PopplerAttachment *attachment,
                                   int fd,
                                   GError **error);

Saves `attachment` to a file referred to by `fd` . If `error` is set, `FALSE` will be returned. Possible errors include those in the G_FILE_ERROR domain and whatever the save function generates. Note that this function takes ownership of `fd` ; you must not operate on it again, nor close it.

#### Parameters

attachment | A PopplerAttachment. |
fd | a valid file descriptor open for writing |
error | return location for error, or `NULL`. | [allow-none]

#### Returns

`TRUE`, if the file successfully saved

Since: 21.12.0

### poppler_attachment_save_to_callback ()

    gboolean
    poppler_attachment_save_to_callback (PopplerAttachment *attachment,
                                         PopplerAttachmentSaveFunc save_func,
                                         gpointer user_data,
                                         GError **error);

Saves `attachment` by feeding the produced data to `save_func` . Can be used when you want to store the attachment to something other than a file, such as an in-memory buffer or a socket. If `error` is set, `FALSE` will be returned. Possible errors include those in the G_FILE_ERROR domain and whatever the save function generates.

#### Parameters

attachment | A PopplerAttachment. |
save_func | a function that is called to save each block of data that the save routine generates. | [scope call]
user_data | user data to pass to the save function. |
error | return location for error, or `NULL`. | [allow-none]

#### Returns

`TRUE`, if the save successfully completed

## Types and Values

### PopplerAttachment

    typedef struct {
        gchar *name;
        gchar *description;
        gsize size;

        /* GTime is deprecated, but is part of our ABI here (see #715, #765). */
        GTime mtime;
        GTime ctime;

        GString *checksum;
    } PopplerAttachment;

Since 25.06 this type supports g_autoptr

#### Members

gchar *`name`; | The filename. Deprecated in poppler 20.09.0. Use `poppler_attachment_get_name()` instead. |
gchar *`description`; | Descriptive text. Deprecated in poppler 20.09.0. Use `poppler_attachment_get_description()` instead. |
gsize `size`; | The size of the file. Deprecated in poppler 20.09.0. Use `poppler_attachment_get_size()` instead. |
GTime `mtime`; | The date and time when the file was last modified. Deprecated in poppler 20.09.0. Use `poppler_attachment_get_mtime()` instead. |
GTime `ctime`; | The date and time when the file was created. Deprecated in poppler 20.09.0. Use `poppler_attachment_get_ctime()` instead. |
GString *`checksum`; | A 16-byte checksum of the file. Deprecated in poppler 20.09.0. Use `poppler_attachment_get_checksum()` instead. |