Skip to content
Discussion options

You must be logged in to vote

Without really knowing the internals of the attached JSON info, let's assume it contains all the required text.
Then simply create a TextWriter object an append text piece by text piece

tw = fitz.TextWriter(page.rect)  # need the intended page's size here
# for each text piece (a word, a string, a character, ... everything goes)
tw.append(
    pos,  # the insertion point
    text,  # the text to insert
    font=font,  # a fitz.Font(...) object
    fontsize=fontsize,
   )
# ... repeat the above with arbitrary other fonts / fontsizes, when done:
tw.writeText(page, render_mode=3,...)  # write the whole text writer as hidden (render mode 3) text.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@sjscotti
Comment options

Answer selected by JorjMcKie
Comment options

You must be logged in to vote
1 reply
@sjscotti
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants