From ea3f9b67e5e4e4b3453df55af9758a94c023d6f7 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Sun, 20 Sep 2026 14:50:05 +0200 Subject: pdf: minimal PDF writer for generated documents --- src/pdf.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/pdf.h (limited to 'src/pdf.h') diff --git a/src/pdf.h b/src/pdf.h new file mode 100644 index 0000000..c6f95ac --- /dev/null +++ b/src/pdf.h @@ -0,0 +1,27 @@ +#ifndef BOKF_PDF_H +#define BOKF_PDF_H + +#include + +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 -- cgit v1.3