The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Exportation in pdf with an applescript Thread Tools Search this Thread Display Modes
It sounds like you want something like the following. Once you have all the documents open, this will cycle through them and execute the code in the inner section for each. Hope this helps!

Code:
tell application "OmniOutliner Professional"
	repeat with aDocument in every document

		-- e.g. the stuff you want to do goes here 
		set text of cell 2 of row 1 of aDocument to "hello"

	end repeat
end tell
 
Thanks, but can I do the same without opening anything ?

Quote:
Originally Posted by Brian View Post
It sounds like you want something like the following. Once you have all the documents open, this will cycle through them and execute the code in the inner section for each. Hope this helps!

Code:
tell application "OmniOutliner Professional"
	repeat with aDocument in every document

		-- e.g. the stuff you want to do goes here 
		set text of cell 2 of row 1 of aDocument to "hello"

	end repeat
end tell
 
You can get the file name from the shell process which loops through the .003 files.

If you can make sure that all documents in oo3 are closed, you can then assume that the newly opened one is the front document.

Don't have time for testing or debugging today, but you should be able to put something along these general lines in a shell script:

Code:
osascript -e 'tell application id "OOut" to close documents' > /dev/null 2>&1;
for f in *.oo3 
do 
	open "$f"
	sleep .5 # You may be able to reduce or remove this
	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 "$f".pdf > /dev/null 2>&1;
	osascript -e 'tell application id "OOut" to close documents' > /dev/null 2>&1;
done
rm ~/tmp.rtf

Last edited by RobTrew; 2011-08-31 at 04:39 AM..
 
Marvelous, Thanks for that. I have modify a little (add set front doc) and add the ability to manage folders and subfolders. After, just need to sync the .pdf with the nas and remove them. Thanks a lot, here is the final script :

Code:
  1 osascript -e 'tell application id "OOut" to close documents' #  > /dev/null 2>&1;  
2 for f in `find /Users/Pamphile/Desktop/a -name "*.oo3" -type d ` #  /Users/Pamphile/Desktop/*.oo3 
  3 do   
  4         open "$f"
  5         sleep .1
  6 osascript -e 'tell application id "OOut" to activate'
  7         osascript -e 'tell application id "OOut" to export front document as "OORTFPboardType" to "~/tmp.rtf"' #  > /dev/null 2>&    1;
  8         /System/Library/Printers/Libraries/convert -f  ~/tmp.rtf -o "$f".pdf #  > /dev/null 2>&1;
  9         osascript -e 'tell application id "OOut" to close documents' # > /dev/null 2>&1;
 10 done
 11 rm ~/tmp.rtf


Quote:
Originally Posted by RobTrew View Post
You can get the file name from the shell process which loops through the .003 files.

If you can make sure that all documents in oo3 are closed, you can then assume that the newly opened one is the front document.

Don't have time for testing or debugging today, but you should be able to put something along these general lines in a shell script:

Code:
osascript -e 'tell application id "OOut" to close documents' > /dev/null 2>&1;
for f in *.oo3 
do 
	open "$f"
	sleep .5 # You may be able to reduce or remove this
	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 "$f".pdf > /dev/null 2>&1;
	osascript -e 'tell application id "OOut" to close documents' > /dev/null 2>&1;
done
rm ~/tmp.rtf
 
Hi, I've notice that this script just work for the text but not for all the image and pdf inside !!! Do you have an idea ? I really need that ! Thanks
 
You can export the embedded graphics to an rtfd bundle by changing the export type:

Code:
osascript -e 'tell application id "OOut" to export front document as "OORTFDPboardType" to "~/tmp.rtfd"' > /dev/null 2>&1;
Not sure, however, whether convert can handle rtfd for the conversion to pdf - might need an intermediate conversion with textutil from rtfd to html - a bit busy now, but a problem that should yield to a bit of research ...

--

Last edited by RobTrew; 2011-09-12 at 04:38 PM.. Reason: added reference to textutil
 
Hi,
finally, I've found a solution on Internet and modify it a little to make it work.
Thanks again for everything !!! I appreciate your help !

here is the code if your need it :

Code:
# Saves current document open in foreground app as PDF using the Print dialog "Save as PDF" option

# value to limit how long we wait for a given dialog or menu popup
set maxloops to 100

# Open a log file - only used for debugging
# Log file is written to the root of the hard disk
# set fid to open for access "mylog.txt" with write permission

### Set process name based on the frontmost app ###
# This allows the script to run with whatever app is in foreground
# Note: Some apps use a property sheet and some use a window for the print
#          Dialog so depending on which we need to take different actions
set process_name to displayed name of (info for (path to frontmost application))
# If needed, you can hard-code the app name by uncommenting the following:
# set process_name "Firefox"
# If we hard-code the name, we should active the app
# activate application process_name 

tell application "System Events"
	tell process process_name
		
		# Open the print dialog
		keystroke "p" using command down
		
		# Wait until the Print dialog opens before proceeding
		set prdlg to 0 # Initialize loop variable
		set lcnt to 0 # Counter to prevent infinit loops
		repeat until prdlg is not 0
			# Determine if the app is using a dialog or a sheet for print options and then create reference to dialog or sheet for use later
			if exists window "Print" then
				# Current App uses the Print dialog (not sheet)
				set prdlg to 1
				set prdlgref to a reference to window "Print"
				set wtype to "dlg"
			else if exists sheet 1 of window 1 then
				# Current App uses the Print sheet (not dialog)
				set prdlg to 1
				set prdlgref to a reference to sheet 1 of window 1
				set wtype to "sht"
			end if
			set lcnt to lcnt + 1
			if (lcnt) > maxloops then
				display dialog "Reached Max Loops waiting for print dialog to open."
				return
			end if
		end repeat
		
		# Expand the "PDF" menu button (must be expanded before the menu is referencable)
		click menu button "PDF" of prdlgref
		
		# Wait until the Menu button menu is created before proceeding
		set lcnt to 0
		repeat until exists menu item "Enregistrer au format PDF…" of menu 1 of menu button "PDF" of prdlgref
			set lcnt to lcnt + 1
			if (lcnt) > maxloops then
				display dialog "Reached Max Loops waiting for Save as PDF dropdown to open."
				return
			end if
		end repeat
		
		# Select the "Save as PDF" menu item
		click menu item "Enregistrer au format PDF…" of menu 1 of menu button "PDF" of prdlgref
		
		# Wait until the Save dialog opens before proceeding
		keystroke return	
	end tell
end tell
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML and AppleScript seanprice OmniFocus Extras 0 2013-03-14 02:07 PM
Applescript help mojaverat OmniFocus 1 for Mac 1 2011-08-23 04:18 PM
Applescript? dbadev OmniDazzle 0 2011-06-22 06:46 PM
Applescript Help ryan_marsh OmniFocus 1 for Mac 3 2008-11-24 09:51 AM
Applescript, run from USB jem OmniFocus 1 for Mac 4 2007-05-22 03:09 AM


All times are GMT -8. The time now is 08:30 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.