Wednesday, July 27, 2011

Split PDF into single page

** This process requires you to have acrobat pro
** The acrobat reader does not compatible with it


** Create an object to hold the Acrobat
Pd = CreateObject('acroexch.pddoc')
Pn = CreateObject('acroexch.pddoc')Pd.open('input.pdf')


** Get the actual page count from pdf
PC = pd.getnumpages


** First page is 0, so the last page is the PC - 1
For cp = 0 to PC - 1


  ** Create a new and empty PDF file
  Pn.create


  ** Insert a page from the original file
  Pn.insertpages(-1, pd, cp, 1, .f.)


  ** Save the new pdf with page number
  Pn.save(1, 'output_' + padl(cp + 1, 3, '0'))


  ** Close the new pdf file
  Pn.close


Next


** Close and release all PDF process
Pd.Close
Release pd
Release Pn
Close all

No comments:

Post a Comment