parameters: ()
docstring: creates one pdf file from several others, following order from the cover
docstring_summary: creates one pdf file from several others, following order from the cover
docstring_tokens: creates one pdf file from several others following order from the cover
function: def joinpdf():
      "creates one pdf file from several others, following order from the cover"
      from PyPDF2 import PdfFileReader,PdfFileWriter
      if VERBOSE: print("Building table of contents...")
      
      result = PdfFileWriter()
      createCover()
      inputfile = PdfFileReader(open(FOLDER+os.sep+'Cover.pdf','rb'))
      result.addPage(inputfile.getPage(0))
      count = 1
  
      tocfile = createTOC()
      parent = False
      for page in tocfile:
          page = page.strip()
          if page:
              if page[0] == "#":
                  continue
              if page == "begin":
                  parent = True
                  continue
              if page == "end":
                  parent = False
                  continue
              if VERBOSE: print('Appending ',page, " at position ",count)
              title = page.replace("_"," ")
              pdffile = page + ".pdf"
              if exists(pdffile,True):
                  inputfile = PdfFileReader(open(FOLDER + os.sep + pdffile,'rb'))
                  numpages = inputfile.getNumPages()
                  for i in range(numpages):
                      result.addPage(inputfile.getPage(i))
                  if parent == True:
                      parent = result.addBookmark(title,count)
                  elif parent == False:
                      result.addBookmark(title,count)
                  else:
                      result.addBookmark(title,count,parent)
                  count += numpages
              else:
                  print("page ",pdffile," not found, aborting.")
                  sys.exit()
  
      if VERBOSE: print("Writing...")
      outputfile = open(FOLDER+os.sep+"freecad.pdf",'wb')
      result.write(outputfile)
      outputfile.close()
      if VERBOSE: 
          print(' ')
          print('Successfully created '+FOLDER+os.sep+'freecad.pdf')
function_tokens: def joinpdf ( ) : from PyPDF2 import PdfFileReader , PdfFileWriter if VERBOSE : print ( "Building table of contents..." ) result = PdfFileWriter ( ) createCover ( ) inputfile = PdfFileReader ( open ( FOLDER + os . sep + 'Cover.pdf' , 'rb' ) ) result . addPage ( inputfile . getPage ( 0 ) ) count = 1 tocfile = createTOC ( ) parent = False for page in tocfile : page = page . strip ( ) if page : if page [ 0 ] == "#" : continue if page == "begin" : parent = True continue if page == "end" : parent = False continue if VERBOSE : print ( 'Appending ' , page , " at position " , count ) title = page . replace ( "_" , " " ) pdffile = page + ".pdf" if exists ( pdffile , True ) : inputfile = PdfFileReader ( open ( FOLDER + os . sep + pdffile , 'rb' ) ) numpages = inputfile . getNumPages ( ) for i in range ( numpages ) : result . addPage ( inputfile . getPage ( i ) ) if parent == True : parent = result . addBookmark ( title , count ) elif parent == False : result . addBookmark ( title , count ) else : result . addBookmark ( title , count , parent ) count += numpages else : print ( "page " , pdffile , " not found, aborting." ) sys . exit ( ) if VERBOSE : print ( "Writing..." ) outputfile = open ( FOLDER + os . sep + "freecad.pdf" , 'wb' ) result . write ( outputfile ) outputfile . close ( ) if VERBOSE : print ( ' ' ) print ( 'Successfully created ' + FOLDER + os . sep + 'freecad.pdf' )