Add Bookmarks to PDF using iTextSharp -


i have big pdf file , want copy pages new pdf file using itextsharp. works fine following code.

dim sourcefullfilepathandname string = "src.pdf" dim outputfullfilepathandname string = "cpy.pdf" dim pagefirst integer = 5 dim pagelast integer = 10  using rdr itextsharp.text.pdf.pdfreader = new itextsharp.text.pdf.pdfreader(sourcefullfilepathandname)     dim docsrc new itextsharp.text.document(rdr.getpagesizewithrotation(1))     using fs = new system.io.filestream(outputfullfilepathandname, system.io.filemode.create)         dim copy new itextsharp.text.pdf.pdfcopy(docsrc, fs)         docsrc.open()         dim bookmarks = new list(of dictionary(of string, object))() 'new arraylist() '// changed         pagenumber integer = pagefirst pagelast             dim ip = copy.getimportedpage(rdr, pagenumber)              if pagenumber = pagefirst '// changed                 dim h = ip.height '// changed                 dim test = new dictionary(of string, object) 'new hashtable() '// changed                 test.add("action", "goto") '// changed                 test.add("title", "page1 0 h 0") '// changed                 test.add("page", "1 xyz 0 " & h.tostring & " 0") '// changed                 bookmarks.add(test) '// changed             end if '// changed              copy.addpage(ip)         next         copy.outlines = bookmarks '// changed - got exception here!         docsrc.close()     end using     rdr.close() end using 

but can not find out how add bookmark each new page. have found samples bookmark specific page using itextsharp 4.1.6 not solve problem.

update: added code of how tried create bookmarks marked '// changed btw. using itextsharp v5.4.4. getting following exception: unable cast object of type 'system.collections.arraylist' type 'system.collections.generic.ilist1[system.collections.generic.dictionary2[system.string,system.object]]'. changed again using list of dictionary instead of hashtable. not getting error getting no bookmarks.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -