1 #include <stdlib.h>
2 #include <stdarg.h>
3 #include <stdio.h>
4 #include <time.h>
5 #include <libps/pslib.h>
6 #ifdef MEMORY_DEBUGGING
7 #include <libps/pslib-mp.h>
8 #endif
9 
10 struct spotcolor {
11 	int id;
12 	char *name;
13 	char *colorspace;
14 	float c1;
15 	float c2;
16 	float c3;
17 	float c4;
18 };
19 
errorhandler(PSDoc * p,int error,const char * str,void * data)20 void errorhandler(PSDoc *p, int error, const char *str, void *data) {
21 	fprintf(stderr, "PSLib: %s\n", str);
22 }
23 
writeproc(PSDoc * p,void * data,size_t size)24 size_t writeproc(PSDoc *p, void *data, size_t size) {
25 	return fwrite(data, 1, size, stdout);
26 }
27 
main()28 int main() {
29 	PSDoc *ps;
30 	int psfont, psfontbold;
31 	int psimage;
32 	int i, w, x;
33 	struct spotcolor spotcolors[5] = {
34 		{0, "PANTONE Violet C", "cmyk", 0.75, 0.94, 0.0, 0.0},
35 		{0, "PANTONE 114 C", "cmyk", 0.0, 0.11, 0.69, 0.0},
36 		{0, "PANTONE 5565 C", "cmyk", 0.37, 0.0, 0.34, 0.34},
37 		{0, "RGB Blue", "rgb", 0.0, 0.0, 1.0, 0.0},
38 		{0, "Gray Black", "gray", 0.0, 0.0, 0.0, 0.0}};
39 
40 	PS_boot();
41 #ifdef MEMORY_DEBUGGING
42 	PS_mp_init();
43 #endif
44 
45 #ifdef MEMORY_DEBUGGING
46 	ps = PS_new2(errorhandler, PS_mp_malloc, PS_mp_realloc, PS_mp_free, NULL);
47 #else
48 	ps = PS_new();
49 #endif
50 
51 	if (0 > PS_open_file(ps, "poster.ps")) {
52 		printf("Cannot open PostScript file\n");
53 		exit(1);
54 	}
55 
56 	PS_set_parameter(ps, "warning", "true");
57 	PS_set_parameter(ps, "imageencoding", "hex");
58 
59 	PS_set_info(ps, "Creator", __FILE__);
60 	PS_set_info(ps, "Author", "Uwe Steinmann");
61 	PS_set_info(ps, "Title", "Poster Example");
62 	PS_set_info(ps, "Keywords", "Poster");
63 
64 	for(i=0; i<5; i++) {
65 		PS_setcolor(ps, "fill", spotcolors[i].colorspace, spotcolors[i].c1, spotcolors[i].c2, spotcolors[i].c3, spotcolors[i].c4);
66 		spotcolors[i].id = PS_makespotcolor(ps, spotcolors[i].name, 0);
67 	}
68 
69 	PS_begin_page(ps, 596, 842);
70 	psfont = PS_findfont(ps, "Helvetica", "", 0);
71 	psfontbold = PS_findfont(ps, "Helvetica-Bold", "", 0);
72 	PS_setfont(ps, psfont, 8.0);
73 
74 	PS_setcolor(ps, "fill", "spot", (float) spotcolors[2].id, 0.1, 0.0, 0.0);
75 	PS_rect(ps, 0, 767, 410, 65);
76 	PS_fill(ps);
77 	PS_rect(ps, 410, 782, 15, 50);
78 	PS_fill(ps);
79 	PS_circle(ps, 410, 782, 15);
80 	PS_fill(ps);
81 	psimage = PS_open_image_file(ps, "eps", "MMK.eps", NULL, 0);
82 	PS_place_image(ps, psimage, 370, 785, 1.3);
83 	PS_rect(ps, 0, 0, 596, 20);
84 	PS_fill(ps);
85 
86 	PS_setfont(ps, psfontbold, 24.0);
87 	x = (596-PS_stringwidth(ps, "Lernen mit frei verf�gbaren Komponenten", psfontbold, 0))/2;
88 	PS_show_xy(ps, "Lernen mit frei verf�gbaren Komponenten", x, 720);
89 
90 	PS_setfont(ps, psfont, 14.0);
91 	PS_show_xy(ps, "Frei verf�gbare Komponenten f�r Lernplattformen bieten", 240, 650);
92 	PS_show_xy(ps, "Flexibilit�t bei der Zusammenstellen", 250, 630);
93 	PS_show_xy(ps, "Anpassung an die eigenen Bed�rfnisse", 250, 610);
94 	PS_show_xy(ps, "Uneingeschr�nkte Nutzung", 250, 590);
95 	PS_show_xy(ps, "offene Schnittstellen", 250, 570);
96 
97 	psimage = PS_open_image_file(ps, "png", "lvm_screenshot.png", NULL, 0);
98 	PS_place_image(ps, psimage, 10, 500, 0.25);
99 
100 	psimage = PS_open_image_file(ps, "png", "gits.png", NULL, 0);
101 	PS_place_image(ps, psimage, 300, 270, 0.25);
102 
103 	psimage = PS_open_image_file(ps, "png", "evita.png", NULL, 0);
104 	PS_place_image(ps, psimage, 10, 30, 0.3);
105 
106 	PS_end_page(ps);
107 
108 	PS_close(ps);
109 	PS_delete(ps);
110 
111 #ifdef MEMORY_DEBUGGING
112 	PS_mp_list_unfreed();
113 #endif
114 
115 	PS_shutdown();
116 	exit(0);
117 }
118