1/*---------------------------------------------------------------------------*
2 |              PDFlib - A library for generating PDF on the fly             |
3 +---------------------------------------------------------------------------+
4 | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. |
5 +---------------------------------------------------------------------------+
6 |                                                                           |
7 |    This software is subject to the PDFlib license. It is NOT in the       |
8 |    public domain. Extended versions and commercial licenses are           |
9 |    available, please check http://www.pdflib.com.                         |
10 |                                                                           |
11 *---------------------------------------------------------------------------*/
12
13/* $Id: pdflib.h 14574 2005-10-29 16:27:43Z bonefish $
14 *
15 * PDFlib public function and constant declarations
16 *
17 */
18
19#ifndef PDFLIB_H
20#define PDFLIB_H
21
22#include <stdio.h>
23#include <setjmp.h>
24
25
26/*
27 * ----------------------------------------------------------------------
28 * Setup, mostly Windows calling conventions and DLL stuff
29 * ----------------------------------------------------------------------
30 */
31
32#ifdef WIN32
33
34#if !defined(PDFLIB_CALL)
35#define PDFLIB_CALL	__cdecl
36#endif
37
38#if !defined(PDFLIB_API)
39#ifdef PDFLIB_EXPORTS
40#define PDFLIB_API __declspec(dllexport) /* prepare a DLL (internal use only) */
41
42#elif defined(PDFLIB_DLL)
43#define PDFLIB_API __declspec(dllimport) /* PDFlib clients: import PDFlib DLL */
44
45#else	/* !PDFLIB_DLL */
46#define PDFLIB_API /* */	/* default: generate or use static library */
47
48#endif	/* !PDFLIB_DLL */
49#endif /* !PDFLIB_API */
50
51#else	/* !WIN32 */
52
53#if ((defined __IBMC__ || defined __IBMCPP__) && defined __DLL__ && defined OS2)
54    #define PDFLIB_CALL _Export
55    #define PDFLIB_API
56#endif	/* IBM VisualAge C++ DLL */
57
58#ifndef PDFLIB_CALL
59#define PDFLIB_CALL
60#endif
61#ifndef PDFLIB_API
62#define PDFLIB_API
63#endif
64
65#endif	/* !WIN32 */
66
67
68/* export all symbols for a shared library on the Mac */
69#if defined(__MWERKS__) && defined(PDFLIB_EXPORTS)
70#pragma export on
71#endif
72
73
74/* Make our declarations C++ compatible */
75#ifdef __cplusplus
76extern "C" {
77#endif
78
79
80/* Define the basic PDF type. This is used opaquely at the API level. */
81#if !defined(PDF) || defined(ACTIVEX)
82typedef struct PDF_s PDF;
83#endif /* !PDF */
84
85/* The API structure with function pointers. */
86typedef struct PDFlib_api_s PDFlib_api;
87
88/*
89 * The version defines below may be used to check the version of the
90 * include file against the library.
91 */
92
93/* do not change this (version.sh will do it for you :) */
94#define PDFLIB_MAJORVERSION	5	/* PDFlib major version number */
95#define PDFLIB_MINORVERSION	0	/* PDFlib minor version number */
96#define PDFLIB_REVISION		3	/* PDFlib revision number */
97#define PDFLIB_VERSIONSTRING	"5.0.3"	/* The whole bunch */
98
99
100/* {{{ p_annots.c: file attachments, notes, and links
101 * ----------------------------------------------------------------------
102 */
103
104/* Add a launch annotation (to a target of arbitrary file type). */
105PDFLIB_API void PDFLIB_CALL
106PDF_add_launchlink(PDF *p, float llx, float lly, float urx, float ury,
107    const char *filename);
108
109/* Add a link annotation to a target within the current PDF file. */
110PDFLIB_API void PDFLIB_CALL
111PDF_add_locallink(PDF *p, float llx, float lly, float urx, float ury,
112    int page, const char *optlist);
113
114/* Add a note annotation. icon is one of of "comment", "insert", "note",
115 * "paragraph", "newparagraph", "key", or "help". */
116PDFLIB_API void PDFLIB_CALL
117PDF_add_note(PDF *p, float llx, float lly, float urx, float ury,
118    const char *contents, const char *title, const char *icon, int open);
119
120PDFLIB_API void PDFLIB_CALL
121PDF_add_note2(PDF *p, float llx, float lly, float urx, float ury,
122    const char *contents, int len_cont, const char *title, int len_title,
123    const char *icon, int open);
124
125/* Add a file link annotation (to a PDF target). */
126PDFLIB_API void PDFLIB_CALL
127PDF_add_pdflink(PDF *p, float llx, float lly, float urx, float ury,
128    const char *filename, int page, const char *optlist);
129
130/* Add a weblink annotation to a target URL on the Web. */
131PDFLIB_API void PDFLIB_CALL
132PDF_add_weblink(PDF *p, float llx, float lly, float urx, float ury,
133    const char *url);
134
135/* Add a file attachment annotation. icon is one of "graph", "paperclip",
136 * "pushpin", or "tag". */
137PDFLIB_API void PDFLIB_CALL
138PDF_attach_file(PDF *p, float llx, float lly, float urx, float ury,
139    const char *filename, const char *description, const char *author,
140    const char *mimetype, const char *icon);
141
142PDFLIB_API void PDFLIB_CALL
143PDF_attach_file2(PDF *p, float llx, float lly, float urx, float ury,
144    const char *filename, int reserved, const char *description, int len_descr,
145    const char *author, int len_auth, const char *mimetype, const char *icon);
146
147/* Set the border color for all kinds of annotations. */
148PDFLIB_API void PDFLIB_CALL
149PDF_set_border_color(PDF *p, float red, float green, float blue);
150
151/* Set the border dash style for all kinds of annotations. See PDF_setdash(). */
152PDFLIB_API void PDFLIB_CALL
153PDF_set_border_dash(PDF *p, float b, float w);
154
155/* Set the border style for all kinds of annotations. style is "solid" or
156 * "dashed". */
157PDFLIB_API void PDFLIB_CALL
158PDF_set_border_style(PDF *p, const char *style, float width);
159/* }}} */
160
161
162/* {{{ p_basic.c: general functions
163 * ----------------------------------------------------------------------
164 */
165
166/* Add a new page to the document. */
167PDFLIB_API void PDFLIB_CALL
168PDF_begin_page(PDF *p, float width, float height);
169
170/* Boot PDFlib (recommended although currently not required). */
171PDFLIB_API void PDFLIB_CALL
172PDF_boot(void);
173
174/* Close the generated PDF file, and release all document-related resources. */
175PDFLIB_API void PDFLIB_CALL
176PDF_close(PDF *p);
177
178/* Delete the PDFlib object, and free all internal resources. */
179PDFLIB_API void PDFLIB_CALL
180PDF_delete(PDF *p);
181
182/* Finish the page. */
183PDFLIB_API void PDFLIB_CALL
184PDF_end_page(PDF *p);
185
186/* Retrieve a structure with PDFlib API function pointers (mainly for DLLs).
187 * Although this function is published here, it is not supposed to be used
188 * directly by clients. Use PDF_new_dl() (in pdflibdl.c) instead. */
189PDFLIB_API const PDFlib_api * PDFLIB_CALL
190PDF_get_api(void);
191
192/* Get the name of the API function which threw the last exception or failed. */
193PDFLIB_API const char * PDFLIB_CALL
194PDF_get_apiname(PDF *p);
195
196/* Get the contents of the PDF output buffer. The result must be used by
197 * the client before calling any other PDFlib function. */
198PDFLIB_API const char * PDFLIB_CALL
199PDF_get_buffer(PDF *p, long *size);
200
201/* Get the descriptive text of the last thrown exception, or the reason of
202 * a failed function call. */
203PDFLIB_API const char * PDFLIB_CALL
204PDF_get_errmsg(PDF *p);
205
206/* Get the number of the last thrown exception, or the reason of a failed
207 * function call. */
208PDFLIB_API int PDFLIB_CALL
209PDF_get_errnum(PDF *p);
210
211/* Depreceated: use PDF_get_value() */
212PDFLIB_API int PDFLIB_CALL
213PDF_get_majorversion(void);
214
215/* Depreceated: use PDF_get_value() */
216PDFLIB_API int PDFLIB_CALL
217PDF_get_minorversion(void);
218
219/* Fetch the opaque application pointer stored in PDFlib. */
220PDFLIB_API void * PDFLIB_CALL
221PDF_get_opaque(PDF *p);
222
223/* Create a new PDFlib object, using default error handling and memory
224 management. */
225PDFLIB_API PDF * PDFLIB_CALL
226PDF_new(void);
227
228/* Create a new PDFlib object with client-supplied error handling and memory
229 * allocation routines. */
230typedef void  (*errorproc_t)(PDF *p1, int errortype, const char *msg);
231typedef void* (*allocproc_t)(PDF *p2, size_t size, const char *caller);
232typedef void* (*reallocproc_t)(PDF *p3,
233		void *mem, size_t size, const char *caller);
234typedef void  (*freeproc_t)(PDF *p4, void *mem);
235
236PDFLIB_API PDF * PDFLIB_CALL
237PDF_new2(errorproc_t errorhandler, allocproc_t allocproc,
238	reallocproc_t reallocproc, freeproc_t freeproc, void *opaque);
239
240/* Create a new PDF file using the supplied file name. */
241PDFLIB_API int PDFLIB_CALL
242PDF_open_file(PDF *p, const char *filename);
243
244/* Open a new PDF file associated with p, using the supplied file handle. */
245PDFLIB_API int PDFLIB_CALL
246PDF_open_fp(PDF *p, FILE *fp);
247
248/* Open a new PDF in memory, and install a callback for fetching the data. */
249typedef size_t (*writeproc_t)(PDF *p1, void *data, size_t size);
250PDFLIB_API void PDFLIB_CALL
251PDF_open_mem(PDF *p, writeproc_t writeproc);
252
253/* Shut down PDFlib (recommended although currently not required). */
254PDFLIB_API void PDFLIB_CALL
255PDF_shutdown(void);
256
257/*
258 * Error classes are deprecated; use PDF_TRY/PDF_CATCH instead.
259 * Note that old-style error handlers are still supported, but
260 * they will always receive type PDF_NonfatalError (for warnings)
261 * or PDF_UnknownError (for other exceptions).
262 */
263
264#define PDF_MemoryError    1
265#define PDF_IOError        2
266#define PDF_RuntimeError   3
267#define PDF_IndexError     4
268#define PDF_TypeError      5
269#define PDF_DivisionByZero 6
270#define PDF_OverflowError  7
271#define PDF_SyntaxError    8
272#define PDF_ValueError     9
273#define PDF_SystemError   10
274
275#define PDF_NonfatalError 11
276#define PDF_UnknownError  12
277
278/* }}} */
279
280
281/*{{{ p_block.c: Variable Data Processing with blocks (requires the PDI library)
282 * --------------------------------------------------------------------------
283 */
284
285/* Process an image block according to its properties. */
286PDFLIB_API int PDFLIB_CALL
287PDF_fill_imageblock(PDF *p, int page, const char *blockname,
288    int image, const char *optlist);
289
290/* Process a PDF block according to its properties. */
291PDFLIB_API int PDFLIB_CALL
292PDF_fill_pdfblock(PDF *p, int page, const char *blockname,
293    int contents, const char *optlist);
294
295/* Process a text block according to its properties. */
296PDFLIB_API int PDFLIB_CALL
297PDF_fill_textblock(PDF *p, int page, const char *blockname,
298    const char *text, int len, const char *optlist);
299/* }}} */
300
301
302/* {{{ p_color.c: color handling
303 * ----------------------------------------------------------------------
304 */
305
306/* Make a named spot color from the current color. */
307PDFLIB_API int PDFLIB_CALL
308PDF_makespotcolor(PDF *p, const char *spotname, int reserved);
309
310/* Set the current color space and color. fstype is "fill", "stroke",
311or "fillstroke".
312 */
313PDFLIB_API void PDFLIB_CALL
314PDF_setcolor(PDF *p, const char *fstype, const char *colorspace,
315    float c1, float c2, float c3, float c4);
316
317/* The following six functions are deprecated, use PDF_setcolor() instead. */
318PDFLIB_API void PDFLIB_CALL
319PDF_setgray(PDF *p, float gray);
320
321PDFLIB_API void PDFLIB_CALL
322PDF_setgray_fill(PDF *p, float gray);
323
324PDFLIB_API void PDFLIB_CALL
325PDF_setgray_stroke(PDF *p, float gray);
326
327PDFLIB_API void PDFLIB_CALL
328PDF_setrgbcolor(PDF *p, float red, float green, float blue);
329
330PDFLIB_API void PDFLIB_CALL
331PDF_setrgbcolor_fill(PDF *p, float red, float green, float blue);
332
333PDFLIB_API void PDFLIB_CALL
334PDF_setrgbcolor_stroke(PDF *p, float red, float green, float blue);
335/* }}} */
336
337
338/* {{{ p_draw.c: path construction, painting, and clipping
339 * ----------------------------------------------------------------------
340 */
341
342/* Draw a counterclockwise circular arc from alpha to beta degrees. */
343PDFLIB_API void PDFLIB_CALL
344PDF_arc(PDF *p, float x, float y, float r, float alpha, float beta);
345
346/* Draw a clockwise circular arc from alpha to beta degrees. */
347PDFLIB_API void PDFLIB_CALL
348PDF_arcn(PDF *p, float x, float y, float r, float alpha, float beta);
349
350/* Draw a circle with center (x, y) and radius r. */
351PDFLIB_API void PDFLIB_CALL
352PDF_circle(PDF *p, float x, float y, float r);
353
354/* Use the current path as clipping path. */
355PDFLIB_API void PDFLIB_CALL
356PDF_clip(PDF *p);
357
358/* Close the current path. */
359PDFLIB_API void PDFLIB_CALL
360PDF_closepath(PDF *p);
361
362/* Close the path, fill, and stroke it. */
363PDFLIB_API void PDFLIB_CALL
364PDF_closepath_fill_stroke(PDF *p);
365
366/* Close the path, and stroke it. */
367PDFLIB_API void PDFLIB_CALL
368PDF_closepath_stroke(PDF *p);
369
370/* Draw a Bezier curve from the current point, using 3 more control points. */
371PDFLIB_API void PDFLIB_CALL
372PDF_curveto(PDF *p,
373    float x_1, float y_1, float x_2, float y_2, float x_3, float y_3);
374
375/* End the current path without filling or stroking it. */
376PDFLIB_API void PDFLIB_CALL
377PDF_endpath(PDF *p);
378
379/* Fill the interior of the path with the current fill color. */
380PDFLIB_API void PDFLIB_CALL
381PDF_fill(PDF *p);
382
383/* Fill and stroke the path with the current fill and stroke color. */
384PDFLIB_API void PDFLIB_CALL
385PDF_fill_stroke(PDF *p);
386
387/* Draw a line from the current point to (x, y). */
388PDFLIB_API void PDFLIB_CALL
389PDF_lineto(PDF *p, float x, float y);
390
391/* Draw a line from the current point to (cp + (x, y)) (unsupported). */
392PDFLIB_API void PDFLIB_CALL
393PDF_rlineto(PDF *p, float x, float y);
394
395/* Set the current point. */
396PDFLIB_API void PDFLIB_CALL
397PDF_moveto(PDF *p, float x, float y);
398
399/* Draw a Bezier curve from the current point using relative coordinates
400 (unsupported). */
401PDFLIB_API void PDFLIB_CALL
402PDF_rcurveto(PDF *p,
403    float x_1, float y_1, float x_2, float y_2, float x_3, float y_3);
404
405/* Draw a rectangle at lower left (x, y) with width and height. */
406PDFLIB_API void PDFLIB_CALL
407PDF_rect(PDF *p, float x, float y, float width, float height);
408
409/* Set the new current point relative the old current point (unsupported). */
410PDFLIB_API void PDFLIB_CALL
411PDF_rmoveto(PDF *p, float x, float y);
412
413/* Stroke the path with the current color and line width, and clear it. */
414PDFLIB_API void PDFLIB_CALL
415PDF_stroke(PDF *p);
416
417/* }}} */
418
419
420/* {{{ p_encoding.c: encoding handling
421 * ----------------------------------------------------------------------
422 */
423
424/* Request a glyph name from a custom encoding (unsupported). */
425PDFLIB_API const char * PDFLIB_CALL
426PDF_encoding_get_glyphname(PDF *p, const char *encoding, int slot);
427
428/* Request a glyph unicode value from a custom encoding (unsupported). */
429PDFLIB_API int PDFLIB_CALL
430PDF_encoding_get_unicode(PDF *p, const char *encoding, int slot);
431
432/* Add a glyph name to a custom encoding. */
433PDFLIB_API void PDFLIB_CALL
434PDF_encoding_set_char(PDF *p, const char *encoding, int slot,
435    const char *glyphname, int uv);
436/* }}} */
437
438
439/* {{{ p_font.c: text and font handling
440 * ----------------------------------------------------------------------
441 */
442
443/* Search a font, and prepare it for later use. PDF_load_font() is
444 * recommended. */
445PDFLIB_API int PDFLIB_CALL
446PDF_findfont(PDF *p, const char *fontname, const char *encoding, int embed);
447
448/* Request a glyph ID value from a font (unsupported). */
449PDFLIB_API int PDFLIB_CALL
450PDF_get_glyphid(PDF *p, int font, int code);
451
452/* Open and search a font, and prepare it for later use. */
453PDFLIB_API int PDFLIB_CALL
454PDF_load_font(PDF *p, const char *fontname, int len,
455    const char *encoding, const char *optlist);
456
457/* Set the current font in the given size, using a font handle returned by
458 * PDF_load_font(). */
459PDFLIB_API void PDFLIB_CALL
460PDF_setfont(PDF *p, int font, float fontsize);
461/* }}} */
462
463
464/* {{{ p_gstate.c: graphics state
465 * ----------------------------------------------------------------------
466 */
467
468/* Maximum length of dash arrays */
469#define MAX_DASH_LENGTH	8
470
471/* Concatenate a matrix to the current transformation matrix. */
472PDFLIB_API void PDFLIB_CALL
473PDF_concat(PDF *p, float a, float b, float c, float d, float e, float f);
474
475/* Reset all color and graphics state parameters to their defaults. */
476PDFLIB_API void PDFLIB_CALL
477PDF_initgraphics(PDF *p);
478
479/* Restore the most recently saved graphics state. */
480PDFLIB_API void PDFLIB_CALL
481PDF_restore(PDF *p);
482
483/* Rotate the coordinate system by phi degrees. */
484PDFLIB_API void PDFLIB_CALL
485PDF_rotate(PDF *p, float phi);
486
487/* Save the current graphics state. */
488PDFLIB_API void PDFLIB_CALL
489PDF_save(PDF *p);
490
491/* Scale the coordinate system. */
492PDFLIB_API void PDFLIB_CALL
493PDF_scale(PDF *p, float sx, float sy);
494
495/* Set the current dash pattern to b black and w white units. */
496PDFLIB_API void PDFLIB_CALL
497PDF_setdash(PDF *p, float b, float w);
498
499/* Set a more complicated dash pattern defined by an optlist. */
500PDFLIB_API void PDFLIB_CALL
501PDF_setdashpattern(PDF *p, const char *optlist);
502
503/* Set the flatness to a value between 0 and 100 inclusive. */
504PDFLIB_API void PDFLIB_CALL
505PDF_setflat(PDF *p, float flatness);
506
507/* Set the linecap parameter to a value between 0 and 2 inclusive. */
508PDFLIB_API void PDFLIB_CALL
509PDF_setlinecap(PDF *p, int linecap);
510
511/* Set the linejoin parameter to a value between 0 and 2 inclusive. */
512PDFLIB_API void PDFLIB_CALL
513PDF_setlinejoin(PDF *p, int linejoin);
514
515/* Set the current linewidth to width. */
516PDFLIB_API void PDFLIB_CALL
517PDF_setlinewidth(PDF *p, float width);
518
519/* Explicitly set the current transformation matrix. */
520PDFLIB_API void PDFLIB_CALL
521PDF_setmatrix(PDF *p, float a, float b, float c, float d, float e, float f);
522
523/* Set the miter limit to a value greater than or equal to 1. */
524PDFLIB_API void PDFLIB_CALL
525PDF_setmiterlimit(PDF *p, float miter);
526
527/* Deprecated, use PDF_setdashpattern() instead. */
528PDFLIB_API void PDFLIB_CALL
529PDF_setpolydash(PDF *p, float *dasharray, int length);
530
531/* Skew the coordinate system in x and y direction by alpha and beta degrees. */
532PDFLIB_API void PDFLIB_CALL
533PDF_skew(PDF *p, float alpha, float beta);
534
535/* Translate the origin of the coordinate system. */
536PDFLIB_API void PDFLIB_CALL
537PDF_translate(PDF *p, float tx, float ty);
538/* }}} */
539
540
541/* {{{ p_hyper.c: bookmarks and document info fields
542 * ----------------------------------------------------------------------
543 */
544
545/* Add a nested bookmark under parent, or a new top-level bookmark if
546 * parent = 0. Returns a bookmark descriptor which may be
547 * used as parent for subsequent nested bookmarks. If open = 1, child
548 * bookmarks will be folded out, and invisible if open = 0. */
549PDFLIB_API int PDFLIB_CALL
550PDF_add_bookmark(PDF *p, const char *text, int parent, int open);
551
552PDFLIB_API int PDFLIB_CALL
553PDF_add_bookmark2(PDF *p, const char *text, int len, int parent, int open);
554
555/* Create a named destination on an arbitrary page in the current document. */
556PDFLIB_API void PDFLIB_CALL
557PDF_add_nameddest(PDF *p, const char *name, int reserved, const char *optlist);
558
559/* Fill document information field key with value. key is one of "Subject",
560 * "Title", "Creator", "Author", "Keywords", or a user-defined key. */
561PDFLIB_API void PDFLIB_CALL
562PDF_set_info(PDF *p, const char *key, const char *value);
563
564PDFLIB_API void PDFLIB_CALL
565PDF_set_info2(PDF *p, const char *key, const char *value, int len);
566/* }}} */
567
568
569/* {{{ p_icc.c: ICC profile handling
570 * ----------------------------------------------------------------------
571 */
572
573/* Search an ICC profile, and prepare it for later use. */
574PDFLIB_API int PDFLIB_CALL
575PDF_load_iccprofile(PDF *p, const char *profilename, int reserved,
576    const char *optlist);
577/* }}} */
578
579
580/* {{{ p_image.c: image handling
581 * ----------------------------------------------------------------------
582 */
583
584/* Add an existing image as thumbnail for the current page. */
585PDFLIB_API void PDFLIB_CALL
586PDF_add_thumbnail(PDF *p, int image);
587
588/* Close an image retrieved with PDF_load_image(). */
589PDFLIB_API void PDFLIB_CALL
590PDF_close_image(PDF *p, int image);
591
592/* Place an image or template at (x, y) with various options. */
593PDFLIB_API void PDFLIB_CALL
594PDF_fit_image(PDF *p, int image, float x, float y, const char *optlist);
595
596/* Open a (disk-based or virtual) image file with various options. */
597PDFLIB_API int PDFLIB_CALL
598PDF_load_image(PDF *p, const char *imagetype, const char *filename,
599    int reserved, const char *optlist);
600
601/* Deprecated, use PDF_load_image() instead. */
602PDFLIB_API int PDFLIB_CALL
603PDF_open_CCITT(PDF *p, const char *filename, int width, int height,
604    int BitReverse, int K, int BlackIs1);
605
606/* Deprecated, use PDF_load_image() with virtual files instead. */
607PDFLIB_API int PDFLIB_CALL
608PDF_open_image(PDF *p, const char *imagetype, const char *source,
609    const char *data, long length, int width, int height, int components,
610    int bpc, const char *params);
611
612/* Deprecated, use PDF_load_image() instead. */
613PDFLIB_API int PDFLIB_CALL
614PDF_open_image_file(PDF *p, const char *imagetype, const char *filename,
615    const char *stringparam, int intparam);
616
617/* Deprecated, use PDF_fit_image() instead. */
618PDFLIB_API void PDFLIB_CALL
619PDF_place_image(PDF *p, int image, float x, float y, float scale);
620/* }}} */
621
622
623/* {{{ p_kerning.c: font kerning
624 * ----------------------------------------------------------------------
625 */
626
627/* Request the amount of kerning between two characters in a specified font.
628   (unsupported) */
629PDFLIB_API float PDFLIB_CALL
630PDF_get_kern_amount(PDF *p, int font, int firstchar, int secondchar);
631/* }}} */
632
633
634/* {{{ p_params.c: parameter handling
635 * ----------------------------------------------------------------------
636 */
637
638/* Get the contents of some PDFlib parameter with string type. */
639PDFLIB_API const char * PDFLIB_CALL
640PDF_get_parameter(PDF *p, const char *key, float modifier);
641
642/* Get the value of some PDFlib parameter with float type. */
643PDFLIB_API float PDFLIB_CALL
644PDF_get_value(PDF *p, const char *key, float modifier);
645
646/* Set some PDFlib parameter with string type. */
647PDFLIB_API void PDFLIB_CALL
648PDF_set_parameter(PDF *p, const char *key, const char *value);
649
650/* Set the value of some PDFlib parameter with float type. */
651PDFLIB_API void PDFLIB_CALL
652PDF_set_value(PDF *p, const char *key, float value);
653/* }}} */
654
655
656/* {{{ p_pattern.c: pattern definition
657 * ----------------------------------------------------------------------
658 */
659
660/* Start a new pattern definition. */
661PDFLIB_API int PDFLIB_CALL
662PDF_begin_pattern(PDF *p,
663    float width, float height, float xstep, float ystep, int painttype);
664
665/* Finish a pattern definition. */
666PDFLIB_API void PDFLIB_CALL
667PDF_end_pattern(PDF *p);
668/* }}} */
669
670
671/* {{{ p_pdi.c: PDF import (requires the PDI library)
672 * ----------------------------------------------------------------------
673 */
674
675/* Close all open page handles, and close the input PDF document. */
676PDFLIB_API void PDFLIB_CALL
677PDF_close_pdi(PDF *p, int doc);
678
679/* Close the page handle, and free all page-related resources. */
680PDFLIB_API void PDFLIB_CALL
681PDF_close_pdi_page(PDF *p, int page);
682
683/* Place an imported PDF page with the lower left corner at (x, y) with
684 * various options. */
685PDFLIB_API void PDFLIB_CALL
686PDF_fit_pdi_page(PDF *p, int page, float x, float y, const char *optlist);
687
688/* Get the contents of some PDI document parameter with string type. */
689PDFLIB_API const char *PDFLIB_CALL
690PDF_get_pdi_parameter(PDF *p, const char *key, int doc, int page,
691    int reserved, int *len);
692
693/* Get the contents of some PDI document parameter with numerical type. */
694PDFLIB_API float PDFLIB_CALL
695PDF_get_pdi_value(PDF *p, const char *key, int doc, int page, int reserved);
696
697/* Open a (disk-based or virtual) PDF document and prepare it for later use. */
698PDFLIB_API int PDFLIB_CALL
699PDF_open_pdi(PDF *p, const char *filename, const char *optlist, int reserved);
700
701/* Open an existing PDF document with callback functions for file access. */
702PDFLIB_API int PDFLIB_CALL
703PDF_open_pdi_callback(PDF *p, void *opaque, size_t filesize,
704    size_t (*readproc)(void *opaque, void *buffer, size_t size),
705    int (*seekproc)(void *opaque, long offset),
706    const char *optlist);
707
708/* Prepare a page for later use with PDF_place_pdi_page(). */
709PDFLIB_API int PDFLIB_CALL
710PDF_open_pdi_page(PDF *p, int doc, int pagenumber, const char *optlist);
711
712/* Deprecated, use PDF_fit_pdi_page( ) instead. */
713PDFLIB_API void PDFLIB_CALL
714PDF_place_pdi_page(PDF *p, int page, float x, float y, float sx, float sy);
715
716/* Perform various actions on a PDI document. */
717PDFLIB_API int PDFLIB_CALL
718PDF_process_pdi(PDF *p, int doc, int page, const char *optlist);
719/* }}} */
720
721
722/* {{{ p_resource.c: resources and virtual file system handling
723 * ----------------------------------------------------------------------
724 */
725
726/* Create a new virtual file. */
727PDFLIB_API void PDFLIB_CALL
728PDF_create_pvf(PDF *p, const char *filename, int reserved,
729               const void *data, size_t size, const char *optlist);
730
731/* Delete a virtual file. */
732PDFLIB_API int PDFLIB_CALL
733PDF_delete_pvf(PDF *p, const char *filename, int reserved);
734/* }}} */
735
736
737/* {{{ p_shading.c: shadings
738 * ----------------------------------------------------------------------
739 */
740
741/* Define a color blend (smooth shading) from the current fill color to the
742 * supplied color. */
743PDFLIB_API int PDFLIB_CALL
744PDF_shading(PDF *p,
745    const char *shtype,
746    float x_0, float y_0,
747    float x_1, float y_1,
748    float c_1, float c_2, float c_3, float c_4,
749    const char *optlist);
750
751/* Define a shading pattern using a shading object. */
752PDFLIB_API int PDFLIB_CALL
753PDF_shading_pattern(PDF *p, int shading, const char *optlist);
754
755/* Fill an area with a shading, based on a shading object. */
756PDFLIB_API void PDFLIB_CALL
757PDF_shfill(PDF *p, int shading);
758/* }}} */
759
760
761/* {{{ p_template.c: template definition
762 * ----------------------------------------------------------------------
763 */
764
765/* Start a new template definition. */
766PDFLIB_API int PDFLIB_CALL
767PDF_begin_template(PDF *p, float width, float height);
768
769/* Finish a template definition. */
770PDFLIB_API void PDFLIB_CALL
771PDF_end_template(PDF *p);
772/* }}} */
773
774
775/* {{{ p_text.c: text output
776 * ----------------------------------------------------------------------
777 */
778
779/* Function duplicates with explicit string length for use with
780strings containing null characters. These are for C and C++ clients only,
781but are used internally for the other language bindings. */
782
783/* Print text at the next line. The spacing between lines is determined by
784 * the "leading" parameter. */
785PDFLIB_API void PDFLIB_CALL
786PDF_continue_text(PDF *p, const char *text);
787
788/* Same as PDF_continue_text but with explicit string length. */
789PDFLIB_API void PDFLIB_CALL
790PDF_continue_text2(PDF *p, const char *text, int len);
791
792/* Place a single text line at (x, y) with various options. */
793PDFLIB_API void PDFLIB_CALL
794PDF_fit_textline(PDF *p, const char *text, int len, float x, float y,
795    const char *optlist);
796
797/* This function is unsupported, and not considered part of the PDFlib API! */
798PDFLIB_API void PDFLIB_CALL
799PDF_set_text_matrix(PDF *p,
800    float a, float b, float c, float d, float e, float f);
801
802/* Set the text output position. */
803PDFLIB_API void PDFLIB_CALL
804PDF_set_text_pos(PDF *p, float x, float y);
805
806/* Print text in the current font and size at the current position. */
807PDFLIB_API void PDFLIB_CALL
808PDF_show(PDF *p, const char *text);
809
810/* Same as PDF_show() but with explicit string length. */
811PDFLIB_API void PDFLIB_CALL
812PDF_show2(PDF *p, const char *text, int len);
813
814/* Format text in the current font and size into the supplied text box
815 * according to the requested formatting mode, which must be one of
816 * "left", "right", "center", "justify", or "fulljustify". If width and height
817 * are 0, only a single line is placed at the point (left, top) in the
818 * requested mode. */
819PDFLIB_API int PDFLIB_CALL
820PDF_show_boxed(PDF *p, const char *text, float left, float top,
821    float width, float height, const char *hmode, const char *feature);
822
823/* Same as PDF_show_boxed() but with explicit string length.
824   (unsupported) */
825PDFLIB_API int PDFLIB_CALL
826PDF_show_boxed2(PDF *p, const char *text, int len, float left, float top,
827    float width, float height, const char *hmode, const char *feature);
828
829/* Print text in the current font at (x, y). */
830PDFLIB_API void PDFLIB_CALL
831PDF_show_xy(PDF *p, const char *text, float x, float y);
832
833/* Same as PDF_show_xy() but with explicit string length. */
834PDFLIB_API void PDFLIB_CALL
835PDF_show_xy2(PDF *p, const char *text, int len, float x, float y);
836
837/* Return the width of text in an arbitrary font. */
838PDFLIB_API float PDFLIB_CALL
839PDF_stringwidth(PDF *p, const char *text, int font, float fontsize);
840
841/* Same as PDF_stringwidth but with explicit string length. */
842PDFLIB_API float PDFLIB_CALL
843PDF_stringwidth2(PDF *p, const char *text, int len, int font, float fontsize);
844/* }}} */
845
846
847/* {{{ p_type3.c: Type 3 (user-defined) fonts
848 * ----------------------------------------------------------------------
849 */
850
851/* Start a type 3 font definition. */
852PDFLIB_API void PDFLIB_CALL
853PDF_begin_font(PDF *p, const char *fontname, int reserved,
854    float a, float b, float c, float d, float e, float f, const char *optlist);
855
856/* Start a type 3 glyph definition. */
857PDFLIB_API void PDFLIB_CALL
858PDF_begin_glyph(PDF *p, const char *glyphname, float wx,
859    float llx, float lly, float urx, float ury);
860
861/* Terminate a type 3 font definition. */
862PDFLIB_API void PDFLIB_CALL
863PDF_end_font(PDF *p);
864
865/* Terminate a type 3 glyph definition. */
866PDFLIB_API void PDFLIB_CALL
867PDF_end_glyph(PDF *p);
868/* }}} */
869
870
871/* {{{ p_xgstate.c: explicit graphic states
872 * ----------------------------------------------------------------------
873 */
874
875/* Create a gstate object definition. */
876PDFLIB_API int PDFLIB_CALL
877PDF_create_gstate(PDF *p, const char *optlist);
878
879/* Activate a gstate object. */
880PDFLIB_API void PDFLIB_CALL
881PDF_set_gstate(PDF *p, int gstate);
882/* }}} */
883
884
885typedef struct
886{
887    jmp_buf	jbuf;
888} pdf_jmpbuf;
889
890
891/*
892 * ----------------------------------------------------------------------
893 * PDFlib API structure with function pointers to all API functions
894 * ----------------------------------------------------------------------
895 */
896
897/* The API structure with pointers to all PDFlib API functions */
898struct PDFlib_api_s {
899    /* version numbers for checking the DLL against client code */
900    size_t sizeof_PDFlib_api;	/* size of this structure */
901
902    int major;			/* PDFlib major version number */
903    int minor;			/* PDFlib minor version number */
904    int revision;		/* PDFlib revision number */
905
906    int reserved;		/* reserved */
907
908    /* {{{ p_annots.c: file attachments, notes, and links */
909    void (PDFLIB_CALL * PDF_add_launchlink)(PDF *p,
910    		float llx, float lly, float urx,
911		float ury, const char *filename);
912    void (PDFLIB_CALL * PDF_add_locallink)(PDF *p,
913    		float llx, float lly, float urx,
914		float ury, int page, const char *optlist);
915    void (PDFLIB_CALL * PDF_add_note)(PDF *p, float llx, float lly,
916    		float urx, float ury, const char *contents, const char *title,
917		const char *icon, int open);
918    void (PDFLIB_CALL * PDF_add_note2) (PDF *p, float llx, float lly,
919		float urx, float ury, const char *contents, int len_cont,
920		const char *title, int len_title, const char *icon, int open);
921    void (PDFLIB_CALL * PDF_add_pdflink)(PDF *p,
922    		float llx, float lly, float urx,
923		float ury, const char *filename, int page, const char *optlist);
924    void (PDFLIB_CALL * PDF_add_weblink)(PDF *p,
925    		float llx, float lly, float urx, float ury, const char *url);
926    void (PDFLIB_CALL * PDF_attach_file)(PDF *p, float llx, float lly,
927    		float urx, float ury, const char *filename,
928		const char *description,
929		const char *author, const char *mimetype, const char *icon);
930    void (PDFLIB_CALL * PDF_attach_file2) (PDF *p, float llx, float lly,
931                float urx, float ury, const char *filename, int reserved,
932		const char *description, int len_descr, const char *author,
933		int len_auth, const char *mimetype, const char *icon);
934    void (PDFLIB_CALL * PDF_set_border_color)(PDF *p,
935				    float red, float green, float blue);
936    void (PDFLIB_CALL * PDF_set_border_dash)(PDF *p, float b, float w);
937
938    void (PDFLIB_CALL * PDF_set_border_style)(PDF *p,
939				    const char *style, float width);
940    /* }}} */
941
942    /* {{{ p_basic.c: general functions */
943    void (PDFLIB_CALL * PDF_begin_page)(PDF *p, float width,
944    				float height);
945    void (PDFLIB_CALL * PDF_boot)(void);
946    void (PDFLIB_CALL * PDF_close)(PDF *p);
947    void (PDFLIB_CALL * PDF_delete)(PDF *);
948    void (PDFLIB_CALL * PDF_end_page)(PDF *p);
949    const PDFlib_api * (PDFLIB_CALL * PDF_get_api)(void);
950    const char * (PDFLIB_CALL * PDF_get_apiname) (PDF *p);
951    const char * (PDFLIB_CALL * PDF_get_buffer)(PDF *p, long *size);
952    const char * (PDFLIB_CALL * PDF_get_errmsg) (PDF *p);
953    int (PDFLIB_CALL * PDF_get_errnum) (PDF *p);
954    int  (PDFLIB_CALL * PDF_get_majorversion)(void);
955    int  (PDFLIB_CALL * PDF_get_minorversion)(void);
956    void * (PDFLIB_CALL * PDF_get_opaque)(PDF *p);
957    PDF* (PDFLIB_CALL * PDF_new)(void);
958    PDF* (PDFLIB_CALL * PDF_new2)(errorproc_t errorhandler,
959    				allocproc_t allocproc,
960				reallocproc_t reallocproc,
961				freeproc_t freeproc, void *opaque);
962    int  (PDFLIB_CALL * PDF_open_file)(PDF *p, const char *filename);
963    int  (PDFLIB_CALL * PDF_open_fp)(PDF *p, FILE *fp);
964    void (PDFLIB_CALL * PDF_open_mem)(PDF *p, writeproc_t writeproc);
965    void (PDFLIB_CALL * PDF_shutdown)(void);
966	pdf_jmpbuf * (PDFLIB_CALL * pdf_jbuf)(PDF *p);
967	void (PDFLIB_CALL * pdf_exit_try)(PDF *p);
968	int  (PDFLIB_CALL * pdf_catch)(PDF *p);
969	void (PDFLIB_CALL * pdf_rethrow)(PDF *p);
970
971    /* }}} */
972
973    /* {{{ p_block.c: Variable Data Processing with blocks */
974    int (PDFLIB_CALL * PDF_fill_imageblock) (PDF *p, int page,
975		const char *blockname, int image, const char *optlist);
976    int (PDFLIB_CALL * PDF_fill_pdfblock) (PDF *p, int page,
977	    const char *blockname, int contents, const char *optlist);
978    int (PDFLIB_CALL * PDF_fill_textblock) (PDF *p, int page,
979	    const char *blockname, const char *text, int len,
980	    const char *optlist);
981    /* }}} */
982
983    /* {{{ p_color.c: color handling */
984    int  (PDFLIB_CALL * PDF_makespotcolor)(PDF *p, const char *spotname,
985                        int reserved);
986    void (PDFLIB_CALL * PDF_setcolor)(PDF *p,
987			const char *fstype, const char *colorspace,
988			float c1, float c2, float c3, float c4);
989    void (PDFLIB_CALL * PDF_setgray)(PDF *p, float gray);
990    void (PDFLIB_CALL * PDF_setgray_stroke)(PDF *p, float gray);
991    void (PDFLIB_CALL * PDF_setgray_fill)(PDF *p, float gray);
992    void (PDFLIB_CALL * PDF_setrgbcolor)(PDF *p, float red, float green,
993    			float blue);
994    void (PDFLIB_CALL * PDF_setrgbcolor_fill)(PDF *p,
995			float red, float green, float blue);
996    void (PDFLIB_CALL * PDF_setrgbcolor_stroke)(PDF *p,
997			float red, float green, float blue);
998    /* }}} */
999
1000    /* {{{ p_draw.c: path construction, painting, and clipping */
1001    void (PDFLIB_CALL * PDF_arc)(PDF *p, float x, float y,
1002				    float r, float alpha, float beta);
1003    void (PDFLIB_CALL * PDF_arcn)(PDF *p, float x, float y,
1004				    float r, float alpha, float beta);
1005    void (PDFLIB_CALL * PDF_circle)(PDF *p, float x, float y, float r);
1006    void (PDFLIB_CALL * PDF_clip)(PDF *p);
1007    void (PDFLIB_CALL * PDF_closepath)(PDF *p);
1008    void (PDFLIB_CALL * PDF_closepath_fill_stroke)(PDF *p);
1009    void (PDFLIB_CALL * PDF_closepath_stroke)(PDF *p);
1010    void (PDFLIB_CALL * PDF_curveto)(PDF *p, float x_1, float y_1,
1011				float x_2, float y_2, float x_3, float y_3);
1012    void (PDFLIB_CALL * PDF_endpath)(PDF *p);
1013    void (PDFLIB_CALL * PDF_fill)(PDF *p);
1014    void (PDFLIB_CALL * PDF_fill_stroke)(PDF *p);
1015    void (PDFLIB_CALL * PDF_lineto)(PDF *p, float x, float y);
1016    void (PDFLIB_CALL * PDF_moveto)(PDF *p, float x, float y);
1017    void (PDFLIB_CALL * PDF_rect)(PDF *p, float x, float y,
1018				    float width, float height);
1019    void (PDFLIB_CALL * PDF_stroke)(PDF *p);
1020    /* }}} */
1021
1022    /*  {{{ p_encoding.c: encoding handling */
1023    void (PDFLIB_CALL * PDF_encoding_set_char) (PDF *p, const char *encoding,
1024			    int slot, const char *glyphname, int uv);
1025    /* }}} */
1026
1027    /* {{{ p_font.c: text and font handling */
1028    int  (PDFLIB_CALL * PDF_findfont)(PDF *p, const char *fontname,
1029			    const char *encoding, int embed);
1030    int (PDFLIB_CALL * PDF_load_font)(PDF *p, const char *fontname,
1031		int len, const char *encoding, const char *optlist);
1032    void (PDFLIB_CALL * PDF_setfont)(PDF *p, int font, float fontsize);
1033    /* }}} */
1034
1035    /* {{{ p_gstate.c graphics state */
1036    void (PDFLIB_CALL * PDF_concat)(PDF *p, float a, float b,
1037				    float c, float d, float e, float f);
1038    void (PDFLIB_CALL * PDF_initgraphics)(PDF *p);
1039    void (PDFLIB_CALL * PDF_restore)(PDF *p);
1040    void (PDFLIB_CALL * PDF_rotate)(PDF *p, float phi);
1041    void (PDFLIB_CALL * PDF_save)(PDF *p);
1042    void (PDFLIB_CALL * PDF_scale)(PDF *p, float sx, float sy);
1043    void (PDFLIB_CALL * PDF_setdash)(PDF *p, float b, float w);
1044    void (PDFLIB_CALL * PDF_setdashpattern) (PDF *p, const char *optlist);
1045    void (PDFLIB_CALL * PDF_setflat)(PDF *p, float flatness);
1046    void (PDFLIB_CALL * PDF_setlinecap)(PDF *p, int linecap);
1047    void (PDFLIB_CALL * PDF_setlinejoin)(PDF *p, int linejoin);
1048    void (PDFLIB_CALL * PDF_setlinewidth)(PDF *p, float width);
1049    void (PDFLIB_CALL * PDF_setmatrix)(PDF *p, float a, float b,
1050				    float c, float d, float e, float f);
1051    void (PDFLIB_CALL * PDF_setmiterlimit)(PDF *p, float miter);
1052    void (PDFLIB_CALL * PDF_setpolydash)(PDF *p, float *dasharray,
1053				    int length);
1054    void (PDFLIB_CALL * PDF_skew)(PDF *p, float alpha, float beta);
1055    void (PDFLIB_CALL * PDF_translate)(PDF *p, float tx, float ty);
1056    /* }}} */
1057
1058    /* {{{ p_hyper.c: bookmarks and document info fields */
1059    int (PDFLIB_CALL * PDF_add_bookmark)(PDF *p, const char *text,
1060	    int parent, int open);
1061    int (PDFLIB_CALL * PDF_add_bookmark2) (PDF *p, const char *text, int len,
1062	    int parent, int open);
1063    void (PDFLIB_CALL * PDF_add_nameddest) (PDF *p, const char *name,
1064	    int reserved, const char *optlist);
1065    void (PDFLIB_CALL * PDF_set_info)(PDF *p, const char *key,
1066	    const char *value);
1067    void (PDFLIB_CALL * PDF_set_info2) (PDF *p, const char *key,
1068	    const char *value, int len);
1069    /* }}} */
1070
1071    /* {{{ p_icc.c: ICC profile handling */
1072    int  (PDFLIB_CALL * PDF_load_iccprofile)(PDF *p, const char *profilename,
1073                        int reserved, const char *optlist);
1074    /* }}} */
1075
1076    /* {{{ p_image.c: image handling */
1077    void (PDFLIB_CALL * PDF_add_thumbnail)(PDF *p, int image);
1078    void (PDFLIB_CALL * PDF_close_image)(PDF *p, int image);
1079    void (PDFLIB_CALL * PDF_fit_image) (PDF *p, int image, float x, float y,
1080	    const char *optlist);
1081    int (PDFLIB_CALL * PDF_load_image) (PDF *p, const char *imagetype,
1082	    const char *filename, int reserved, const char *optlist);
1083    int (PDFLIB_CALL * PDF_open_CCITT)(PDF *p, const char *filename,
1084    			int width, int height,
1085			int BitReverse, int K, int BlackIs1);
1086    int (PDFLIB_CALL * PDF_open_image)(PDF *p, const char *imagetype,
1087		const char *source, const char *data, long length, int width,
1088		int height, int components, int bpc, const char *params);
1089    int (PDFLIB_CALL * PDF_open_image_file)(PDF *p, const char *imagetype,
1090		const char *filename, const char *stringparam, int intparam);
1091    void (PDFLIB_CALL * PDF_place_image)(PDF *p, int image,
1092					float x, float y, float scale);
1093    /* }}} */
1094
1095    /* {{{ p_kerning.c: font kerning */
1096    /* }}} */
1097
1098    /* {{{ p_params.c: parameter handling */
1099    const char* (PDFLIB_CALL * PDF_get_parameter)(PDF *p,
1100				const char *key, float modifier);
1101    float (PDFLIB_CALL * PDF_get_value)(PDF *p, const char *key,
1102    				float modifier);
1103    void (PDFLIB_CALL * PDF_set_parameter)(PDF *p,
1104				const char *key, const char *value);
1105    void (PDFLIB_CALL * PDF_set_value)(PDF *p, const char *key,
1106    				float value);
1107    /* }}} */
1108
1109    /* {{{ p_pattern.c: pattern definition */
1110    int  (PDFLIB_CALL * PDF_begin_pattern)(PDF *p,
1111    			float width, float height,
1112			float xstep, float ystep, int painttype);
1113    void (PDFLIB_CALL * PDF_end_pattern)(PDF *p);
1114    /* }}} */
1115
1116    /* {{{ p_pdi.c: PDF import (requires the PDI library) */
1117    void (PDFLIB_CALL * PDF_close_pdi)(PDF *p, int doc);
1118    void (PDFLIB_CALL * PDF_close_pdi_page)(PDF *p, int page);
1119    void (PDFLIB_CALL * PDF_fit_pdi_page) (PDF *p, int page, float x,
1120	    float y, const char *optlist);
1121    const char * (PDFLIB_CALL * PDF_get_pdi_parameter)(PDF *p,
1122		    const char *key, int doc, int page, int reserved, int *len);
1123    float (PDFLIB_CALL * PDF_get_pdi_value)(PDF *p, const char *key,
1124					    int doc, int page, int reserved);
1125    int  (PDFLIB_CALL * PDF_open_pdi)(PDF *p, const char *filename,
1126				const char *optlist, int reserved);
1127    int (PDFLIB_CALL * PDF_open_pdi_callback) (PDF *p, void *opaque,
1128	    size_t filesize, size_t (*readproc)(void *opaque, void *buffer,
1129	    size_t size), int (*seekproc)(void *opaque, long offset),
1130	    const char *optlist);
1131    int  (PDFLIB_CALL * PDF_open_pdi_page)(PDF *p,
1132				int doc, int pagenumber, const char *optlist);
1133    void (PDFLIB_CALL * PDF_place_pdi_page)(PDF *p, int page,
1134				float x, float y, float sx, float sy);
1135    int (PDFLIB_CALL * PDF_process_pdi)(PDF *p,
1136				int doc, int page, const char *optlist);
1137    /* }}} */
1138
1139    /* {{{ p_resource.c: resources and virtual file system handling */
1140    void (PDFLIB_CALL * PDF_create_pvf)(PDF *p, const char *filename,
1141                            int reserved, const void *data, size_t size,
1142                            const char *options);
1143    int (PDFLIB_CALL * PDF_delete_pvf)(PDF *p, const char *filename,
1144                            int reserved);
1145    /* }}} */
1146
1147    /* {{{ p_shading.c: shadings */
1148    int (PDFLIB_CALL * PDF_shading) (PDF *p, const char *shtype, float x_0,
1149	    float y_0, float x_1, float y_1, float c_1, float c_2, float c_3,
1150	    float c_4, const char *optlist);
1151    int (PDFLIB_CALL * PDF_shading_pattern) (PDF *p, int shading,
1152	    const char *optlist);
1153    void (PDFLIB_CALL * PDF_shfill) (PDF *p, int shading);
1154    /* }}} */
1155
1156    /* {{{ p_template.c: template definition */
1157    int  (PDFLIB_CALL * PDF_begin_template)(PDF *p,
1158    			float width, float height);
1159    void (PDFLIB_CALL * PDF_end_template)(PDF *p);
1160    /* }}} */
1161
1162    /* {{{ p_text.c: text output */
1163    void (PDFLIB_CALL * PDF_continue_text)(PDF *p, const char *text);
1164    void (PDFLIB_CALL * PDF_continue_text2)(PDF *p, const char *text,
1165					    int len);
1166    void (PDFLIB_CALL * PDF_fit_textline)(PDF *p, const char *text,
1167                         int len, float x, float y, const char *optlist);
1168    void (PDFLIB_CALL * PDF_set_text_pos)(PDF *p, float x, float y);
1169    void (PDFLIB_CALL * PDF_show)(PDF *p, const char *text);
1170    void (PDFLIB_CALL * PDF_show2)(PDF *p, const char *text, int len);
1171    int  (PDFLIB_CALL * PDF_show_boxed)(PDF *p, const char *text,
1172                        float left, float top, float width, float height,
1173                        const char *hmode, const char *feature);
1174    void (PDFLIB_CALL * PDF_show_xy)(PDF *p, const char *text, float x,
1175    			float y);
1176    void (PDFLIB_CALL * PDF_show_xy2)(PDF *p, const char *text,
1177					    int len, float x, float y);
1178    float (PDFLIB_CALL * PDF_stringwidth)(PDF *p,
1179                                const char *text, int font, float fontsize);
1180    float (PDFLIB_CALL * PDF_stringwidth2)(PDF *p, const char *text,
1181                                            int len, int font, float fontsize);
1182    /* }}} */
1183
1184    /* {{{ p_type3.c: Type 3 (user-defined) fonts */
1185    void (PDFLIB_CALL * PDF_begin_font)(PDF *p, const char *fontname,
1186        int reserved, float a, float b, float c, float d, float e, float f,
1187        const char *optlist);
1188    void (PDFLIB_CALL * PDF_begin_glyph)(PDF *p, const char *glyphname,
1189	float wx, float llx, float lly, float urx, float ury);
1190    void (PDFLIB_CALL * PDF_end_font)(PDF *p);
1191    void (PDFLIB_CALL * PDF_end_glyph)(PDF *p);
1192    /* }}} */
1193
1194    /* {{{ p_xgstate.c: explicit graphic states */
1195    int (PDFLIB_CALL * PDF_create_gstate) (PDF *p, const char *optlist);
1196    void (PDFLIB_CALL * PDF_set_gstate) (PDF *p, int gstate);
1197    /* }}} */
1198};
1199
1200/*
1201 * ----------------------------------------------------------------------
1202 * page size formats
1203 * ----------------------------------------------------------------------
1204 */
1205
1206/* The page sizes are only available to the C and C++ bindings */
1207#define a0_width	 (float) 2380.0
1208#define a0_height	 (float) 3368.0
1209#define a1_width	 (float) 1684.0
1210#define a1_height	 (float) 2380.0
1211#define a2_width	 (float) 1190.0
1212#define a2_height	 (float) 1684.0
1213#define a3_width	 (float) 842.0
1214#define a3_height	 (float) 1190.0
1215#define a4_width	 (float) 595.0
1216#define a4_height	 (float) 842.0
1217#define a5_width	 (float) 421.0
1218#define a5_height	 (float) 595.0
1219#define a6_width	 (float) 297.0
1220#define a6_height	 (float) 421.0
1221#define b5_width	 (float) 501.0
1222#define b5_height	 (float) 709.0
1223#define letter_width	 (float) 612.0
1224#define letter_height	 (float) 792.0
1225#define legal_width 	 (float) 612.0
1226#define legal_height 	 (float) 1008.0
1227#define ledger_width	 (float) 1224.0
1228#define ledger_height	 (float) 792.0
1229#define p11x17_width	 (float) 792.0
1230#define p11x17_height	 (float) 1224.0
1231
1232
1233/*
1234 * ----------------------------------------------------------------------
1235 * exception handling with try/catch implementation
1236 * ----------------------------------------------------------------------
1237 */
1238
1239/* Set up an exception handling frame; must always be paired with PDF_CATCH().*/
1240
1241#define PDF_TRY(p)		if (p) { if (setjmp(pdf_jbuf(p)->jbuf) == 0)
1242
1243/* Inform the exception machinery that a PDF_TRY() will be left without
1244   entering the corresponding PDF_CATCH( ) clause. */
1245#define PDF_EXIT_TRY(p)		pdf_exit_try(p)
1246
1247/* Catch an exception; must always be paired with PDF_TRY(). */
1248#define PDF_CATCH(p)		} if (pdf_catch(p))
1249
1250/* Re-throw an exception to another handler. */
1251#define PDF_RETHROW(p)		pdf_rethrow(p)
1252
1253/*
1254 * ----------------------------------------------------------------------
1255 * End of public declarations
1256 * ----------------------------------------------------------------------
1257 */
1258
1259
1260/*
1261 * ----------------------------------------------------------------------
1262 * Private stuff, do not use explicitly but only via the above macros!
1263 * ----------------------------------------------------------------------
1264 */
1265
1266PDFLIB_API pdf_jmpbuf * PDFLIB_CALL
1267pdf_jbuf(PDF *p);
1268
1269PDFLIB_API void PDFLIB_CALL
1270pdf_exit_try(PDF *p);
1271
1272PDFLIB_API int PDFLIB_CALL
1273pdf_catch(PDF *p);
1274
1275PDFLIB_API void PDFLIB_CALL
1276pdf_rethrow(PDF *p);
1277
1278PDFLIB_API void PDFLIB_CALL
1279pdf_throw(PDF *p, const char *binding, const char *apiname, const char *errmsg);
1280
1281
1282/*
1283 * ----------------------------------------------------------------------
1284 * End of useful stuff
1285 * ----------------------------------------------------------------------
1286 */
1287
1288
1289#ifdef __cplusplus
1290}	/* extern "C" */
1291#endif
1292
1293#if defined(__MWERKS__) && defined(PDFLIB_EXPORTS)
1294#pragma export off
1295#endif
1296
1297#endif	/* PDFLIB_H */
1298
1299/*
1300 * vim600: sw=4 fdm=marker
1301 */
1302