Replies: 8 comments 10 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Thank you. I can get letter info. Is it possible to change color and background color for the desired letters? How to change letter color /background color after I get below text box info.? Character: 'H', BBox: (50, 89.0, 54.84253845306543, 100) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
When I try to use a local font, below error occurs. How to solve it?
File "D:\Python3.8.8\lib\site-packages\pymupdf_init_.py", line 18203, in get_text_length 指定字体文件路径font_path = r'F:\fonts\SarasaTermSCNerd.ttc' # 下载字体文件simhei.ttf font_path = "path/to/your/font.ttf" # 替换为你的字体文件路径font = fitz.Font(fontfile=font_path) # pymupdf加载字体, choose a font with small caps page.insert_font(fontname="F0", fontbuffer=font.buffer) # 加载自定义字体font = fitz.Font(font_path)插入文本page.insert_text(start_point, text, fontsize=11, font=font) # 使用加载的自定义字体page.insert_text(start_point, text, fontsize=11, fontname="F0") # 使用加载的自定义字体 搜索文本以获取其矩形rect = page.search_for(text)[0] # 获取找到的第一个矩形 获取文本的总宽度total_width = fitz.get_text_length(text, fontsize=11, fontname='F0') # 使用字体文件名 ''' |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Another question is for below code. If there are 100 texts on one page, text may be either same or different. rect = page.search_for(text)[0] |
Beta Was this translation helpful? Give feedback.
-
Is space not included in blocks? source chars: ['賃', '金', '規', '程', '第', ' ', '4'] blocks: missing one space |
Beta Was this translation helpful? Give feedback.
-
Ending dot box may be wrong. And there may be some additional spaces at the end of line. |
Beta Was this translation helpful? Give feedback.
-
page.insert_text
Beta Was this translation helpful? Give feedback.
All reactions