PapersDocument.Document.factory_get_document_for_fd
Description: Reference for PapersDocument.Document.factory_get_document_for_fd

### Function

# PapersDocument Documentfactory_get_document_for_fd

since: 42.0

#### Declaration [src]

    PpsDocument*
    pps_document_factory_get_document_for_fd (
      int fd,
      const char* mime_type,
      PpsDocumentLoadFlags flags,
      GError** error
    )

#### Description [src]

Synchronously creates a `PpsDocument` for the document from `fd` using the backend for loading documents of type `mime_type`; or, if the backend does not support loading from file descriptors, or an error occurred on opening the document, returns `NULL` and fills in `error`. If the document is encrypted, it is returned but also `error` is set to `PPS_DOCUMENT_ERROR_ENCRYPTED`.

If the mime type cannot be inferred from the file descriptor, and `mime_type` is `NULL`, an error is returned.

Note that this function takes ownership of `fd`; you must not ever operate on it again. It will be closed automatically if the document is destroyed, or if this function returns `NULL`.

Available since: 42.0

#### Parameters

`fd`

  Type: `int`

  A file descriptor.

`mime_type`

  Type: `const char*`

  The mime type.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`flags`

  Type: `PpsDocumentLoadFlags`

  Flags from `PpsDocumentLoadFlags`.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `PpsDocument`

A new `PpsDocument`, or `NULL`.

The caller of the function takes ownership of the data, and is responsible for freeing it.