This file is indexed.

/usr/include/Wt/Render/WPdfRenderer is in libwt-dev 3.3.0-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2010 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WPDF_RENDERER_H_
#define WPDF_RENDERER_H_

#include <Wt/Render/WTextRenderer>
#include <Wt/WPdfImage>

namespace Wt {
  namespace Render {

/*! \class WPdfRenderer Wt/Render/WPdfRenderer Wt/Render/WPdfRenderer
 *  \brief An XHTML to PDF renderer.
 *
 * This class implements an XHTML to PDF renderer. The rendering engine
 * supports only a subset of XHTML. See the documentation of WTextRenderer
 * for more information.
 *
 * \if cpp
 * The renderer renders to a libharu PDF document (using WPdfImage).
 * \endif
 * \if java
 * The renderer renders to a PDFJet PDF document (using WPdfImage).
 * \endif
 *
 * By default it uses a pixel resolution of 72 DPI, which is the
 * default for a WPdfImage, but differs from the default used by most
 * browsers (which is 96 DPI and has nothing to do with the actual
 * screen resolution). The pixel resolution can be configured using
 * setDpi(). Increasing the resolution has the effect of scaling down
 * the rendering. This can be used in conjunction with setFontScale() to
 * scale the font size differently than other content.
 *
 * \if cpp
 * Usage example:
 *
 * \code
 * extern "C" {
 *   HPDF_STATUS HPDF_UseUTFEncodings(HPDF_Doc pdf);
 * }
 *	
 * HPDF_Doc pdf = HPDF_New(error_handler, 0);
 * HPDF_UseUTFEncodings(pdf); // enables UTF-8 encoding with true type fonts
 * HPDF_Page page = HPDF_AddPage(pdf);
 * HPDF_Page_SetSize(page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT);
 *
 * Render::WPdfRenderer renderer(pdf, page);
 * renderer.setMargin(2.54);
 * renderer.setDpi(96);
 *
 * renderer.render("<p style=\"background-color: #c11\">Hello, world !</p>");
 *
 * HPDF_SaveToFile(pdf, "hello.pdf");
 * HPDF_Free(pdf);
 * \endcode
 * \endif
 *
 * \ingroup render
 */
class WT_API WPdfRenderer : public WTextRenderer
{
public:
  /*! \brief Creates a new PDF renderer.
   *
   * The PDF renderer will render on the given \p pdf (starting) on the
   * given \p page.
   *
   * Default margins are 0, and the default DPI is 72.
   */
  WPdfRenderer(HPDF_Doc pdf, HPDF_Page page);

  virtual ~WPdfRenderer();

  /*! \brief Sets the page margins.
   *
   * This sets page margins, in \p cm, for one or more \p sides.
   */
  void setMargin(double cm, WFlags<Side> sides = All);

  /*! \brief Sets the resolution.
   *
   * The resolution used between CSS pixels and actual page
   * dimensions. Note that his does not have an effect on the <i>de
   * facto</i> standard CSS resolution of 96 DPI that is used to
   * convert between physical WLength units (like <em>cm</em>,
   * <em>inch</em> and <em>point</em>) and pixels. Instead it has the
   * effect of scaling down or up the rendered XHTML on the page.
   *
   * The dpi setting also affects the pageWidth(), pageHeight(), and
   * margin() pixel calculations.
   *
   * The default resolution is 72 DPI.
   */
  void setDpi(int dpi);

  /*! \brief Adds a font collection.
   *
   * \sa WPdfImage::addFontCollection()
   */
  void addFontCollection(const std::string& directory, bool recursive=true);

  /*! \brief Returns the current page.
   *
   * This returns the page last created using createPage(), or the initial
   * page if no additional apges have yet been created.
   */
  HPDF_Page currentPage() const { return page_; }

  virtual double pageWidth(int page) const;
  virtual double pageHeight(int page) const;

  virtual double margin(Side side) const;

  virtual WPaintDevice *startPage(int page);
  virtual void endPage(WPaintDevice *device);
  virtual WPainter *getPainter(WPaintDevice *device);

  /*! \brief Creates a new page.
   *
   * The default implementation creates a new page with the same dimensions
   * as the previous page.
   *
   * You may want to specialize this method to add e.g.~headers and footers.
   */
  virtual HPDF_Page createPage(int page);

private:
  struct FontCollection {
    std::string directory;
    bool recursive;
  };

  std::vector<FontCollection> fontCollections_;

  HPDF_Doc  pdf_;
  HPDF_Page page_;

  double margin_[4];
  int dpi_;
  WPainter *painter_;
};

  }
}

#endif // WPDF_RENDER_