NetSurf
save_pdf.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 John Tytgat <joty@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/** \file
20 * Export a content as a PDF file (implementation).
21 */
22
23#include "utils/config.h"
24#ifdef WITH_PDF_EXPORT
25
26#include <stdbool.h>
27#include "oslib/osfile.h"
28
29#include "utils/log.h"
30#include "utils/config.h"
31#include "desktop/print.h"
32#include "desktop/save_pdf/font_haru.h"
33#include "desktop/save_pdf/pdf_plotters.h"
34
35#include "riscos/save_pdf.h"
36
37/**
38 * Export a content as a PDF file.
39 *
40 * \param h content to export
41 * \param path path to save PDF as
42 * \return true on success, false on error and error reported
43 */
44bool save_as_pdf(hlcache_handle *h, const char *path)
45{
46 struct print_settings *psettings;
47
49 if (psettings == NULL)
50 return false;
51
52 if (!print_basic_run(h, &pdf_printer, psettings))
53 return false;
54
55 xosfile_set_type(path, 0xadf);
56
57 return true;
58}
59
60#endif
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.
Definition: print.c:254
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 clea...
Definition: print.c:64
Conception: Generalized output-in-pages.
@ PRINT_DEFAULT
Definition: print.h:45
const struct printer pdf_printer
const struct font_functions haru_nsfont
High-level cache handle.
Definition: hlcache.c:66
Settings for a print - filled in by print_make_settings or 'manually' by the caller.
Definition: print.h:50
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821