Olivier BASTIN (506) wrote:
I have try with the Trailer and the value is null.
PdfDictionary dictionary = reader.getTrailer();
System.out.println(dictionary.get(PdfName.TITLE));
Of course it is null. Haven't you read my remark?
I wrote: "you will find a *reference* to the Info Dictionary in the
trailer."
This doesn't mean you will find the *title* in the trailer.
PDF is a little bit more complex than that.
You first have to ask the trailer where to find the info dictionary;
once you have this info dictionary, then you can fetch the title.
But why would you go into all that trouble, if getInfo() does
all this work for you?
Anyway, I am glad to see that iText is used in Belgium too;
sometimes I have the feeling that iText is used everywhere
except in my own country ;-)
br,
Bruno (Gent, Belgium)
Olivier
-----Message d'origine-----
De : bruno [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 7 avril 2006 11:04
À : Olivier BASTIN (506)
Cc : [email protected]
Objet : Re: [iText-questions] Retrieve Pdf Title
Olivier BASTIN (506) wrote:
Hi,
How to retrieve the pdf title?
You'd need something like this:
PdfReader reader = new PdfReader("my.pdf");
Map info = reader.getInfo();
String title = info.get("Title");
I have try with this code:
private static void getTitle(AcroFields form, PdfStamper
stamper, PdfReader reader)
{
...
PdfDictionary dictionary = reader.getCatalog();
System.out.println(dictionary.get(PdfName.TITLE));
...
}
The value is null.
Note that the Catalog is not the same as the Information Dictionary.
You will find a reference to the Info Dictionary in the trailer, not
in the Root Dictionary (= Catalog).
br,
Bruno
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions