Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 10th, 2012  |  syntax: Ruby  |  size: 0.62 KB  |  views: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def self.process(working_path, pdf_name)
  2.         pdf_path = "#{working_path}\/#{pdf_name}"
  3.         pdf_text = PdfUtils.pdf_text(pdf_path)
  4.  
  5.         # split off PDF for people one by one until we have no pages left
  6.         page_num   = 1
  7.         person_num = 1
  8.         while PdfUtils.pdf_page_count(pdf_path)>0
  9.                 # are we at the end of the person's PDF?
  10.                 if PageNumMatcher.matches_page_n_of_n?(pdf_text, page_num)
  11.                         puts "Splitting off PDF #{person_num}"
  12.                         # pull off the person's PDF into a new one, with sequential numbering
  13.                         PdfUtils.split_pdfs(pdf_path, 1, page_num+1, "#{working_path}\/{person_num}.pdf")
  14.                         person_num += 1
  15.                 end
  16.                 page_num += 1
  17.         end
  18. end
clone this paste RAW Paste Data