summaryrefslogtreecommitdiff
path: root/src/pdf.h
blob: 9ed4595cd1b319d31275713271bbd52575206466 (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
28
29
30
31
32
33
#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);
/* Draws utf8 at x/baseline, shrinking the size (down to min_size) to fit
   max_w; if it still does not fit, truncates at a whole UTF-8 character so
   the text ends with "...". */
void pdf_text_fit(struct pdf *p, double x, double baseline, const char *font,
                  double size, double min_size, double max_w, const char *rgb,
                  const char *utf8);
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