什么取代了 itext7 中的 Phrase?
What replaces Phrase in itext7?
我们代码库中的 itext 5 代码使用“Phrase”,如下所示。 itext 7 中是否有任何等效项?我认为“块”的替代品可能是 itext 7 中的“文本”,我知道字体的解决方法。但是找不到 Phrase 的任何内容。
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Font;
import com.itextpdf.text.Phrase;
public class PdfUtils {
public static void setFont(Phrase phrase, Font font) {
if (phrase == null) {
return;
}
for (Object object : phrase) {
if (object instanceof Chunk) {
Chunk chunk = (Chunk) object;
chunk.setFont(font);
}
}
phrase.setFont(font);
}
}
您可以使用 Paragraph.
Paragraph paragraph = new Paragraph();
paragraph.setFont(font);
Text text = new Text("test");
paragraph.add(text);
我们代码库中的 itext 5 代码使用“Phrase”,如下所示。 itext 7 中是否有任何等效项?我认为“块”的替代品可能是 itext 7 中的“文本”,我知道字体的解决方法。但是找不到 Phrase 的任何内容。
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Font;
import com.itextpdf.text.Phrase;
public class PdfUtils {
public static void setFont(Phrase phrase, Font font) {
if (phrase == null) {
return;
}
for (Object object : phrase) {
if (object instanceof Chunk) {
Chunk chunk = (Chunk) object;
chunk.setFont(font);
}
}
phrase.setFont(font);
}
}
您可以使用 Paragraph.
Paragraph paragraph = new Paragraph();
paragraph.setFont(font);
Text text = new Text("test");
paragraph.add(text);