Skip to content
Discussion options

You must be logged in to vote

Your use of page.insert_textbox() is incorrect - see corrected version below.
Please also note, that this set of text insertions (insert_text / insert_textbox) doen't support writing right-to-left. You must either "emulate" this in your code by reverting such strings, or use TextWriter output, which has a right-to-left feature.

Other than that, text comes out correctly:

# pip install pymupdf
import fitz

# Load the PDF file
pdf_file = "Sample.pdf"
doc = fitz.open(pdf_file)

# Load the custom font
font_file1 = r"ZahraRoosta.ttf"
font_file2 = r"CascadiaCode-Regular.ttf"

# Loop through each page of the PDF
for page in doc:
    page.insert_font(fontfile=font_file1, fontname="F0")
    page.i…

Replies: 4 comments 12 replies

Comment options

You must be logged in to vote
6 replies
@411A
Comment options

@JorjMcKie
Comment options

@411A
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

Answer selected by 411A
Comment options

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

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@dalius415
Comment options

@dalius415
Comment options

@JorjMcKie
Comment options

@dalius415
Comment options

@JorjMcKie
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce
3 participants
Converted from issue

This discussion was converted from issue #2288 on March 15, 2023 13:21.