Skip to main content
SychevKA
Inspiring
March 3, 2021
Question

Batch jpg to pdf to ms word

  • March 3, 2021
  • 2 replies
  • 945 views

Hello forum!
I need help (sorry for my English)
I need a script that makes several moves:
1. user chooses a folder
2. create PDF from JPG ( from full path )
3. save as MS Word ( with options: OCR false, Comments false )
4. close PDF without saving

I'm not a newbie but i never developed for Acrobat.
Please help me with my simple task.
Thanks!

function get_files(path){
	var folder = Folder(path).getFiles()
	for(var i = 0; i < folder.length; i++){
		if(File(folder[i]).constructor.name == 'Folder'){get_files(folder[i])}
		else{
			var f = File(folder[i]).fsName
			if(f.split('.').slice(-1)[0].toLowerCase() == 'jpg'){
				files[f.split('\\').slice(-1)[0].split('.').slice(0,-1).join('.')] = f
			}
		}
	}
}
var path = Folder.selectDialog('')
if(path != null){
	var files = {}
	get_files(path)
	for(k in files){
		
		// here k is filename without extension
		// files[k] is fullpath
		
		createPDF()
		saveasMSWord()
		closePDF()

	}
}

 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
March 3, 2021

I think you should be able to do it with an Action in Acrobat Pro. You don't need any scripts, though.

Just create a new Action and add to it a command to run Text Recognition and then a Save As and change the export type to Word. Run it on your files and it will convert all non-PDFs files to PDF first, and then perform the other commands on them.

SychevKA
SychevKAAuthor
Inspiring
March 3, 2021

Yes it worked, but I have subfolders...

 

try67
Community Expert
Community Expert
March 3, 2021

If you select the parent folder as the starting point of the Action it will process all sub-folders, too.

Bernd Alheit
Community Expert
Community Expert
March 3, 2021

Why want you use the detour over PDF?

try67
Community Expert
Community Expert
March 3, 2021

To perform OCR, most likely...

try67
Community Expert
Community Expert
March 3, 2021

Although I'm seeing now they want to specify OCR as false, so yeah, it is a bit strange...