paginate


Description:

public bool paginate (PrintContext context)

Paginate the document associated with the this.

In order to support non-blocking pagination, document is paginated in small chunks. Each time [[email protected]] is invoked, a chunk of the document is paginated. To paginate the entire document, [[email protected]] must be invoked multiple times. It returns true if the document has been completely paginated, otherwise it returns false.

This method has been designed to be invoked in the handler of the [[email protected]:GtkSourcePrintCompositor:paginate ] signal, as shown in the following example:

```c // Signal handler for the GtkPrintOperation:GtkSourcePrintCompositor:paginate signal

static gboolean paginate (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data) { GtkSourcePrintCompositor *compositor;

compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);

if (gtk_source_print_compositor_paginate (compositor, context)) { gint n_pages;

n_pages = gtk_source_print_compositor_get_n_pages (compositor); gtk_print_operation_set_n_pages (operation, n_pages);

return TRUE; }

return FALSE; } ```

If you don't need to do pagination in chunks, you can simply do it all in the [[email protected]: GtkSourcePrintCompositor:begin-print] handler, and set the number of pages from there, like in the following example:

```c // Signal handler for the GtkPrintOperation:GtkSourcePrintCompositor:begin-print signal

static void begin_print (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data) { GtkSourcePrintCompositor *compositor; gint n_pages;

compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);

while (!gtk_source_print_compositor_paginate (compositor, context));

n_pages = gtk_source_print_compositor_get_n_pages (compositor); gtk_print_operation_set_n_pages (operation, n_pages); } ```

Parameters:

this

a PrintCompositor.

context

the PrintContext whose parameters (e.g. paper size, print margins, etc.) are used by the the this to paginate the document.

Returns:

true if the document has been completely paginated, false otherwise.




2022 vala-language.org