Steve Simpson (AVR IT Dept) wrote:

Hi,

I want to be able to set the PDF Producer, Title, Author, Subject and Keywords properties of a PDF file.

Can you tell me how to do this?

Thanks

Steve

New document:

Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("HelloWorldMetadata.pdf"));
document.addTitle("Hello World example");
document.addSubject("This example shows how to add metadata");
document.addKeywords("Metadata, iText, step 3");
document.addCreator("My program using iText");
document.addAuthor("Bruno Lowagie");
document.open();
document.add(new Paragraph("Hello World"));
document.close();

Existing document:

PdfReader reader = new PdfReader("HelloWorldNoMetadata.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloWorldStampedMetadata.pdf"));
HashMap info = reader.getInfo();
info.put("Subject", "Hello World");
info.put("Author", "Bruno Lowagie");
info.put("Keywords", "iText in Action, PdfStamper");
info.put("Title", "Hello World stamped");
info.put("Creator", "Silly standalone example");
stamper.setMoreInfo(info);
stamper.close();

The producer is set automatically and should refer to the iText version.
br,
Bruno


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to