下面的示例演示了如何使用iText库设置各种属性,如作者姓名、创建日期、创建者姓名或者 pdf 文件的简单标题。
Document document = new Document();
try
{
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream('SetAttributeExample.pdf'));
document.open();
document.add(new Paragraph('Some content here'));
//Set attributes here
document.addAuthor('Jamez Gupta');
document.addCreationDate();
document.addCreator('onitroad.com');
document.addTitle('Set Attribute Example');
document.addSubject('An example to show how attributes can be added to pdf files.');
document.close();
writer.close();
} catch (Exception e)
{
e.printStackTrace();
}
日期:2020-09-17 00:09:30 来源:oir作者:oir
