title: Split PDF #python function is only exporting the first page ONLY
body: <p>After exporting a PDF file from an xslx file. The split function only works for the first page only.</p>
  <p>In a matter of fact, I export 2 PDF files from 2 xslx files. The first one is working just fine but the other one gets exported into a PDF file and split into the needed file but it only executes the first page only then the process gets terminated.</p>
  <p>Here is the function:</p>
  <pre class="lang-py prettyprint-override"><code>def split_pdf(file_name, info_json, save_file_name = None, folder_name = &quot;Reports&quot;):
  
      if save_file_name == None:
  
          save_file_name = file_name
  
      output_folder_path = '{}/'.format(folder_name)
  
      Path(output_folder_path).mkdir(parents=True, exist_ok=True)
  
      print(&quot;The '{}/' folder has been created&quot;.format(folder_name))
  
      pdf = PdfFileReader(os.path.join(os.getcwd(), file_name + &quot;.pdf&quot;))
  
      location = None
      for page_num in range(pdf.numPages):
          pdfWriter = PdfFileWriter()
          pdfWriter.addPage(pdf.getPage(page_num))
          page_content = pdf.getPage(page_num).extractText()
          list_of_names = page_content.encode('utf-8').decode('utf-8').split(&quot;\n&quot;)
          if location == None:
              for index, name in enumerate(list_of_names):
                  if 'name' in name.lower():
                      location = index + 1
                      break
          try:
              Name = list_of_names[location].strip()
          except:
              continue
              
          if 'name' not in list_of_names[location - 1].lower().strip():
              continue
              
          if Name == '#N/A':
              continue
  
          try:
              file_location = &quot;{}{}/{}/{}/&quot;.format(output_folder_path, info_js[Name]['Campus'], info_js[Name]['School'], Name)
          except:
              print(&quot;\t\tCouldn't find {}&quot;.format(Name))
              continue
          print(&quot;\t&quot; + file_location + '{}.pdf'.format(save_file_name))
          Path(file_location).mkdir(parents=True, exist_ok=True)
          with open(file_location + '{}.pdf'.format(save_file_name), 'wb') as f:
              pdfWriter.write(f)
  </code></pre>