pdfsettings.hh 5.7 KB

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