: asapien/signet

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 
/*
 * pdfw: tiny PDF writer for transparent stamp overlays and the audit page.
 * Text (embedded TrueType via Identity-H, or base-14 Helvetica as fallback)
 * and images (PNG with alpha -> SMask, JPEG passthrough).  Coordinates are
 * PDF user space: points, origin bottom-left.
 */
#ifndef SIGNET_PDFW_H
#define SIGNET_PDFW_H

typedef struct pdfw pdfw;

#define PDFW_HELVETICA 0

pdfw *pdfw_open(const char *path);
int pdfw_page(pdfw *, double w, double h);
/* returns a font id; falls back to PDFW_HELVETICA if the file is unusable */
int pdfw_font(pdfw *, const char *ttf_path);
double pdfw_text_width(pdfw *, int font, const char *utf8, double size);
/* ascent / descent as fractions of the font size; descent is negative */
void pdfw_font_metrics(pdfw *, int font, double *ascent, double *descent);
void pdfw_text(pdfw *, int font, double size, double x, double baseline,
    const char *utf8);
int pdfw_image_size(pdfw *, const char *path, int *w, int *h);
int pdfw_image(pdfw *, const char *path, double x, double y, double w,
    double h);
/* Clipping: pdfw_clip_circle begins a circular clip path, pdfw_clip_end ends it */
void pdfw_clip_circle(pdfw *, double cx, double cy, double r);
void pdfw_clip_end(pdfw *);
/* returns 0 only if every write succeeded */
int pdfw_close(pdfw *);

#endif