Documents for Excel, Java Edition Documentation
Manage File Operations / Export to a PDF File / Support Document Properties
In This Topic
    Support Document Properties
    In This Topic

    GcExcel 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.

    Copy Code
    Workbook workbook = new Workbook();
    // Fetch default worksheet
    IWorksheet worksheet = workbook.getWorksheets().get(0);
    worksheet.getRange("A1").setValue("GrapeCity Documents for Excel");
    // Load an image from a specific file in input stream
    InputStream inputStream = ClassLoader.getSystemResourceAsStream("grapecity.png");
    try {
        byte[] bytes = new byte[inputStream.available()];
        // Read an image from input stream, 0, bytes.length);
        // Add background image of the worksheet
    } catch (IOException ioe) {
    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
    // Print the background picture in the centre of exported pdf file
    // Saving workbook to pdf"12-PrintBackgroundPicture.pdf", pdfSaveOptions);