Created
June 14, 2020 20:17
-
-
Save JoeGlines/b86da514d36c2373308fd985b651af9d to your computer and use it in GitHub Desktop.
convert PDF to different formats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File_path:="C:\Users\Joe\DropBox\Progs\AutoHotkey_L\AHK Work\PDF\pdftotext\LUM00700060_06082018.pdf" | |
;~ File_path:="B:\Progs\AutoHotkey_L\AHK Work\PDF\example PDfs\Carrollton_4.pdf" | |
;~ File_path:="B:\Progs\AutoHotkey_L\AHK Work\PDF\example PDfs\coppell.pdf" | |
Type:="xml" ;"txt2" ; | |
;~ Type:="txt2" ; | |
run:="1" | |
Convert_PDF(File_Path,Type,Run=1) | |
return | |
Convert_PDF(File_Path,Type,Run){ | |
SplitPath, File_Path,,Dir,,Name_no_Ext | |
;***********make sure case is lower in "com.adobe.acrobat....******************* | |
; Accessible Text preserves comments, form fields, and minor formatting, such as line breaks. | |
O_Ext_format:={"rtf":"com.adobe.acrobat.rtf","txt":"com.adobe.acrobat.plain-text","txt2":"com.adobe.acrobat.accesstext","doc":"com.adobe.acrobat.doc","htm":"com.adobe.acrobat.html-4-01-css-1-00","xml":"com.adobe.acrobat.spreadsheet" | |
,"html":"com.adobe.acrobat.html-3-20","xml":"com.adobe.acrobat.xml-1-00","eps":"com.adobe.acrobat.eps","jpg":"com.adobe.acrobat.jpeg","png":"com.adobe.acrobat.png","tif":"com.adobe.acrobat.tiff"} | |
oPDDoc := ComObjCreate("AcroExch.PDDoc") | |
oPDDoc.Open(File_Path) | |
jsO := oPDDoc.GetJSObject ;Get Javascript object | |
try jsO.saveAs(Dir "\" Name_no_Ext "." substr(Type,1,3), O_Ext_format[Type]) ;first three so can have more than one text converter | |
Catch { | |
MsgBox this folder is protected, you need to save in a non-secure folder | |
return | |
} | |
;***********Open it with default program******************* | |
if (run=1) | |
if FileExist(Dir "\" Name_no_Ext "." substr(Type,1,3)) | |
run % Dir "\" Name_no_Ext "." substr(Type,1,3) | |
Else | |
MsgBox the file didn't get created | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment