PdfContentByte is strictly for things that appear in pages.  A bookmark's appearance is just a string... you can't even control the font or point size.
 
You can set the color, and have flags to control 'italic' and 'bold', but that's it.  I'm not sure that iText exposes this ability, let me check...  Yes, iText has a PdfOutline object that allows you to set its color (with a java.awt.Color) and style.
 
And there's an example of how to use it:
http://itextdocs.lowagie.com/examples/com/lowagie/examples/directcontent/pageevents/Bookmarks.java
 
It actually uses a PdfContentByte, but only as a way to access the root outline.  I suspect that PdfWriter.getRootOutline() was added after this example was written... it would be less confusing to write Bookmarks.OnParagraph() like this:
 
public void onParagraph(PdfWriter writer, Document document, float position)
{
 n++;
  PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
  PdfOutline root = writer.getRootOutline();
  PdfOutline outline = new PdfOutline(root, destination, "paragraph " + n);
}
 
I believe you can safely ignore the "new PdfOutline" return value. Outlines are in a doubly linked parent-child tree, so there's no danger of it being garbage collected... javac might complain however, though you'll still get a 'variable assigned but never used' warning.

--Mark Storer
  Senior Software Engineer
  Cardiff Software

#include <disclaimer>
typedef std::Disclaimer<Cardiff> DisCard;

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Miguel Tablado
Sent: Thursday, July 06, 2006 9:04 AM
To: [email protected]
Subject: [iText-questions] Paragraph and PdfContentByte

Hello.

I have a problem writing into an existing pdf file. I want to write a Paragraph into a pdf bookmark, but I don't find what is the PdfContentByte's method to do add a Paragraph nor the funcionality to add a Paragraph at a specific position.

If it is not posible, It will be enough if I could justify a text of a bookmark.

Could you help me?

Thanks in advance!

Miguel Tablado.
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to