source: wkhtmltox/trunk/fuentes/src/lib/pdfsettings.hh @ 51

Last change on this file since 51 was 51, checked in by mabarracus, 4 years ago

wip

File size: 5.7 KB
Line 
1// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
2// vi:set ts=4 sts=4 sw=4 noet :
3//
4// Copyright 2010 wkhtmltopdf authors
5//
6// This file is part of wkhtmltopdf.
7//
8// wkhtmltopdf is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Lesser General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12//
13// wkhtmltopdf is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public License
19// along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
20
21#ifndef __PDFSETTINGS_HH__
22#define __PDFSETTINGS_HH__
23
24#include <QNetworkProxy>
25#include <QPrinter>
26#include <QString>
27#include <wkhtmltox/loadsettings.hh>
28#include <wkhtmltox/websettings.hh>
29
30#include <wkhtmltox/dllbegin.inc>
31namespace wkhtmltopdf {
32namespace settings {
33
34typedef QPair<qreal, QPrinter::Unit> UnitReal;
35
36/*! \brief Settings considering margins */
37struct DLL_PUBLIC Margin {
38        Margin();
39        //!Margin applied to the top of the page
40        UnitReal top;
41        //!Margin applied to the right of the page
42        UnitReal right;
43        //!Margin applied to the bottom of the page
44        UnitReal bottom;
45        //!Margin applied to the leftp of the page
46        UnitReal left;
47};
48
49/*! \brief Settings considering page size */
50struct DLL_PUBLIC Size {
51        Size();
52        //! What size paper should we use
53        QPrinter::PageSize pageSize;
54        //!Height of the page
55        UnitReal height;
56        //!Width of the page
57        UnitReal width;
58};
59
60/*! \brief Settings considering the table of content */
61struct DLL_PUBLIC TableOfContent {
62        TableOfContent();
63        //! Should we print dots between the name and the page number?
64        bool useDottedLines;
65        //! Name af the TOC
66        QString captionText;
67        //! Link from TOC to section headers
68        bool forwardLinks;
69        //! Link from section headers to TOC
70        bool backLinks;
71        //! How fare should we indent on every level
72        QString indentation;
73        //! Factor we should scale the font with on every level
74        float fontScale;
75};
76
77/*! \brief Class holding all user setting.
78    This class holds all the user settings, settings can be filled in by hand,
79    or with other methods.
80    \sa CommandLineParser::parse()
81*/
82struct DLL_PUBLIC PdfGlobal {
83        PdfGlobal();
84
85        //! Size related settings
86        Size size;
87
88        //! Be less verbose
89        bool quiet;
90
91        //! Should we use the graphics system
92        bool useGraphics;
93
94        //! Should relative links be resolved or kept as-is
95        bool resolveRelativeLinks;
96
97        //! Should we orientate in landscape or portrate
98        QPrinter::Orientation orientation;
99
100        //! Color or grayscale
101        QPrinter::ColorMode colorMode;
102
103        //! What overall resolution should we use
104        QPrinter::PrinterMode resolution;
105
106        //! What dpi should be used when printing
107        int dpi;
108
109        //! When pagenumbers are printed, apply this offset to them all
110        int pageOffset;
111
112        //! How many copies do we wan to print
113        int copies;
114
115        //! Should be print a whole copy before beginning the next
116        bool collate;
117
118        //! Should we generate an outline and put it into the pdf file
119        bool outline;
120
121        //! Maximal depth of the generated outline
122        int outlineDepth;
123
124        //! dump outline to this filename
125        QString dumpOutline;
126
127        //! The file where in to store the output
128        QString out;
129
130        QString documentTitle;
131
132        bool useCompression;
133
134        //! Margin related settings
135        Margin margin;
136
137        QString viewportSize;
138
139        int imageDPI;
140        int imageQuality;
141
142        LoadGlobal load;
143
144        QString get(const char * name);
145        bool set(const char * name, const QString & value);
146};
147
148/*! \brief Settings considering headers and footers */
149struct DLL_PUBLIC HeaderFooter {
150        HeaderFooter();
151        //! Size of the font used to render the text
152        int fontSize;
153        //! Name of font used to render text
154        QString fontName;
155        //! Text to render at the left
156        QString left;
157        //! Text to render at the right
158        QString right;
159        //! Text to render at the center
160        QString center;
161        //! Should a line seperate the header/footer and the document
162        bool line;
163        //! Url of the document the html document that should be used as a header/footer
164        QString htmlUrl;
165        //! Spacing
166        float spacing;
167};
168
169struct DLL_PUBLIC PdfObject {
170        PdfObject();
171        //! Settings regarding the TOC
172        TableOfContent toc;
173
174        QString page;
175
176        //! Header related settings
177        HeaderFooter header;
178
179        //! Header related settings
180        HeaderFooter footer;
181
182        //! Should external links be links in the PDF
183        bool useExternalLinks;
184
185        //! Should internal links be links in the PDF
186        bool useLocalLinks;
187
188        //! Replacements
189        QList< QPair<QString, QString> > replacements;
190
191        //! Convert forms on the pages into PDF forms
192        bool produceForms;
193
194        LoadPage load;
195
196        Web web;
197
198        bool includeInOutline;
199
200        bool pagesCount;
201
202        bool isTableOfContent;
203
204        QString tocXsl;
205
206        QString get(const char * name);
207        bool set(const char * name, const QString & value);
208};
209
210DLL_PUBLIC QPrinter::PageSize strToPageSize(const char * s, bool * ok=0);
211DLL_PUBLIC QString pageSizeToStr(QPrinter::PageSize ps);
212
213DLL_PUBLIC UnitReal strToUnitReal(const char * s, bool * ok=0);
214DLL_PUBLIC QString unitRealToStr(const UnitReal & ur, bool * ok);
215
216DLL_PUBLIC QPrinter::Orientation strToOrientation(const char * s, bool * ok=0);
217DLL_PUBLIC QString orientationToStr(QPrinter::Orientation o);
218
219DLL_PUBLIC QPrinter::PrinterMode strToPrinterMode(const char * s, bool * ok=0);
220DLL_PUBLIC QString printerModeToStr(QPrinter::PrinterMode o);
221
222DLL_PUBLIC QPrinter::ColorMode strToColorMode(const char * s, bool * ok=0);
223DLL_PUBLIC QString colorModeToStr(QPrinter::ColorMode o);
224
225}
226
227DLL_PUBLIC void dumpDefaultTOCStyleSheet(QTextStream & stream, settings::TableOfContent & s);
228}
229#include <wkhtmltox/dllend.inc>
230#endif //__PDFSETTINGS_HH__
Note: See TracBrowser for help on using the repository browser.