code: def pdf_add(dest: str, source: str, pages: [str], output: str):
      
      if output is not None and os.path.isfile(output):
          if not overwrite_dlg(output):
              return
  
      writer = PdfFileWriter()
  
      # read pages from destination file
      destfile = open(dest, "rb")
      destreader = PdfFileReader(destfile)
      for page in destreader.pages:
          writer.addPage(page)
  
      # read pages from source file
      srcfile = open(source, "rb")
      srcreader = PdfFileReader(srcfile)
  
      # if no page numbers are given add all pages from source
      if pages is None:
          for i, page in enumerate(srcreader.pages):
              writer.addPage(page)
      else:
          pages = parse_rangearg(pages, len(srcreader.pages))
          for pagenr in pages:
              page = srcreader.getPage(pagenr)
              writer.addPage(page)
  
      if output is None:
          # Write into Temporary File first and then overwrite dest file
          if overwrite_dlg(dest):
              tempfile = NamedTemporaryFile(delete=False)
              writer.write(tempfile)
              tempfile.close()
              destfile.close()
              srcfile.close()
              os.remove(dest)
              move(tempfile.name, dest)
      else:
          with open(output, "wb") as outfile:
              writer.write(outfile)
              destfile.close()
              srcfile.close()
docs: Add pages from a source pdf file to an output file. If the output
      file does not exist a new file will be created.
      :param source: source pdf file
      :param dest: destination pdf file
      :param pages: list of page numbers or range expressions
      :param output: output pdf file