Example usage for com.lowagie.text Document addKeywords

List of usage examples for com.lowagie.text Document addKeywords

Introduction

In this page you can find the example usage for com.lowagie.text Document addKeywords.

Prototype


public boolean addKeywords(String keywords) 

Source Link

Document

Adds the keywords to a Document.

Usage

From source file:questions.metadata.UpdateModDate.java

public static void main(String[] args) {
    Document document = new Document();
    try {//  ww w  .  ja va 2  s .c  o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(ORIGINAL));
        document.addTitle("Hello World example");
        document.addSubject("This example shows how to add metadata");
        document.addKeywords("Metadata, iText, XMP");
        document.addCreator("My program using iText");
        document.addAuthor("Bruno Lowagie");
        writer.createXmpMetadata();
        document.open();
        document.add(new Paragraph("Hello World"));
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    PdfReader reader;
    try {
        reader = new PdfReader(ORIGINAL);
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(MODIFIED));
        stamper.close();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
}