[]
        
(Showing Draft Content)

支持文档属性

GcExcel在将Excel电子表格保存为PDF文档的同时提供对文档属性的支持。文档属性包含有关文档的基本信息,例如标题,作者,创建日期,主题,创建者,版本等。您可以在导出的PDF文档中存储这些有用的信息。

所述DocumentProperties 类包含方法如 setPdfVersion, setTitle, setAuthor, setSubject, setKeywords, setCreator, setProducer, setCreationDate 和 setModifyDate.

用例代码

请参考以下示例代码,以在导出的PDF文档中添加文档属性。

//create to a pdf file stream
FileOutputStream outputStream = null;
try {
    outputStream = new FileOutputStream("SetDocumentPropertiesToPDF.pdf");
} catch (FileNotFoundException e) {
    e.printStackTrace();
}
//create a new workbook
Workbook workbook = new Workbook();

IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getRange("A1").setValue("GrapeCity Documents for Excel");
worksheet.getRange("A1").getFont().setSize(25);

DocumentProperties documentProperties = new DocumentProperties();
//Sets the name of the person that created the PDF document.
documentProperties.setAuthor("Jaime Smith");
//Sets the title of thePDF document.
documentProperties.setTitle("GcPdf Document Info Sample");
//Set the PDF version.
documentProperties.setPdfVersion(1.5f);
//Set the subject of the PDF document.
documentProperties.setSubject("GcPdfDocument.DocumentInfo");
//Set the keyword associated with the PDF document.
documentProperties.setKeywords("Keyword1");
//Set the creation date and time of the PDF document.
documentProperties.setCreationDate(new GregorianCalendar(2019,5,24));
//Set the date and time the PDF document was most recently modified.
documentProperties.setModifyDate(new GregorianCalendar(2020,5,24));
//Set the name of the application that created the original PDF document.
documentProperties.setCreator("GcPdfWeb Creator");
//Set the name of the application that created the PDF document.
documentProperties.setProducer("GcPdfWeb Producer");


PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
//Sets the document properties of the pdf.
pdfSaveOptions.setDocumentProperties(documentProperties);