Adding to my previous email this is the basic structure *PDF -> MainBookMark -> subBookMark1 -> pages( 1- 10 etc..)*
On Fri, Jul 14, 2017 at 2:33 PM, Mustafa Farooqui <[email protected] > wrote: > Below is my code and pdf structure which am working on. I am stuck at a > point where i am trying to get the pages which are under the "subBookMark1". > These pages are basically forms which are more than one pages. I am not > sure how to iterate over these pages under subBookMark1. Like page 1, page2 > , page 3 etc. Hope this information helps you to understand my issue? > > > Below is my PDF structure > > *MainBookMarkName > |_subBookMark1 (1-10 pages) > -page1 > -page2 > -page3 > -page4 > - . > - . > -page10 > |_**subBookMark2** (1-5 pages)* > * -page1 > -page2 > -page3 > -page4 > -page5 > |_**subBookMark3 ** (1-8 pages)* > * -page1 > -page2 > -page3 > - . > - . > -page8 > |_**subBookMark4* > * > |_ > |_ > |_**subBookMark5* > > My Code > > public static PDPage printBookmark(PDDocument document, PDOutlineNode > node, String indentation) > throws IOException { > PDOutlineItem mainBookMark= node.getFirstChild(); > PDOutlineItem subBookMark1= mainBookMark.getFirstChild(); > > while (subBookMark1!= null) { > System.out.println(subBookMark1.getTitle()); > > if (subBookMark1.getDestination() instanceof PDPageDestination) { > > if (subBookMark1.getTitle().equals("subBookMark1 Title")) { > > > PDPageDestination pd = (PDPageDestination) subBookMark1.getDestination(); > > System.out.println("Destination page: " + (pd.retrievePageNumber() + 1)); > > return pd.getPage(); > > } > } > printBookmark(document, subBookMark1, indentation + " "); > subBookMark1= subBookMark1.getNextSibling(); > } > return null; > > } > > > > On Fri, Jul 14, 2017 at 11:10 AM, Gilad Denneboom < > [email protected]> wrote: > >> What exactly is the issue? Do you know how to access the Outline root? Do >> you know how to proceed from there to the children/siblings (this will >> require a recursive function, unless you know there is only a fixed amount >> of levels in the bookmark hierarchy)? Do you know how to access the >> action(s) associated with each bookmark? >> It would be helpful if you could let us know to which point you've >> arrived, >> and where you got stuck... >> >> On Fri, Jul 14, 2017 at 4:55 PM, Mustafa Farooqui < >> [email protected] >> > wrote: >> >> > Hi, >> > >> > I am trying to access the pages which are under the sub bookmark . >> > Below is the structure of the pdf file and under it there sub >> > bookmarks. These sub bookmarks have multiple pages which are basically >> > forms extended to more than one page. I am able to get to those sub >> > bookmark. However, cannot iterate over those pages or get any specific >> > page i need to edit or resize? >> > >> > Can anyone please suggest or help? I can share the code but cannot >> > share the confidential pdf which I am working on. I tried finding the >> > sample document online but couldn't find any. My question is similar >> > to the below link which i found on stackover flow. >> > >> > https://stackoverflow.com/questions/45002625/how-to- >> > load-the-pages-which-are-under-the-sub-bookmark-using-pdf-box >> > >> > >> > Below is the structure of my PDF document >> > >> > MainBookMarkName|_firstBookMark (1-10 pages) >> > -page1 >> > -page2 >> > -page3 >> > -page4 >> > - . >> > - . >> > -page10|_secondBookMark (1-5 pages) >> > -page1 >> > -page2 >> > -page3 >> > -page4 >> > -page5|_thirdBookMark (1-8 pages) >> > -page1 >> > -page2 >> > -page3 >> > - . >> > - . >> > -page8|_FourthBookMark|_|_|_lastBookMark >> > >> > >> > Thanks >> > >> > Mustafa >> > >> > >

