You have the writer but you don't have a document.open(). Paulo
----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Post all your questions about iText here" <itext-questions@lists.sourceforge.net> Sent: Friday, April 06, 2007 5:51 PM Subject: Re: [iText-questions] opening url in new window Paulo, I do have a PdfWriter as one of the arguments. Tom > One of the arguments of PdfAction.javaScript() is a PdfWriter. > > Paulo > > ________________________________ > > De: [EMAIL PROTECTED] em nome de > [EMAIL PROTECTED] > Enviada: sex 06-Abr-07 16:34 > Para: Post all your questions about iText here > Assunto: Re: [iText-questions] opening url in new window > > > > Paulo, > > Here is a code sample > > Document document = new Document(); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > PdfWriter writer = PdfWriter.getInstance(document, baos); > Chunk link = new Chunk("<-- view page-->"); > > link.setAction(PdfAction.javaScript("if(app.viewerVersion<7) > {this.openURL(\"www.yahoo.com\",true);} > > else{app.launchURL(\"www.ebay.com\",true);};",writer)); > PdfPCell cell = new PdfPCell(new Paragraph(link)); > > and the Stack trace. > > [4/6/07 10:26:59:531 EDT] 00000025 SystemErr R > java.lang.NullPointerException > [4/6/07 10:26:59:562 EDT] 00000025 SystemErr R at > com.lowagie.text.pdf.PdfWriter.addToBody(Unknown Source) > [4/6/07 10:26:59:562 EDT] 00000025 SystemErr R at > com.lowagie.text.pdf.PdfAction.javaScript(Unknown Source) > [4/6/07 10:26:59:562 EDT] 00000025 SystemErr R at > com.lowagie.text.pdf.PdfAction.javaScript(Unknown Source) > > Regards, > > Tom > >> >> >> ________________________________ >> >> De: [EMAIL PROTECTED] em nome de >> [EMAIL PROTECTED] >> Enviada: sex 06-Abr-07 15:13 >> Para: iText-questions@lists.sourceforge.net >> Assunto: [iText-questions] opening url in new window >> >> >> >> Thank you for your help. >> >> I am attempting to add a link within the PDF to open a page on the same >> domain in a new window. The following opens the link but in the same >> browser window. >> >> Chunk link = new Chunk("<-- view page -->"); >> link.setAction(PdfAction.gotoRemotePage("http://mydomain/mypage","page1",false,true)); >> >> >> It's up to the viewer to respect the new window flag. >> >> >> I have also been trying to do this with a PdfAction.javascript and >> app.launchURL but am getting a NullPointerException whenever my script >> reaches 100 characters. >> >> >> Please post a small code example so that the problem can be reproduced. >> >> >> >> Paulo >> >> >> >> >> Is it possible to open a link in a new window and if so, what way >> should >> I >> be going about it as I am obliviously doing something wrong. >> >> Regards. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/