ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
writer.setPageEvent(new PdfPageEventHelper() {
public void onParagraph(PdfWriter writer, Document document, float position) {
PdfContentByte cb = writer.getDirectContent();
PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
new PdfOutline(cb.getRootOutline(), destination, TITLE);