1 Reply Latest reply on Jan 9, 2010 3:30 AM by Muppet Mark-QAl63s

    How to Export PDF to Text File?


      Hi pals,


      Am doing Applescript to convert PDF to Text. Is there any possibilities to do in Applescript or Javascript (by calling Javascript syntax using doScript in applescript). I need either .txt file or .doc file.Thanks in advance.




        • 1. Re: How to Export PDF to Text File?
          Muppet Mark-QAl63s Level 4

          Use save document command with using conversion… Here is an example for plain text.


          property Default_Location : (path to desktop as Unicode text) as alias


          set Input_Folder to choose folder default location Default_Location with prompt "Select a folder of PDFs" without invisibles


          tell application "Finder"

          set File_List to (files of Input_Folder whose name extension is "pdf")

          repeat with This_File in File_List

          set The_File to This_File as alias

          tell application "Adobe Acrobat 7.0 Professional"


          open The_File

          set Doc_Name to name of document 1

          set Base_Name to my getBaseName(Doc_Name)

          set New_File_Path to (Default_Location as string) & Base_Name & ".txt"

          save front document to file New_File_Path using conversion "com.adobe.acrobat.plain-text"

          close front document

          end tell

          end repeat

          end tell


          on getBaseName(fName)

          set baseName to fName

          repeat with idx from 1 to (length of fName)

          if (item idx of fName = ".") then

          set baseName to (items 1 thru (idx - 1) of fName) as string

          exit repeat

          end if

          end repeat

          return baseName

          end getBaseName


          Other text conversions are "com.adobe.acrobat.rtf" & "com.adobe.acrobat.accesstext"