Using Apple Quick Look tool in application
Posted: Thu Nov 20, 2014 5:30 pm
Hi,
I wish to create a tool that will help me review, rename and file large numbers of pdf files generated by a document scanner. I have a working project that displays a preview of the pdf using a revbrowser control. It works but the browser has caused some issues and is not capable of previewing other file types. So I wondered if it would be possible to use the Quick Look tool that is provided as part of Mac OSX.
Before I proceed I should state that my knowledge of shell, terminal and the inner workings of my mac is quite limited.
Web research reveals that the Quick Look tool may be called using a shell script qlmanage -p filepath . I have been experimenting and have had limited success. The first problem is that the shell does not like spaces and probably other characters in the filepath. My work around is to replace spaces with back slash and space. However I am sure I should be checking for other characters. The web describes the conversion of dirty text to shell acceptable text as putting the text into the quoted form. Does anyone have a description of what characters this applies to?
My app places a list of pdf file names into a field. The user selects a file name and a preview should be displayed. My prototype preview text routine is here:
The problem is that while the shell call does display a preview of the selected file it then blocks the rest of my scripts. Also, closing the preview using its close button often causes it to close only to reopen. Ideally I would like to open a single instance of QuickLook and update its file source when the user moves to a new file, much as it works in the Finder. Obviously it must be able to operate without blocking my other code.
Have any of you experience and advice of using Apple Quick Look in this way?
best wishes
Simon
I wish to create a tool that will help me review, rename and file large numbers of pdf files generated by a document scanner. I have a working project that displays a preview of the pdf using a revbrowser control. It works but the browser has caused some issues and is not capable of previewing other file types. So I wondered if it would be possible to use the Quick Look tool that is provided as part of Mac OSX.
Before I proceed I should state that my knowledge of shell, terminal and the inner workings of my mac is quite limited.
Web research reveals that the Quick Look tool may be called using a shell script qlmanage -p filepath . I have been experimenting and have had limited success. The first problem is that the shell does not like spaces and probably other characters in the filepath. My work around is to replace spaces with back slash and space. However I am sure I should be checking for other characters. The web describes the conversion of dirty text to shell acceptable text as putting the text into the quoted form. Does anyone have a description of what characters this applies to?
My app places a list of pdf file names into a field. The user selects a file name and a preview should be displayed. My prototype preview text routine is here:
Code: Select all
On UserSelectsFile
--user has clicked in the list
put the selectedtext of fld "FileList" into tFilename
put field "folder" & "/" & tFilename into tMyFilePath
replace " " with "\ " in tMyFilePath
put "qlmanage -p " & tMyFilePath into tscript
put shell (tscript) into tResult
end UserSelectsFile
Have any of you experience and advice of using Apple Quick Look in this way?
best wishes
Simon