gpt4 book ai didi

java - com.itextpdf.text.exceptions.IllegalPdfSyntaxException : Unbalanced begin/end text operators

转载 作者:行者123 更新时间:2023-12-01 17:00:41 24 4
gpt4 key购买 nike

在 iText 中使用 PdfContentByte 解决此问题。当我尝试创建新页面时,我使用以下代码-

           canvas = writer.getDirectContent();
canvas.saveState();


canvas.stroke();
canvas.restoreState();
...
canvas.endText();
itextDocument.newPage();

setUpperFontAndSize(canvas);
canvas.beginText();

该问题发生在调用 endText() 时。有什么办法解决吗?

最佳答案

OP 说

The issue is occurring at the time of calling endText()

根据该方法的源代码,该异常表明没有匹配的 beginText()之前打电话。

A text object begins with the BT operator and ends with the ET operator, as shown in the Example, and described in Table 107.

EXAMPLE

BT
…Zero or more text operators or other allowed operators…
ET

... text objects cannot be statically nested ...

关于java - com.itextpdf.text.exceptions.IllegalPdfSyntaxException : Unbalanced begin/end text operators,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27835553/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com