Branch
Hash :
76e50487
Author :
Thomas de Grivel
Date :
2025-12-08T16:08:52
wip asan
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
require PDF.Write
PDF.Write
doc = PDF.Write.new_file("write.pdf")
(PDF.Write*) 1
image = PDF.Write.image_from_file(doc, "image.jpeg")
(U32) 4
font = PDF.Write.font_from_file(doc, "font.ttf")
(U32) 5
a4 = %PDF.Rect{w: (F32) 210,
h: (F32) 297}
%PDF.Rect{x: (F32) 0.0,
y: (F32) 0.0,
w: (F32) 2.099999e+2,
h: (F32) 2.97e+2}
page1 = PDF.Write.Page.new(doc, a4)
(PDF.Write.Page*) 1
x = (F32) 100
(F32) 1.0e+2
y = (F32) 200
(F32) 2.0e+2
font_size = (F32) 12
(F32) 1.2e+1
PDF.Write.Page.set_color_rgb(page1, (F32) 0, (F32) 0, (F32) 0)
(PDF.Write.Page*) 1
PDF.Write.Page.text(page1, x, y, font, font_size, "Test 123\nPlop")
(PDF.Write.Page*) 1
x = (F32) 10
(F32) 1.0e+1
y = (F32) 50
(F32) 5.0e+1
PDF.Write.Page.image(page1, x, y, image)
(PDF.Write.Page*) 1
rect = %PDF.Rect{x: (F32) 10,
y: (F32) 10,
w: (F32) 267,
h: (F32) 10}
%PDF.Rect{x: (F32) 1.0e+1,
y: (F32) 1.0e+1,
w: (F32) 2.67e+2,
h: (F32) 1.0e+1}
PDF.Write.Page.set_color_rgb(page1, (F32) 0, (F32) 0, (F32) 0)
(PDF.Write.Page*) 1
PDF.Write.Page.rectangle(page1, rect)
(PDF.Write.Page*) 1
PDF.Write.add_page(doc, page1)
(PDF.Write*) 1
PDF.Write.Page.delete(page1)
void
PDF.Write.close(doc)
void
PDF.Write.delete(doc)
void