Are you trying to run that Javascript in Reader?  Reader doesn't support 
creating stuff on the fly...

Leonard

From: lester fajardo [mailto:lefaja...@gmail.com]
Sent: Wednesday, November 11, 2009 11:20 AM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] add bookmark at runtime

hello i am trying to add a bookmark using javascript but seems to not be 
working, i create a bookmark using standar itext procedure and 2 using js at 
document load, but only the itext-created bookmark is shown.

thx in advance for any help

this is my code.

string jsCode = "";

Document document = new Document(PageSize.LETTER, 72, 72, 60, 50);

PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("test.pdf", 
FileMode.Create));

document.Open();

// add a test chapter
Chapter chapter1 = new Chapter(new Paragraph("bookmark 1"), 1);
chapter1.BookmarkOpen = true;
doc.Add(chapter1);

// sample code taken from the 
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJS.pdf
 file


// add more bookmarks using javascript
jsCode += " this.bookmarkRoot.createChild( 'bookmark 2',''); \r ";

// add a child to the first book mark created "bookmark 1"
// pointer to the bookmark
jsCode += " var bm = bookmarkRoot.children[0];\r ";

jsCode += " bm.createChild( 'bookmark3',''); ";

PdfAction jsAction = PdfAction.JavaScript(jsCode, writer);

writer.AddJavaScript(jsAction);


document.Close();
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to