summaryrefslogtreecommitdiff
path: root/src/pdf.h
blob: c6f95ac736ef636604d507221a87037173c602ce (plain)
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
#ifndef BOKF_PDF_H
#define BOKF_PDF_H

#include <stddef.h>

struct pdf;

/* One-page A4 (595x842 pt) PDF 1.4 writer. Coordinates are in points with a
   top-left origin; pdf_text's baseline is measured from the top. Colours are
   "#rrggbb". Fonts are the base-14 Helvetica ("H") and Helvetica-Bold ("HB")
   with WinAnsiEncoding; UTF-8 input is converted to WinAnsi. */

struct pdf *pdf_new(void);
int pdf_page(struct pdf *p);
void pdf_fill_rect(struct pdf *p, double x, double y, double w, double h,
                   const char *rgb);
void pdf_line(struct pdf *p, double x1, double y1, double x2, double y2,
              double width, const char *rgb);
void pdf_text(struct pdf *p, double x, double baseline, const char *font,
              double size, const char *rgb, const char *utf8);
double pdf_text_width(const char *font, double size, const char *utf8);
double pdf_font_ascent(const char *font, double size);
void pdf_path(struct pdf *p, const char *path, double x, double y,
              const char *rgb);
unsigned char *pdf_finish(struct pdf *p, size_t *len);

#endif