NetSurf
Macros | Functions | Variables
print.c File Reference

Implementation of paginated output. More...

#include "utils/config.h"
#include <assert.h>
#include <string.h>
#include <dom/dom.h>
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/talloc.h"
#include "netsurf/content.h"
#include "netsurf/plotters.h"
#include "content/hlcache.h"
#include "css/utils.h"
#include "html/box.h"
#include "desktop/print.h"
#include "desktop/printer.h"
Include dependency graph for print.c:

Go to the source code of this file.

Macros

#define DEFAULT_PAGE_WIDTH   595
 
#define DEFAULT_PAGE_HEIGHT   840
 
#define DEFAULT_COPIES   1
 

Functions

bool print_basic_run (hlcache_handle *content, const struct printer *printer, struct print_settings *settings)
 This function calls print setup, prints page after page until the whole content is printed calls cleaning up afterwise. More...
 
static struct hlcache_handleprint_init (struct hlcache_handle *content, struct print_settings *settings)
 The content passed to the function is duplicated with its boxes, font measuring functions are being set. More...
 
static bool print_apply_settings (hlcache_handle *content, struct print_settings *settings)
 The content is resized to fit page width. More...
 
bool print_set_up (hlcache_handle *content, const struct printer *printer, struct print_settings *settings, double *height)
 This function prepares the content to be printed. More...
 
bool print_draw_next_page (const struct printer *printer, struct print_settings *settings)
 This function draws one page, beginning with the height offset of done_height. More...
 
bool print_cleanup (hlcache_handle *content, const struct printer *printer, struct print_settings *settings)
 Memory allocated during printing is being freed here. More...
 
struct print_settingsprint_make_settings (print_configuration configuration, const char *filename, const struct gui_layout_table *font_func)
 Generates one of the predefined print settings sets. More...
 

Variables

static float page_content_width
 
static float page_content_height
 
static struct hlcache_handleprinted_content
 
static float done_height
 
bool html_redraw_printing = false
 
int html_redraw_printing_border = 0
 
int html_redraw_printing_top_cropped = 0
 

Detailed Description

Implementation of paginated output.

Definition in file print.c.

Macro Definition Documentation

◆ DEFAULT_COPIES

#define DEFAULT_COPIES   1

Definition at line 45 of file print.c.

◆ DEFAULT_PAGE_HEIGHT

#define DEFAULT_PAGE_HEIGHT   840

Definition at line 44 of file print.c.

◆ DEFAULT_PAGE_WIDTH

#define DEFAULT_PAGE_WIDTH   595

Definition at line 43 of file print.c.

Function Documentation

◆ print_apply_settings()

static bool print_apply_settings ( hlcache_handle content,
struct print_settings settings 
)
static

The content is resized to fit page width.

Parameters
contentThe content to be printed
settingsThe settings for printing to use
Returns
true if successful, false otherwise

Definition at line 112 of file print.c.

References content_get_height(), content_get_width(), content_reformat(), MARGINBOTTOM, MARGINLEFT, MARGINRIGHT, print_settings::margins, MARGINTOP, NSLOG, page_content_height, page_content_width, print_settings::page_height, print_settings::page_width, print_settings::scale, and settings.

Referenced by print_set_up().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_basic_run()

bool print_basic_run ( hlcache_handle content,
const struct printer printer,
struct print_settings settings 
)

This function calls print setup, prints page after page until the whole content is printed calls cleaning up afterwise.

Parameters
contentThe content to be printed
printerThe printer interface for the printer to be used
settingsThe settings for printing to use
Returns
true if successful, false otherwise

Definition at line 64 of file print.c.

References content_get_height(), done_height, print_cleanup(), print_draw_next_page(), print_set_up(), printed_content, and settings.

Referenced by pdf_button_clicked_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_cleanup()

bool print_cleanup ( hlcache_handle content,
const struct printer printer,
struct print_settings settings 
)

Memory allocated during printing is being freed here.

Parameters
contentThe original content
printerThe printer interface for the printer to be used
settingsThe print settings to use.
Returns
true if successful, false otherwise

Definition at line 228 of file print.c.

References hlcache_handle_release(), html_redraw_printing, print_settings::output, printer::print_end, printed_content, and settings.

