Bookmark

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bookmark

Khatri Anand
Hello sir,

 I want to add Bookmark into PDF. I got the Instance of a writer by PdfStamper class instead of PdfWriter class.
 I use following line of code...

              PdfReader readCombine=new PdfReader("C:\\CombinePDF.pdf");
             PdfStamper stamp=new PdfStamper(readCombine, new FileOutputStream("C:\\CombinePDFStamp.pdf"));
             PdfWriter writer=stamp.getWriter();
             writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
               
             
             PdfOutline root = writer.getRootOutline();
             PdfOutline movieBookmark;
             PdfOutline link;
            
             movieBookmark = new PdfOutline(root,new PdfDestination(PdfDestination.FITH,806),"Purchase Dep.",true);
             movieBookmark.setStyle(Font.BOLD);
             link = new PdfOutline(movieBookmark,new PdfAction("http://www.google.com"),"link to Google");
             link.setColor(BaseColor.BLUE);
            
             movieBookmark = new PdfOutline(root,new PdfDestination(PdfDestination.FITH, 806),"Admin Dep.", true);
             movieBookmark.setStyle(Font.BOLD);
             link = new PdfOutline(movieBookmark,new PdfAction("http://www.google.com"),"link to Google");
             link.setColor(BaseColor.BLUE);
            
             List<HashMap<String, Object>> list = SimpleBookmark.getBookmark(readCombine);
             SimpleBookmark.exportToXML(list,new FileOutputStream("C:\\CombinePDF.xml"), "ISO8859-1", true);
             stamp.close();


and i got java.lang.NullPointerException error... how can I resolve this issue??



Thanks & Regards,
--
Anand Khatri
Software Developer

ZEITECH Solutions,
Ahmedabad.
Ph  : +91 8000008071





------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|

Re: Bookmark

iText mailing list
On 30/09/2011 13:06, Khatri Anand wrote:
>  I want to add Bookmark into PDF.

I honestly doubt that you've got a copy of the book.
If you do, I honestly doubt that you've read it.
If you did, you should look for the setOutlines() method in PdfStamper.
Throw away your code, start anew.

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php