pdfsettings.hh 5.5 KB

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