pdfsettings.hh 5.5 KB

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