aboutsummaryrefslogtreecommitdiff
path: root/src/pdf.h
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-20 14:50:05 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-20 14:50:05 +0200
commitea3f9b67e5e4e4b3453df55af9758a94c023d6f7 (patch)
tree3b248af093a62e5b2c9bd21a3111dcf8c22fee87 /src/pdf.h
parent412dfcca675114b582e4dc9d5739a889066e6277 (diff)
downloadbokf-ea3f9b67e5e4e4b3453df55af9758a94c023d6f7.tar.gz
bokf-ea3f9b67e5e4e4b3453df55af9758a94c023d6f7.zip
pdf: minimal PDF writer for generated documents
Diffstat (limited to 'src/pdf.h')
-rw-r--r--src/pdf.h27
1 files changed, 27 insertions, 0 deletions
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 <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