pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roberto Nibali <rnib...@gmail.com>
Subject Re: Remove document information from PDF
Date Thu, 27 Aug 2015 11:43:20 GMT
Hi Tilman


On Thu, Aug 27, 2015 at 1:21 AM, Tilman Hausherr <THausherr@t-online.de>
wrote:

> See the AddMetadataFromDocInfo.java from the examples
>
>
> PDDocumentCatalog catalog = document.getDocumentCatalog();
>                 PDDocumentInformation info =
> document.getDocumentInformation();
>
>
> you can set stuff... and the example shows you how to do the same for the
> XMP meta data.
>
> See also the ExtractMetadata.java example.
>
>
Thanks for your valuable input. Last night I was puzzled by your answer,
after sleeping, I realized what you meant. I have solved it like follows:

private void stripInfo(PDDocument srcDoc) {
    PDDocumentInformation docInfo = srcDoc.getDocumentInformation();
    docInfo.setAuthor(null);
    docInfo.setCreationDate(null);
    docInfo.setCreator(null);
    docInfo.setKeywords(null);
    docInfo.setModificationDate(null);
    docInfo.setProducer(null);
    docInfo.setSubject(null);
    docInfo.setTitle(null);
    docInfo.setTrapped(null);
}

This is almost like you would supposedly do it with iText:

HashMap<String, String> info = super.reader.getInfo();
info.put("Title", null);
info.put("Author", null);
info.put("Subject", null);
info.put("Keywords", null);
info.put("Creator", null);
info.put("Producer", null;
info.put("CreationDate", null);
info.put("ModDate", null);
info.put("Trapped", null);
stamper.setMoreInfo(info);


Best regards
Roberto

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message