Skip to content

Commit

Permalink
缓解Bug:输出PDF构建字体子集时的异常 (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroi-sora committed Jan 30, 2024
1 parent 99e7707 commit cad0657
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion UmiOCR-data/py_src/ocr/output/output_pdf_layered.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def print(self, res): # 输出图片结果
def onEnd(self): # 结束时保存。
print("保存PDF:", self.outputPath)
if self.pdf:
self.pdf.subset_fonts() # 构建字体子集,减小文件大小。需要 fontTools 库
try: # 对于部分PDF,如用txt直接打印的,构建字体子集会失败。
self.pdf.subset_fonts() # 构建字体子集,减小文件大小。需要 fontTools 库
except Exception as e: # TODO: 失败原因?可能文件中实际并没有字体?
print("[Warning] 构建字体子集失败:", e)
# ez_save默认启用压缩和垃圾回收 deflate=True, garbage=3
self.pdf.ez_save(self.outputPath)

0 comments on commit cad0657

Please sign in to comment.