itextsharp set bookmarks to fit page -


i'm starting out itextsharp , i've managed answer questions one: how bookmarks set open fitpage zoom/view?

i apologize if has been answered elsewhere. here's code if helps.

//edit: below working code. has been modified using bruno's example.

 public sub mergepdffiles(filelist system.collections.generic.list(of modifieditemforlist), pdfname string, pagecount integer)      dim reader pdfreader     dim mergedpdf byte() = nothing     dim n integer     dim page integer     dim par paragraph     dim pagemode integer     dim pagelayout integer     dim pagezoom pdfdestination     dim outlinezoom pdfdestination     dim pdfaction pdfaction     dim root pdfoutline     dim pdfoutline pdfoutline      using ms new memorystream()          using document new document()              using copy new pdfcopy(document, ms)                 'dim copy new pdfcopy(document, ms)                 document.open()                 root = copy.rootoutline                 pagemode = copy.pagemodeuseoutlines                 pagelayout = copy.pagelayoutsinglepage                 pagezoom = new pdfdestination(pdfdestination.fit)                 copy.viewerpreferences = pagemode                 pdfaction = pdfaction.gotolocalpage(1, pagezoom, copy)                 copy.setopenaction(pdfaction)                  ' each filepath keyvaluepair(of string, string) in filelist  ' .count - 1                 integer = 0 pagecount - 1                     ' filepath keyvaluepair(of string, string)                     if file.exists(filelist.item(i).value)                         reader = new pdfreader(filelist.item(i).value)                         ' loop on pages in document                         n = reader.numberofpages                         page = 0                         par = new paragraph(filelist.item(i).key)                         debug.print("filelist.item(i).key = " & filelist.item(i).key)                         outlinezoom = new pdfdestination(pdfdestination.fit)                         pdfoutline = new pdfoutline(root, outlinezoom, par)                          while page < n                             copy.addpage(copy.getimportedpage(reader, system.threading.interlocked.increment(page)))                         end while                      end if                  next              end using          end using          mergedpdf = ms.toarray()      end using      file.writeallbytes(pdfname, mergedpdf)  end sub 

your input appreciated, corbin de bruin

if want custom bookmarks, please don't use chapter , section, use pdfoutline instead. (of course) documented in chapter 7 of book. if need c# port of examples, take @ code examples chapter 7, createoutlinetree.cs, instead of using pdfdestination.fith (for fit horizontally) , y position, create destination pdfdestination.fit (and no parameter):

new pdfoutline(root, new pdfdestination(pdfdestination.fit), title, true); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -