ch['page_range'] = (tA[i][1],tA[i+1][1]-1) else: ch['page_range'] = (tA[i][1],tA[i][1]) j = i+1 while j < lt and tA[j][2] > tA[i][2]: j+=1 ch['children'] = convertTocAtoB(tA[i+1:],j-i-1) i = j; tB.append(ch) return tB def printToc(toc,lvl=0): for el in toc: print "-" * (lvl+1), print "%3d-%-3d" % (el['page_range'][0],el['page_range'][1]), print el['title'] if len(el['children']) != 0: printToc(el['children'],lvl+1) converted_toc = convertTocAtoB(toc,len(toc)) if args.gui: from toc_gui_gtk import toc_gui toc_gui(converted_toc) elif args.pdfmark: from springerdl.pdfmark import tocToPdfmark, labelsToPdfmark print tocToPdfmark(toc) print labelsToPdfmark(getPagelabelsFromPdf(pdf)) else: print toc print converted_toc printToc(converted_toc)
ch['page_range'] = (tA[i][1],tA[i+1][1]-1) else: ch['page_range'] = (tA[i][1],tA[i][1]) j = i+1 while j < lt and tA[j][2] > tA[i][2]: j+=1 ch['children'] = convertTocAtoB(tA[i+1:],j-i-1) i = j; tB.append(ch) return tB def printToc(toc,lvl=0): for el in toc: print "-" * (lvl+1), print "%3d-%-3d" % (el['page_range'][0],el['page_range'][1]), print el['title'] if len(el['children']) != 0: printToc(el['children'],lvl+1) converted_toc = convertTocAtoB(toc,len(toc)) if args.gui: from toc_gui_gtk import toc_gui toc_gui(converted_toc) elif args.pdfmark: from springerdl.pdfmark import tocToPdfmark, labelsToPdfmark print tocToPdfmark(toc) print labelsToPdfmark(pdf.getPagelabels()) else: print toc print converted_toc printToc(converted_toc)