File: pdf.hh

package info (click to toggle)
exactimage 0.9.1-16
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,264 kB
  • ctags: 6,386
  • sloc: cpp: 33,621; ansic: 1,730; xml: 1,590; makefile: 333; perl: 138; sh: 109; python: 45; php: 37
file content (84 lines) | stat: -rw-r--r-- 2,583 bytes parent folder | download | duplicates (4)
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
/*
 * Copyright (c) 2008 Susanne Klaus <susanne@exactcode.de>
 * Copyright (c) 2008 Rene Rebe <rene@exactcode.de>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2. A copy of the GNU General
 * Public License can be found in the file LICENSE.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT-
 * ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * Alternatively, commercial licensing options are available from the
 * copyright holder ExactCODE GmbH Germany.
 */

#include <vector>

#include "Codecs.hh"

struct PDFContext; // fwd

class PDFCodec : public ImageCodec {
public:
  
  PDFCodec ()
    : context(0)
  {
    registerCodec ("pdf", this);
  };

  ~PDFCodec ();
  
  // freestanding
  PDFCodec (std::ostream* s);
  
  virtual std::string getID () { return "PDF"; };
  
  virtual int readImage (std::istream* stream, Image& image, const std::string& decompres);
  virtual bool writeImage (std::ostream* stream, Image& image,
			   int quality, const std::string& compress);

  // direct PDF stream creation, including vector objects and
  // multiple pages
  
  enum filling_rule_t
    {
      fill_non_zero = (1<<0),
      fill_even_odd = (1<<1),
      fill_none = 0xff
    };
  
  void beginPage(double, double);
  
  void moveTo(double x, double y);
  void addLineTo(double x, double y);
  void closePath();
  void addCurveTo(double x1, double y1, double x2, double y2,
		  double x3, double y3);
  void setFillColor(double r, double g, double b);
  void setLineWidth(double width);
  void setLineDash(double offset, const std::vector<double>& dashes);
  void setLineDash(double offset, const double* dashes, int n);
  void showPath(filling_rule_t fill = fill_none);

  /* Default font names, as per PDF Reference:
     Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic,
     Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique,
     Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique,
     Symbol, ZapfDingbats */
  void beginText();
  void textTo(double x, double y);
  void showText(const std::string& font, const std::string& text,
		double height);
  void showImage(Image& image, double x, double y,
		 double width, double height, int quality = 80,
		 const std::string& compress = "");
  void endText();
  
private:
  PDFContext* context;
};