Print: libportal Reference Manual

## Print Print — send documents to a printer |

## Functions

void | xdp_portal_prepare_print ()
GVariant * | xdp_portal_prepare_print_finish ()
void | xdp_portal_print_file ()
gboolean | xdp_portal_print_file_finish ()

## Description

These functions let applications print.

The underlying portal is org.freedesktop.portal.Print.

## Functions

### xdp_portal_prepare_print ()

    void
    xdp_portal_prepare_print (XdpPortal *portal,
                              XdpParent *parent,
                              const char *title,
                              gboolean modal,
                              GVariant *settings,
                              GVariant *page_setup,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer data);

Presents a print dialog to the user and returns print settings and page setup.

When the request is done, `callback` will be called. You can then call `xdp_portal_prepare_print_finish()` to get the results.

#### Parameters

portal | a XdpPortal |
parent | parent window information. | [nullable]
title | tile for the print dialog |
modal | whether the dialog should be modal |
settings | Serialized print settings. | [nullable]
page_setup | Serialized page setup. | [nullable]
cancellable | optional GCancellable. | [nullable]
callback | a callback to call when the request is done. | [scope async]
data | data to pass to `callback` . | [closure]

### xdp_portal_prepare_print_finish ()

    GVariant *
    xdp_portal_prepare_print_finish (XdpPortal *portal,
                                     GAsyncResult *result,
                                     GError **error);

Finishes the prepare-print request, and returns GVariant dictionary with the following information:

- settings `a{sv}`: print settings as set up by the user in the print dialog

- page-setup `a{sv}: page setup as set up by the user in the print dialog

- token u: a token that can by used in a `xdp_portal_print_file()` call to avoid the print dialog

#### Parameters

portal | a XdpPortal |
result | a GAsyncResult |
error | return location for an error |

#### Returns

a GVariant dictionary with print information.

[transfer full]

### xdp_portal_print_file ()

    void
    xdp_portal_print_file (XdpPortal *portal,
                           XdpParent *parent,
                           const char *title,
                           gboolean modal,
                           guint token,
                           const char *file,
                           GCancellable *cancellable,
                           GAsyncReadyCallback callback,
                           gpointer data);

Prints a file.

If a valid token is present in the `options` , then this call will print with the settings from the Print call that the token refers to. If no token is present, then a print dialog will be presented to the user.

When the request is done, `callback` will be called. You can then call `xdp_portal_print_file_finish()` to get the results.

#### Parameters

portal | a XdpPortal |
parent | parent window information. | [nullable]
title | tile for the print dialog |
modal | whether the dialog should be modal |
token | token that was returned by a previous `xdp_portal_prepare_print()` call, or 0 |
file | path of the document to print |
cancellable | optional GCancellable. | [nullable]
callback | a callback to call when the request is done. | [scope async]
data | data to pass to `callback` . | [closure]

### xdp_portal_print_file_finish ()

    gboolean
    xdp_portal_print_file_finish (XdpPortal *portal,
                                  GAsyncResult *result,
                                  GError **error);

Finishes the print request.

#### Parameters

portal | a XdpPortal |
result | a GAsyncResult |
error | return location for an error |

#### Returns

`TRUE` if the request was successful

## Types and Values