4 #include <libps/pslib.h>
6 // Exception class to handle runtime errors
8 class psexception : public std::exception
11 virtual const char* what() const throw()
13 return "PostScript error";
18 // A Postscript document as used in pslib
20 extern bool postscript_started;
30 PostScript(const char * filename)
32 if (!postscript_started)
35 postscript_started = true;
38 if (PS_open_file(psdoc, filename) == -1)
42 //PS_set_info(psdoc, "BoundingBox", "0 0 842 596");
43 PS_set_parameter(psdoc, "SearchPath", "/usr/local/share/afm");
44 PS_set_parameter(psdoc, "SearchPath", "/usr/lib/openoffice/basis3.1/share/psprint/fontmetric");
45 PS_set_parameter(psdoc, "SearchPath", "/usr/lib/openoffice/basis3.2/share/psprint/fontmetric");
46 psfont = PS_findfont(psdoc, "Courier", NULL, 0);
64 void NewPage(float page_width, float page_height)
70 if (page_width > page_height)
72 PS_begin_page(psdoc, page_height, page_width);
73 // Rotate for landscape.
75 PS_translate(psdoc, 600, 0);
80 PS_begin_page(psdoc, page_width, page_height);
83 PS_setfont(psdoc, psfont, 10.0);
86 void FontSize(float size)
88 PS_setfont(psdoc, psfont, size);
91 void LineAttributes(float width, float dash_on, float dash_off)
93 PS_setlinewidth(psdoc, width);
94 PS_setdash(psdoc, dash_on, dash_off);
97 void Line(float x1, float y1, float x2, float y2)
99 PS_moveto(psdoc, x1, y1);
100 PS_lineto(psdoc, x2, y2);
104 void Rectangle(float x, float y, float width, float height)
106 PS_setcolor(psdoc, "fill", "rgb", 0.8, 1.0, 0.8, 0.0);
107 PS_rect(psdoc, x, y, width, height);
111 void Text(float x, float y, const char * text)
113 PS_show_xy(psdoc, text, x, y);