Skip to content
Discussion options

You must be logged in to vote

You can do this:

import fitz
doc=fitz.open()
page=doc.new_page()
tw=fitz.TextWriter(page.rect)
text = "Hello world!"
rect = fitz.Rect(100,100,300,300)
tw1 = fitz.TextWriter(page.rect)
tw1.fill_textbox(rect,text)
tw1.write_text(page,color=(1,0,0),render_mode=0)
tw1.write_text(page,color=(0,0,1),render_mode=1)
doc.ez_save("x.pdf")

You can write the same TextWriter multiple times - on the same or different pages.
Looks like this:

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@pietro-foini
Comment options

@JorjMcKie
Comment options

Answer selected by pietro-foini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants