import fitz
MEDIABOX = fitz.paper_rect("letter")
WHERE = MEDIABOX + (36, 36, -36, -36)
# create story, let it look at script folder for resources
story = fitz.Story(archive=".")
body = story.body # access the body of its DOM
with body.add_paragraph() as para:
# store desired content
para.set_font("sans-serif").set_color("blue").add_text("Hello World!")
# another paragraph for our image:
with body.add_paragraph() as para:
# store image in another paragraph
para.add_image("world.jpg")
writer = fitz.DocumentWriter("output.pdf")
more = 1
while more:
device = writer.begin_page(MEDIABOX)
more, _ = story.place(WHERE)
story.draw(device)
writer.end_page()
writer.close()
Here is some inline code
ok...