Referenced by ami_print_cont(), gtk_print_signal_end_print(), and print_basic_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_draw_next_page()

bool print_draw_next_page ( const struct printer printer,
struct print_settings settings 
)

This function draws one page, beginning with the height offset of done_height.

Parameters
printerThe printer interface for the printer to be used
settingsThe settings for printing to use
Returns
true if successful, false otherwise

Definition at line 176 of file print.c.

References content_redraw_data::background_colour, clip(), content_redraw(), done_height, content_redraw_data::height, html_redraw_printing, html_redraw_printing_border, html_redraw_printing_top_cropped, redraw_context::interactive, nsoption_bool, page_content_height, page_content_width, printer::plotter, printer::print_next_page, printed_content, print_settings::priv, content_redraw_data::repeat_x, content_redraw_data::repeat_y, print_settings::scale, content_redraw_data::scale, settings, content_redraw_data::width, content_redraw_data::x, and content_redraw_data::y.

Referenced by ami_print_cont(), gtk_print_signal_draw_page(), and print_basic_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_init()

static struct hlcache_handle * print_init ( struct hlcache_handle content,
struct print_settings settings 
)
static

The content passed to the function is duplicated with its boxes, font measuring functions are being set.

Parameters
contentThe content to be printed
settingsThe settings for printing to use
Returns
true if successful, false otherwise

Definition at line 94 of file print.c.

References hlcache_handle_clone(), and printed_content.

Referenced by print_set_up().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_make_settings()

struct print_settings * print_make_settings ( print_configuration  configuration,
const char *  filename,
const struct gui_layout_table font_func 
)

Generates one of the predefined print settings sets.

Setup print settings for print render operation.

Parameters
configurationthe requested configuration
filenamethe filename or NULL
font_funcfont handling functions
Returns
print_settings in case if successful, NULL if unknown configuration or lack of memory.

Definition at line 254 of file print.c.

References print_settings::copies, DEFAULT_COPIES, DEFAULT_EXPORT_SCALE, DEFAULT_MARGIN_BOTTOM_MM, DEFAULT_MARGIN_LEFT_MM, DEFAULT_MARGIN_RIGHT_MM, DEFAULT_MARGIN_TOP_MM, DEFAULT_PAGE_HEIGHT, DEFAULT_PAGE_WIDTH, print_settings::font_func, MARGINBOTTOM, MARGINLEFT, MARGINRIGHT, print_settings::margins, MARGINTOP, nsoption_int, print_settings::output, print_settings::page_height, print_settings::page_width, PRINT_DEFAULT, PRINT_OPTIONS, print_settings::scale, and settings.

Referenced by ami_print(), pdf_button_clicked_cb(), and print_button_clicked_cb().

Here is the caller graph for this function:

◆ print_set_up()

bool print_set_up ( hlcache_handle content,
const struct printer printer,
struct print_settings settings,
double *  height 
)

This function prepares the content to be printed.

The current browser content is duplicated and resized, printer initialization is called.

Parameters
contentThe content to be printed
printerThe printer interface for the printer to be used
settingsThe settings for printing to use
heightupdated to the height of the printed content
Returns
true if successful, false otherwise

Definition at line 148 of file print.c.

References content_get_height(), done_height, height, print_apply_settings(), printer::print_begin, print_init(), printed_content, and settings.

Referenced by ami_print(), gtk_print_signal_begin_print(), and print_basic_run().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ done_height

float done_height
static

Definition at line 49 of file print.c.

Referenced by print_basic_run(), print_draw_next_page(), and print_set_up().

◆ html_redraw_printing

bool html_redraw_printing = false

◆ html_redraw_printing_border

int html_redraw_printing_border = 0

Definition at line 52 of file print.c.

Referenced by html_redraw_box(), and print_draw_next_page().

◆ html_redraw_printing_top_cropped

int html_redraw_printing_top_cropped = 0

Definition at line 53 of file print.c.

Referenced by html_redraw_box(), and print_draw_next_page().

◆ page_content_height

float page_content_height
static

Definition at line 47 of file print.c.

Referenced by print_apply_settings(), and print_draw_next_page().

◆ page_content_width

float page_content_width
static

Definition at line 47 of file print.c.

Referenced by print_apply_settings(), and print_draw_next_page().

◆ printed_content

struct hlcache_handle* printed_content
static