将带有fitz的文本添加到特定的pdf时程序崩溃

问题描述

我想在特定文档的页面左上角添加文本,但是这样做会导致程序崩溃。该程序可与其他pdf一起很好地工作,但尤其是这一PDF会使我的程序崩溃。

代码Im用于添加文本

class Limpiar_pag:

    def __init__(self,page):
        self.page = page #Page I want to write on
        x_default,y_default,x1_default,y1_default = self.page.rect #Getting dimension of page as coordinates
        self.x_default,self.y_default,self.x1_default,self.y1_default = x_default,y1_default 
     
    def add_question_number(self,num_pregunta):

        text = "QUESTION " + str(num_pregunta) + "."
        where = fitz.Point(self.x_default + 50,self.y_default + 50)    # text starts here
        self.page.insertText(where,text,fontsize=20,color=(1,0),# some color (red)
                        overlay=True)      # text in foreground
    

我用来从我的程序中呼叫该类的代码

Limpiar_pag_ = Limpiar_pag(beginning_page)
Limpiar_pag_.add_question_number(self.total)

如前所述,它与除this one以外的所有pdf文件都可以正常使用。
有问题的页面第4页

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)