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-2020 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 <logging.hh> 28 #include <loadsettings.hh> 29 #include <websettings.hh> 30 31 #include <dllbegin.inc> 32 namespace wkhtmltopdf { 33 namespace settings { 34 35 typedef QPair<qreal, QPrinter::Unit> UnitReal; 36 37 /*! \brief Settings considering margins */ 38 struct DLL_PUBLIC Margin { 39 Margin(); 40 //!Margin applied to the top of the page 41 UnitReal top; 42 //!Margin applied to the right of the page 43 UnitReal right; 44 //!Margin applied to the bottom of the page 45 UnitReal bottom; 46 //!Margin applied to the leftp of the page 47 UnitReal left; 48 }; 49 50 /*! \brief Settings considering page size */ 51 struct DLL_PUBLIC Size { 52 Size(); 53 //! What size paper should we use 54 QPrinter::PageSize pageSize; 55 //!Height of the page 56 UnitReal height; 57 //!Width of the page 58 UnitReal width; 59 }; 60 61 /*! \brief Settings considering the table of content */ 62 struct DLL_PUBLIC TableOfContent { 63 TableOfContent(); 64 //! Should we print dots between the name and the page number? 65 bool useDottedLines; 66 //! Name af the TOC 67 QString captionText; 68 //! Link from TOC to section headers 69 bool forwardLinks; 70 //! Link from section headers to TOC 71 bool backLinks; 72 //! How fare should we indent on every level 73 QString indentation; 74 //! Factor we should scale the font with on every level 75 float fontScale; 76 }; 77 78 /*! \brief Class holding all user setting. 79 This class holds all the user settings, settings can be filled in by hand, 80 or with other methods. 81 \sa CommandLineParser::parse() 82 */ 83 struct DLL_PUBLIC PdfGlobal { 84 PdfGlobal(); 85 86 //! Size related settings 87 Size size; 88 89 //! Log level 90 LogLevel logLevel; 91 92 //! Should we use the graphics system 93 bool useGraphics; 94 95 //! Should relative links be resolved or kept as-is 96 bool resolveRelativeLinks; 97 98 //! Should we orientate in landscape or portrate 99 QPrinter::Orientation orientation; 100 101 //! Color or grayscale 102 QPrinter::ColorMode colorMode; 103 104 //! What overall resolution should we use 105 QPrinter::PrinterMode resolution; 106 107 //! What dpi should be used when printing 108 int dpi; 109 110 //! When pagenumbers are printed, apply this offset to them all 111 int pageOffset; 112 113 //! How many copies do we wan to print 114 int copies; 115 116 //! Should be print a whole copy before beginning the next 117 bool collate; 118 119 //! Should we generate an outline and put it into the pdf file 120 bool outline; 121 122 //! Maximal depth of the generated outline 123 int outlineDepth; 124 125 //! dump outline to this filename 126 QString dumpOutline; 127 128 //! The file where in to store the output 129 QString out; 130 131 QString documentTitle; 132 133 bool useCompression; 134 135 //! Margin related settings 136 Margin margin; 137 138 QString viewportSize; 139 140 int imageDPI; 141 int imageQuality; 142 143 LoadGlobal load; 144 145 QString get(const char * name); 146 bool set(const char * name, const QString & value); 147 }; 148 149 /*! \brief Settings considering headers and footers */ 150 struct DLL_PUBLIC HeaderFooter { 151 HeaderFooter(); 152 //! Size of the font used to render the text 153 int fontSize; 154 //! Name of font used to render text 155 QString fontName; 156 //! Text to render at the left 157 QString left; 158 //! Text to render at the right 159 QString right; 160 //! Text to render at the center 161 QString center; 162 //! Should a line separate the header/footer and the document 163 bool line; 164 //! Url of the document the html document that should be used as a header/footer 165 QString htmlUrl; 166 //! Spacing 167 float spacing; 168 }; 169 170 struct DLL_PUBLIC PdfObject { 171 PdfObject(); 172 //! Settings regarding the TOC 173 TableOfContent toc; 174 175 QString page; 176 177 //! Header related settings 178 HeaderFooter header; 179 180 //! Header related settings 181 HeaderFooter footer; 182 183 //! Should external links be links in the PDF 184 bool useExternalLinks; 185 186 //! Should internal links be links in the PDF 187 bool useLocalLinks; 188 189 //! Replacements 190 QList< QPair<QString, QString> > replacements; 191 192 //! Convert forms on the pages into PDF forms 193 bool produceForms; 194 195 LoadPage load; 196 197 Web web; 198 199 bool includeInOutline; 200 201 bool pagesCount; 202 203 bool isTableOfContent; 204 205 QString tocXsl; 206 207 QString get(const char * name); 208 bool set(const char * name, const QString & value); 209 }; 210 211 DLL_PUBLIC QPrinter::PageSize strToPageSize(const char * s, bool * ok=0); 212 DLL_PUBLIC QString pageSizeToStr(QPrinter::PageSize ps); 213 214 DLL_PUBLIC UnitReal strToUnitReal(const char * s, bool * ok=0); 215 DLL_PUBLIC QString unitRealToStr(const UnitReal & ur, bool * ok); 216 217 DLL_PUBLIC QPrinter::Orientation strToOrientation(const char * s, bool * ok=0); 218 DLL_PUBLIC QString orientationToStr(QPrinter::Orientation o); 219 220 DLL_PUBLIC QPrinter::PrinterMode strToPrinterMode(const char * s, bool * ok=0); 221 DLL_PUBLIC QString printerModeToStr(QPrinter::PrinterMode o); 222 223 DLL_PUBLIC QPrinter::ColorMode strToColorMode(const char * s, bool * ok=0); 224 DLL_PUBLIC QString colorModeToStr(QPrinter::ColorMode o); 225 226 } 227 228 DLL_PUBLIC void dumpDefaultTOCStyleSheet(QTextStream & stream, settings::TableOfContent & s); 229 } 230 #include <dllend.inc> 231 #endif //__PDFSETTINGS_HH__ 232