/java/

PdfReader getMetaData

2013-06-24 21:31:17


<dependency>
<groupid>com.itextpdf</groupid>
<artifactid>itextpdf</artifactid>
<version>5.4.2</version>
</dependency>

import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.SimpleBookmark;

PdfReader reader = new PdfReader("/home/szalek/paka/dane/file.pdf");

System.out.println("Creator:" + reader.getInfo().get("Creator"));
System.out.println("Title:" + reader.getInfo().get("Title")); 
System.out.println("Producer:" + reader.getInfo().get("Producer"));
System.out.println("Author:" + reader.getInfo().get("Author"));
System.out.println("ModDate:" + reader.getInfo().get("ModDate"));
System.out.println("CreationDate:" + reader.getInfo().get("CreationDate"));
System.out.println("NumberOfPages:" + reader.getNumberOfPages());

List

<hashmap<string, object="">&gt; bookmarks = SimpleBookmark.getBookmark(reader);

if(bookmarks != null){
    for(HashMap<string, object=""> bookmark : bookmarks){
        System.out.println(bookmark);
        System.out.println("----------------");
    }
}