[FIXED] Adding metaData to existng pdf file


I am reading a pdf file using a path, and want to add meta data to it.

I know the adding metadata methods:

Documnt.addAuthor and ext...

But how do i get the existing pdf into a Document object?

I am reading the file like this:

PdfReader reader = new PdfReader(pdfFilePath);
FileOutputStream out = new FileOutputStream(outFile);
PdfStamper stamp = new PdfStamper(reader, out);


You can use: PdfStamper.setMoreInfo:

final HashMap<String, String> info = new HashMap<>();
if (title != null) {
    info.put("Title", title);
if (subject != null) {
    info.put("Subject", subject);
if (keywords != null) {
    info.put("Keywords", keywords);
if (creator != null) {
    info.put("Creator", creator);
if (author != null) {
    info.put("Author", author);


Answered By – epoch

Answer Checked By – Senaida (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published