[]
使用此类可以定义 PDF 元数据,例如生成文档时要使用的标题、作者、主题、关键字、创建者、制作者、创建日期、修改日期和 PDF 版本。将实例分配给 PdfSaveOptions.setDocumentProperties(DocumentProperties) 可在 PDF 导出期间应用这些属性。
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getRange("A1").setValue("Quarterly Sales Summary");
DocumentProperties documentProperties = new DocumentProperties();
documentProperties.setTitle("Quarterly Sales Summary");
documentProperties.setAuthor("Author");
documentProperties.setPdfVersion(1.5f);
PdfSaveOptions options = new PdfSaveOptions();
options.setDocumentProperties(documentProperties);
String fileName = "DocumentProperties.pdf";
workbook.save(fileName, options);
floatgetTitle()voidvoidsetCreationDate(Calendar value) voidsetCreator(String value) voidsetKeywords(String value) voidsetModifyDate(Calendar value) voidsetPdfVersion(float value) voidsetProducer(String value) voidsetSubject(String value) voidtoString()此值指定生成文档时使用的 PDF 版本。
DocumentProperties properties = new DocumentProperties();
properties.setPdfVersion(1.4f);
float pdfVersion = properties.getPdfVersion();
此值指定生成文档时使用的 PDF 版本。
DocumentProperties properties = new DocumentProperties();
properties.setPdfVersion(1.4f);
value - 生成的文档的 PDF 版本。此属性指定存储在文档属性中的标题。
DocumentProperties properties = new DocumentProperties();
properties.setTitle("Quarterly Sales Summary");
String title = properties.getTitle();
此属性指定存储在文档属性中的标题。
DocumentProperties properties = new DocumentProperties();
properties.setTitle("Quarterly Sales Summary");
value - 文档的标题。
DocumentProperties properties = new DocumentProperties();
properties.setAuthor("Author");
String author = properties.getAuthor();
null。
DocumentProperties properties = new DocumentProperties();
properties.setAuthor("Author");
value - 创建文档的人员姓名。如果未设置作者,则设置为 null。使用此属性可获取与文档关联的主题元数据。
DocumentProperties properties = new DocumentProperties();
properties.setSubject("Quarterly Sales Summary");
String subject = properties.getSubject();
使用此属性可设置与文档关联的主题元数据。
DocumentProperties properties = new DocumentProperties();
properties.setSubject("Quarterly Sales Summary");
value - 文档的主题。返回的字符串包含以逗号分隔的文档关键字列表。
DocumentProperties properties = new DocumentProperties();
properties.setKeywords("report, sales, quarterly");
String keywords = properties.getKeywords();
null。返回的字符串包含以逗号分隔的文档关键字列表。
DocumentProperties properties = new DocumentProperties();
properties.setKeywords("report, sales, quarterly");
value - 与文档关联的以逗号分隔的关键字;如果未设置关键字,则为 null。此值表示原始文档或应用程序创建者。它不同于 getProducer(),后者标识生成 PDF 文档的应用程序或库。
DocumentProperties properties = new DocumentProperties();
properties.setCreator("Report Designer");
String creator = properties.getCreator();
null。此值表示原始文档或应用程序创建者。它不同于 getProducer(),后者标识生成 PDF 文档的应用程序或库。
DocumentProperties properties = new DocumentProperties();
properties.setCreator("Report Designer");
value - 创建原始文档的应用程序的名称;如果未设置,则为 null。此值表示 PDF 生成器或导出器,并且不同于 getCreator(),后者标识原始文档或应用程序创建者。
DocumentProperties properties = new DocumentProperties();
properties.setProducer("PDF Exporter");
String producer = properties.getProducer();
null。此值表示 PDF 生成器或导出器,并且不同于 getCreator(),后者标识原始文档或应用程序创建者。
DocumentProperties properties = new DocumentProperties();
properties.setProducer("PDF Exporter");
value - 生成 PDF 文档的应用程序或库的名称。如果未设置制作者,则设置为 null。使用此方法可以检索先前通过 setCreationDate(Calendar) 为 PDF 文档属性分配的值。
DocumentProperties properties = new DocumentProperties();
properties.setCreationDate(new GregorianCalendar(2019, 5, 24));
Calendar creationDate = properties.getCreationDate();
null。使用此方法可以分配存储在文档属性中的创建时间戳。
DocumentProperties properties = new DocumentProperties();
Calendar creationDate = new GregorianCalendar(2024, 2, 15, 10, 30, 0);
properties.setCreationDate(creationDate);
value - 要设置的创建日期和时间。此值可以为 null。使用此方法可以检索存储在此 DocumentProperties 实例中的修改时间戳。
DocumentProperties properties = new DocumentProperties();
properties.setModifyDate(new GregorianCalendar(2020, 5, 24));
Calendar modifyDate = properties.getModifyDate();
null。使用此属性可在 PDF 文档属性中存储修改时间戳。传递 null 会清除存储的修改日期。
DocumentProperties properties = new DocumentProperties();
properties.setCreationDate(new GregorianCalendar(2019, 5, 24));
properties.setModifyDate(new GregorianCalendar(2020, 5, 24));
value - 要设置的修改日期和时间。null 会清除存储的修改日期。