Reading the javadoc for PdfStamper.setMoreInfo() would have helped. To 
remove a key:

HashMap<String, String> info = (HashMap<String, String>)reader.getInfo();
info.put("CreationDate", null);
info.put("ModDate", null);
info.put("Author", "Bruno Lowagie");
stamp.setMoreInfo(info);

Paulo

----- Original Message ----- 
From: "David Kavanagh" <[EMAIL PROTECTED]>
To: "Post all your questions about iText here" 
<[email protected]>
Sent: Tuesday, March 13, 2007 8:01 PM
Subject: Re: [iText-questions] Supressing Creation/Mod Date and IDfrom 
output


> Bruno,
> I took your AddWaterMarkPageNumbers.java and stripped it down. It still
> produces a PDF with CreationDate and ModDate, even though I removed them
> from the reader info dictionary. Here's the code.
>
> David
>
>            PdfReader reader = new PdfReader(args[0]);
>            int n = reader.getNumberOfPages();
>            // we create a stamper that will copy the document to a new 
> file
>            PdfStamper stamp = new PdfStamper(reader, new
> FileOutputStream(args[1]));
>            // adding some metadata
>            HashMap<String, String> info = (HashMap<String,
> String>)reader.getInfo();
>            info.remove("CreationDate");
>            info.remove("ModDate");
>            for (String key : info.keySet()) {
>                System.err.println(key+" = "+info.get(key));
>            }
>            HashMap moreInfo = new HashMap();
>            moreInfo.put("Author", "Bruno Lowagie");
>            stamp.setMoreInfo(moreInfo);
>            // closing PdfStamper will generate the new PDF file
>            stamp.close();
>
> PS. I was removing PdfName.CREATIONDATE, etc, but that didn't actually
> remove the date from the dictionary.
>
> Thus Spoke Bruno Lowagie:
>
>>David Kavanagh wrote:
>>
>>
>>>I've used iText a couple of times and think it is a very nice package. I
>>>searched the archives and didn't find an answer to this.
>>>I have a service that performs OCR and produces a PDF. That document has
>>>a creation date which doesn't allow the service to be idempotent. Since
>>>that is one of our goals, I thought I'd use iText to clean up the PDF by
>>>removing the CreationDate. It turns out that CreationDate ModDate and ID
>>>are three things that iText puts into the output. I'd like to be able to
>>>supress those. Does anyone know how I can do that?
>>>
>>>
>>
>>So you have an existing PDF, and you want to remove
>>the CreationDate, ModDate and ID. Then you should use
>>PdfReader and PdfStamper. I uploaded a 'fix' recently
>>that adds an ID (because PdfStamper removes it), maybe
>>we'll need to make that an option in the future.
>>But for now, the current release removes the ID, and
>>you can remove the CreationDate and ModDate keys from
>>the Info dictionary in PdfReader.
>>br,
>>Bruno
>>
>>-------------------------------------------------------------------------
>>Take Surveys. Earn Cash. Influence the Future of IT
>>Join SourceForge.net's Techsay panel and you'll get the chance to share 
>>your
>>opinions on IT & business topics through brief surveys-and earn cash
>>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>>_______________________________________________
>>iText-questions mailing list
>>[email protected]
>>https://lists.sourceforge.net/lists/listinfo/itext-questions
>>Buy the iText book: http://itext.ugent.be/itext-in-action/
>>
>>
>


--------------------------------------------------------------------------------


> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share 
> your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


--------------------------------------------------------------------------------


> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
> 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to