package com.tutego.traida.util;
import java.io.FileOutputStream;
import java.util.HashMap;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
public class PdfUtils
{
public static void setMetaData( String sourceFilename, String targetFilename )
{
try
{
PdfReader pdfReader = new PdfReader( sourceFilename );
PdfStamper stamp = new PdfStamper( pdfReader, new FileOutputStream( targetFilename ) );
@SuppressWarnings("unchecked")
HashMap<String, String> info = pdfReader.getInfo();
info.put( "Title", "Rechnung für Beratung" );
info.put( "Author", "tutego" );
info.put( "Subject", "Rechnung" );
info.put( "Keywords", "Rechnung, tutego" );
info.put( "Creator", "http://www.tutego.com/" );
info.put( "Producer", "tutego Training Software 1.2" );
stamp.setMoreInfo( info );
stamp.close();
pdfReader.close();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
public static void main( String[] args )
{
setMetaData( "c:/a.pdf", "c:/new.pdf" );
}
}
With iText of course: http://www.lowagie.com/iText/