home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 February / PCWorld_2002-02_cd.bin / Software / Vyzkuste / pdflib / pdflib-4.0.1.sit / pdflib-4.0.1 / bind / cpp / pdflib.hpp < prev    next >
Encoding:
Text File  |  2001-07-04  |  8.4 KB  |  213 lines  |  [TEXT/CWIE]

  1. /*---------------------------------------------------------------------------*
  2.  |              PDFlib - A library for generating PDF on the fly             |
  3.  +---------------------------------------------------------------------------+
  4.  | Copyright (c) 1997-2001 PDFlib GmbH and Thomas Merz. All rights reserved. |
  5.  +---------------------------------------------------------------------------+
  6.  |    This software is NOT in the public domain.  It can be used under two   |
  7.  |    substantially different licensing terms:                               |
  8.  |                                                                           |
  9.  |    The commercial license is available for a fee, and allows you to       |
  10.  |    - ship a commercial product based on PDFlib                            |
  11.  |    - implement commercial Web services with PDFlib                        |
  12.  |    - distribute (free or commercial) software when the source code is     |
  13.  |      not made available                                                   |
  14.  |    Details can be found in the file PDFlib-license.pdf.                   |
  15.  |                                                                           |
  16.  |    The "Aladdin Free Public License" doesn't require any license fee,     |
  17.  |    and allows you to                                                      |
  18.  |    - develop and distribute PDFlib-based software for which the complete  |
  19.  |      source code is made available                                        |
  20.  |    - redistribute PDFlib non-commercially under certain conditions        |
  21.  |    - redistribute PDFlib on digital media for a fee if the complete       |
  22.  |      contents of the media are freely redistributable                     |
  23.  |    Details can be found in the file aladdin-license.pdf.                  |
  24.  |                                                                           |
  25.  |    These conditions extend to ports to other programming languages.       |
  26.  |    PDFlib is distributed with no warranty of any kind. Commercial users,  |
  27.  |    however, will receive warranty and support statements in writing.      |
  28.  *---------------------------------------------------------------------------*/
  29.  
  30. // $Id: pdflib.hpp,v 1.14 2001/04/02 11:45:28 york Exp $
  31. //
  32. // C++ wrapper for PDFlib
  33. //
  34. //
  35.  
  36. #ifndef PDFLIB_HPP
  37. #define PDFLIB_HPP
  38.  
  39. // Uncomment this if your compiler doesn't support proper bool handling
  40. //#define PDF_BROKEN_BOOL
  41.  
  42. // Add your compiler here if it doesn't like "using namespace std" for
  43. // proper handling of ANSI C++ strings
  44. #ifndef __GNUC__
  45. #define PDF_NEED_NAMESPACE
  46. #endif
  47.  
  48. #ifdef PDF_BROKEN_BOOL
  49.     #define bool    int
  50. #endif
  51.  
  52. // If ANSI C++ strings don't work we revert to plain old C char *
  53. #ifndef PDF_BROKEN_STRINGS
  54.     #include <string>
  55.  
  56.     // VC++ needs this to recognize the string class, but gcc doesn't
  57.     // understand it...
  58.     #ifdef PDF_NEED_NAMESPACE
  59.     using namespace std;
  60.     #endif
  61.  
  62.     #define pdfstring    string
  63. #else
  64.     #define pdfstring    const char *
  65. #endif
  66.  
  67. // We use PDF as a C++ class name, therefore hide the actual C struct
  68. // name for PDFlib usage with C++.
  69.  
  70. #define PDF PDF_c
  71. #include "pdflib.h"
  72. #undef PDF
  73.  
  74.  
  75. // The C++ class wrapper for PDFlib
  76.  
  77. class PDF {
  78. public:
  79.     PDF(errorproc_t errorproc = NULL,
  80.     allocproc_t allocproc = NULL,
  81.     reallocproc_t reallocproc = NULL,
  82.     freeproc_t freeproc = NULL,
  83.     void *opaque = NULL);
  84.     ~PDF();
  85.  
  86.     void * get_opaque();
  87.     static int get_majorversion();
  88.     static int get_minorversion();
  89.  
  90.     // Overloaded generic open and close methods
  91.     int  open(pdfstring filename);
  92.     int  open(FILE *fp);
  93.     void open(writeproc_t writeproc);
  94.  
  95.     void close();
  96.  
  97.     const char *get_buffer(long *size);
  98.  
  99.     void begin_page(float width, float height);
  100.     void end_page();
  101.     void set_parameter(pdfstring key, pdfstring value);
  102.     pdfstring get_parameter(pdfstring key, float mod);
  103.     float get_value(pdfstring key, float mod);
  104.     void set_value(pdfstring key, float value);
  105.     void show(pdfstring text);
  106.  
  107. // If ANSI C++ strings are not available, we need the old-style C
  108. // functions for dealing with strings with embedded null characters
  109. #ifdef PDF_BROKEN_STRINGS
  110.     void show2(pdfstring text, int len);
  111.     void show_xy2(pdfstring text, int len, float x, float y);
  112.     void continue_text2(pdfstring text, int len);
  113.     float stringwidth2(pdfstring text, int len, int font, float size);
  114. #endif
  115.     void show_xy(pdfstring text, float x, float y);
  116.     void continue_text(pdfstring text);
  117.     int show_boxed(pdfstring text, float left, float top,
  118.     float width, float height, pdfstring hmode, pdfstring reserved);
  119.     void set_text_pos(float x, float y);
  120.  
  121.     float stringwidth(pdfstring text, int font, float size);
  122.  
  123.     int  findfont(pdfstring fontname, pdfstring encoding, int embed);
  124.     void setfont(int font, float fontsize);
  125.     void save();
  126.     void restore();
  127.     void translate(float tx, float ty);
  128.     void scale(float sx, float sy);
  129.     void rotate(float phi);
  130.     void skew(float alpha, float beta);
  131.     void concat(float a, float b, float c, float d, float e, float f);
  132.     void setdash(float b, float w);
  133.     void setpolydash(float *darray, int length);
  134.     void setflat(float flat);
  135.     void setlinejoin(int join);
  136.     void setlinecap(int cap);
  137.     void setmiterlimit(float miter);
  138.     void setlinewidth(float width);
  139.     void moveto(float x, float y);
  140.     void lineto(float x, float y);
  141.     void curveto(float x1, float y1, float x2, float y2, float x3, float y3);
  142.     void circle(float x, float y, float r);
  143.     void arc(float x, float y, float r, float alpha1, float alpha2);
  144.     void arcn(float x, float y, float r, float alpha1, float alpha2);
  145.     void rect(float x, float y, float width, float height);
  146.     void closepath();
  147.     void stroke();
  148.     void closepath_stroke();
  149.     void fill();
  150.     void fill_stroke();
  151.     void closepath_fill_stroke();
  152.     void clip();
  153.     void endpath();
  154.     void setgray_fill(float g);
  155.     void setgray_stroke(float g);
  156.     void setgray(float g);
  157.     void setrgbcolor_fill(float red, float green, float blue);
  158.     void setrgbcolor_stroke(float red, float green, float blue);
  159.     void setrgbcolor(float red, float green, float blue);
  160.     int begin_template(float width, float height);
  161.     void end_template();
  162.     void place_image(int image, float x, float y, float scale);
  163.     int open_image(pdfstring type, pdfstring source, const char *data, long len,
  164.         int width, int height, int components, int bpc, pdfstring params);
  165.     int open_image_file(pdfstring type, pdfstring filename,
  166.         pdfstring stringparam, int intparam);
  167.     void close_image(int image);
  168.     int open_CCITT(pdfstring filename, int width, int height,
  169.         bool BitReverse, int K, bool BlackIs1);
  170.     int add_bookmark(pdfstring text, int parent, bool open);
  171.     void set_info(pdfstring key, pdfstring value);
  172.     void attach_file(float llx, float lly, float urx, float ury,
  173.         pdfstring filename, pdfstring description, pdfstring author,
  174.     pdfstring mimetype, pdfstring icon);
  175.     void add_note(float llx, float lly, float urx, float ury,
  176.         pdfstring contents, pdfstring title, pdfstring icon, bool open);
  177.     void add_pdflink(float llx, float lly, float urx, float ury,
  178.         pdfstring filename, int page, pdfstring dest);
  179.     void add_launchlink(float llx, float lly, float urx, float ury,
  180.         pdfstring filename);
  181.     void add_locallink(float llx, float lly, float urx, float ury,
  182.         int page, pdfstring dest);
  183.     void add_weblink(float llx, float lly, float urx, float ury, pdfstring url);
  184.  
  185.     void set_border_style(pdfstring style, float width);
  186.     void set_border_color(float red, float green, float blue);
  187.     void set_border_dash(float d1, float d2);
  188.  
  189.     int open_pdi(pdfstring filename, pdfstring stringparam, int intparam);
  190.     void close_pdi(int doc);
  191.     int open_pdi_page(int doc, int page, pdfstring label);
  192.     void place_pdi_page(int page, float x, float y, float sx, float sy);
  193.     void close_pdi_page(int page);
  194.     pdfstring get_pdi_parameter(pdfstring key, int doc, int page, int index,
  195.     int *len);
  196.     float get_pdi_value(pdfstring key, int doc, int page, int index);
  197.  
  198.     int begin_pattern(float width, float height, float xstep, float ystep,
  199.     int painttype);
  200.     void end_pattern();
  201.     int makespotcolor(pdfstring spotname, int len);
  202.     void setcolor(pdfstring type, pdfstring colorspace,
  203.     float c1, float c2, float c3, float c4);
  204.     void add_thumbnail(int image);
  205.     void initgraphics();
  206.     void setmatrix(float a, float b, float c, float d, float e, float f);
  207.  
  208. private:
  209.     PDF_c *p;
  210. };
  211.  
  212. #endif    // PDFLIB_HPP
  213.