Exportation in pdf with an applescript
Hi,
I would like to create a bash script with an enclosed applescript. I need that because I have a NAS and I want to share pdf versions with people. I edit every days dozens of .oo3 so It would be more convenient to be able to include that process within my rsync script. I've try to do that but I don't know how to solve the issues : [CODE] set myDoc to "/Users/Pamphile/Desktop/notes.oo3" set pdfSavePath to "/Users/Pamphile/Desktop/" tell application "OmniOutliner Professional" activate open myDoc end tell tell application "System Events" tell process "OmniOutliner pro" -- Press command+p to open our print dialog keystroke "p" using command down -- Let's make sure our print dialog is up repeat until exists window "Print" end repeat -- Click the PDF menu button click menu button "PDF" of window "Print" -- Make sure the menu is up repeat until exists menu item "Save as PDF…" of menu 1 of menu button "PDF" of window "Print" end repeat -- Select the "Save as PDF" menu item click menu item "Save as PDF…" of menu 1 of menu button "PDF" of window "Print" -- Make sure the save dialog is visible repeat until exists window "Save" end repeat -- Press command+shift+g to show the "Go" drop down sheet keystroke "g" using {command down, shift down} -- Set our location field to our pdfSavePath set value of text field 1 of sheet of window "Save" to pdfSavePath -- Now click the Go button click button "Go" of sheet of window "Save" -- Now that we are in our desired folder, set the file name and save set value of text field 1 of window "Save" to "Notes.pdf" click button "Save" of window "Save" end tell end tell [/CODE] Thanks for your help !!!! |
Can you describe the issues you're running into? It'll be easier to try and help if we know what the problems are. :-)
|
Hi, thanks for this fast answer !
When I launch the script I have : exists window "Print" of process "OmniOutliner pro" --> false And the same problem with the other command about the control of the buttons |
It might prove simpler to export to RTF and then convert the RTF to PDF.
An illustrative snippet: [CODE]property pstrConvert : "/System/Library/Printers/Libraries/convert -f " property pstrDesktop : POSIX path of (path to desktop) property pstrTempFile : pstrDesktop & "tmp.rtf" tell application "OmniOutliner Professional" -- EXPORT TO RTF set oDoc to front document export oDoc as "OORTFPboardType" to pstrTempFile -- CONVERT RTF TO PDF do shell script pstrConvert & quoted form of pstrTempFile & ¬ " -o " & quoted form of (pstrDesktop & name of oDoc & ".pdf") -- DELETE TMP RTF FILE do shell script "rm " & pstrTempFile end tell [/CODE] [COLOR="White"]--[/COLOR] |
But beware of a reasonably thermonuclear bug in the OmniOutliner export function.
If you give its output argument the path of a folder rather than a file, it will happily obliterate the folder and all of the data in it ... My fault, but I managed to lose my Desktop this way this morning :-) |
thanks for that it works quit good ! and if I want to change the paths (I have a folder with subfolders and lots of .oo3 within) ? because I don't really understand the code (I repeat I'm new with apple scripting). For instance I'll move .oo3 to the desktop and after converted I'll move the .pdf to the nas. Furthermore I don't want to have a lot of .pdf within my folder so I need to remove all of them after the transfer.
[QUOTE=RobTrew;101179]It might prove simpler to export to RTF and then convert the RTF to PDF. An illustrative snippet: [CODE]property pstrConvert : "/System/Library/Printers/Libraries/convert -f " property pstrDesktop : POSIX path of (path to desktop) property pstrTempFile : pstrDesktop & "tmp.rtf" tell application "OmniOutliner Professional" -- EXPORT TO RTF set oDoc to front document export oDoc as "OORTFPboardType" to pstrTempFile -- CONVERT RTF TO PDF do shell script pstrConvert & quoted form of pstrTempFile & ¬ " -o " & quoted form of (pstrDesktop & name of oDoc & ".pdf") -- DELETE TMP RTF FILE do shell script "rm " & pstrTempFile end tell [/CODE] [COLOR="White"]--[/COLOR][/QUOTE] |
You can do it all directly from the shell:
[CODE]osascript -e 'tell application id "OOut" to export front document as "OORTFPboardType" to "~/tmp.rtf"' > /dev/null 2>&1 /System/Library/Printers/Libraries/convert -f ~/tmp.rtf -o output2.pdf > /dev/null 2>&1[/CODE] |
Ok thanks but how can I specify witch folder I want to use and where I want to save it ?
[QUOTE=RobTrew;101190]You can do it all directly from the shell: [CODE]osascript -e 'tell application id "OOut" to export front document as "OORTFPboardType" to "~/tmp.rtf"' > /dev/null 2>&1 /System/Library/Printers/Libraries/convert -f ~/tmp.rtf -o output2.pdf > /dev/null 2>&1[/CODE][/QUOTE] |
Right there in the command line you supply:
[code] osascript -e 'tell application id "OOut" to export front document as "OORTFPboardType" to "~/tmp.rtf"' > /dev/null 2>&1 /System/Library/Printers/Libraries/convert -f ~/tmp.rtf -o output2.pdf > /dev/null 2>&1 [/code] the "-o output2.pdf" portion of the convert command tells it to write the output to a file named "output2.pdf" in the current directory. If you want to put it in the directory called "Example" in your home directory, that would be "-o ~/Example/output2.pdf" and so on. Rob's illustrative snippet illustrates the process of building up that command string. To save you the trouble of copying the file to the NAS volume and then deleting the local copy, you could write it directly to the NAS volume. All of this supposes that you've already figured out what the name of the file is going to be, of course... |
Ok thanks but I way talking about the input directory, how to set it ?
I have a folder with subfolder, the input would be the main folder. Every day there is change with all the .oo3, every day I launch a bash script who save all data to the has. To the has I want the .oo3 and the .pdf. So within the bash script I would like to add an applescript which gonna use the main folder and convert all the file in .pdf and move them to the has. So here in the script I don't know how to change the input, front document. [QUOTE=whpalmer4;101205]Right there in the command line you supply: [code] osascript -e 'tell application id "OOut" to export front document as "OORTFPboardType" to "~/tmp.rtf"' > /dev/null 2>&1 /System/Library/Printers/Libraries/convert -f ~/tmp.rtf -o output2.pdf > /dev/null 2>&1 [/code] the "-o output2.pdf" portion of the convert command tells it to write the output to a file named "output2.pdf" in the current directory. If you want to put it in the directory called "Example" in your home directory, that would be "-o ~/Example/output2.pdf" and so on. Rob's illustrative snippet illustrates the process of building up that command string. To save you the trouble of copying the file to the NAS volume and then deleting the local copy, you could write it directly to the NAS volume. All of this supposes that you've already figured out what the name of the file is going to be, of course...[/QUOTE] |
All times are GMT -8. The time now is 04:57 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.