Document Solutions for Excel, Java Edition | Document Solutions
File Operations / Export to PDF / Support Document Properties
In This Topic
    Support Document Properties
    In This Topic

    DsExcel provides support for document properties while saving Excel spreadsheets to PDF documents. The document properties contain the basic information about a document, such as title, author, creation date, subject, creator, version etc. You can store such useful information in the exported PDF document. 

    The DocumentProperties class contains the methods such as setPdfVersion, setTitle, setAuthor, setSubject, setKeywords, setCreator, setProducer, setCreationDate and setModifyDate.

    Using Code

    Refer to the following example code to add document properties in the exported PDF document.

    Java
    Copy Code
    //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("Document Solutions 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("DsPdf Document Info Sample");
    //Set the PDF version.
    documentProperties.setPdfVersion(1.5f);
    //Set the subject of the PDF document.
    documentProperties.setSubject("DsPdfDocument.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("DsPdfWeb Creator");
    //Set the name of the application that created the PDF document.
    documentProperties.setProducer("DsPdfWeb Producer");
    
    
    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
    //Sets the document properties of the pdf.
    pdfSaveOptions.setDocumentProperties(documentProperties);