Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

josecarioca

macrumors newbie
Original poster
Dec 21, 2013
5
0
Sardinia - Italy
I'm a debutant to this forum. I am not able to complete this script to automate conversion of few image files (jpg) to PDF, with PDFpen application. First it should be run for a single file, afterwards I will adapt it to most files.
Could anyone suggest me the missing instructions for?
Thanks
Mario

Code:
on run
	set MioOcr to "PDFpen"
	set cartella to ("HDmio:JPGsPROVE:")
	set filmio to (cartella & "immagine-1.jpg")
	tell application MioOcr
		open filmio --     OK : it opens image with PDFpen
		
		--            Here statments to continue      
		--   key  : Document OCR (to execute conversion)
		--   key  : save as :   ....    (filename, folder, format)
		--   key  : close file
	end tell
end run
 
Last edited by a moderator:
Why not save yourself the trouble and do this in Automator with the New PDF From Images action.
 

Attachments

  • Screen Shot 2013-12-23 at 01.52.20.png
    Screen Shot 2013-12-23 at 01.52.20.png
    60.7 KB · Views: 197
Why not save yourself the trouble and do this in Automator with the New PDF From Images action.

Thanks Kryten2,
but suggested solution with Automator gives me a Pdf file not sercheable (type image only), contrariwise I need a PDF where I can make reserches on words. And PDFpen satisfies theese my needs.
 
Thanks Kryten2,
but suggested solution with Automator gives me a Pdf file not sercheable (type image only), contrariwise I need a PDF where I can make reserches on words. And PDFpen satisfies theese my needs.

Ok, now I see why you used PDFpen. Here's an example for one file.


Code:
set theFile to choose file default location path to documents folder
set theFileName to do shell script "sed -E 's|:$||;s|.*:||;s|\\.[^.]*$||' <<< " & quoted form of (theFile as text)

tell application "PDFpenPro"
	-- insert actions here
	activate
	open theFile
	tell document 1
		ocr
		repeat while performing ocr
			delay 1
		end repeat
		delay 1
		save in file ("MavericksDP:Users:kryten:" & theFileName)
		close
	end tell
end tell

Info and example scripts : here and pdfpen-ocr-applescript-to-automatically-make-pdfs-searchable/ and pdfpen-ocr-folder-action-script.html
 
:) I thank you infinitely for your kindness. It seems to work fine, except for some error probably due to my mistakes in data entry.
Now I have to minutely examine script you sent me. For now, thank you so much and be pleased with best wishes for Christmas and happy New Year!
Mario
 
hi Kryten2,
could you explain me the meaning of the following command included into script you sent me ?

set theFileName to do shell script "sed -E 's|:$||;s|.*:||;s|\\.[^.]*$||' <<< " & quoted form of (theFile as text)

Thanks in advance
 
hi Kryten2,
could you explain me the meaning of the following command included into script you sent me ?

set theFileName to do shell script "sed -E 's|:$||;s|.*:||;s|\\.[^.]*$||' <<< " & quoted form of (theFile as text)

Thanks in advance

It should return the filename without the extension you get from the first line in the script e.g. set theFile to choose file ... So for example if your file is named Holiday.jpg then the value of theFileName variable would be "Holiday". It was merely given as an example. Feel free to name your file(s) however you like.
 
It should return the filename without the extension you get from the first line in the script e.g. set theFile to choose file ... So for example if your file is named Holiday.jpg then the value of theFileName variable would be "Holiday". It was merely given as an example. Feel free to name your file(s) however you like.

Thank you so much again.
I understood what the string you sent me makes, but I wanted to understand how script string get the result. Particularly, I realized that '-E' indicates 'editing' and 's' means 'substitute'. But not the part of the string where are the characters '|' (I think those are delimiters. I read delimiters should only be 3 and so I get confused).
Also I can not understand the last part of the command 'sed' (ie '<<< ") and the final part of the string (ie' & quoted form of (the file as text)).
I know I'm asking too much, so if I'm boring, you can easily not answer: thank you anyway.
By the way do you understand Italian language ? It would be easier for me to explain..
Mario
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.