gpt4 book ai didi

java - 使用 iText 形成 PDF 文件

转载 作者:行者123 更新时间:2023-12-01 23:51:43 26 4
gpt4 key购买 nike

我使用以下代码通过 iText 显示 PDF 文件中的一行:

Phrase phraseHeader = new Phrase(18, new Chunk("Registration Form       "+registrationForm.getRegistrationDate(), FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD)));
Paragraph paragraph=new Paragraph(phraseHeader);
paragraph.setAlignment("center");
document.add(paragraph);

如果我运行此代码,pdf 文件将包含以下内容:

Registration Form        26-Apr-2013 11:58:20

我想以较大的字体显示“注册表”,以较小的字体显示日期/时间,但两者应该在同一行。我怎样才能做到这一点?

最佳答案

这应该可以解决问题:

    Phrase phraseHeader  = new Phrase();
phraseHeader.add(
new Chunk("Registration Form ",
FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD)));
phraseHeader.add(
new Chunk(registrationForm.getRegistrationDate(),
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)));

Paragraph paragraph = new Paragraph(phraseHeader);

关于java - 使用 iText 形成 PDF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16230664/

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