Hello
I’m trying to drive Pages to export documents as Rtf or Rtfd ones.
When the documents aren’t embedding graphic objects they are exported as xx.rtf but when graphic objects are embedded, I can’t find the required syntax.
Here is a quick and dirty script which I use to make tests.
--[SCRIPT
set p2d to "" & (path to desktop folder)
set chemin_de_Pages to p2d & "text_and_table.pages"
my export_to_rtf(chemin_de_Pages)
set chemin_de_Pages to p2d & "with_graphics.pages"
my export_to_rtf(chemin_de_Pages)
on export_to_rtf(chemin_de_Pages)
if chemin_de_Pages ends with ":" then
set off7 to 2
else
set off7 to 1
end if
tell application "Pages"
open chemin_de_Pages as alias
tell document 1
set nbg to count of every graphic
set nbt to count of every table
end tell
if (nbg - nbt) > 0 then
set xType to "SLDocumentTypeRichTextBundle"
set p_xport to (text 1 thru -off7 of chemin_de_Pages) & ".rtfd"
else
set xType to "SLDocumentTypeRichText"
set p_xport to (text 1 thru -off7 of chemin_de_Pages) & ".rtf"
end if
try
save front document as xType in p_xport
on error errMsg number errNbr
display dialog errMsg & return & "number #" & errNbr
end try
close front document saving no
end tell -- Pages
end export_to_rtf
--[/SCRIPT]
When the doc embed graphics, the export to rtfd fails with the error :
error “The document cannot be exported to the "Document RTF avec pièces jointes (RTFD)" format.” number -50
At this time, I am forced to use GUIscripting to achieve the goal.
Yvan KOENIG (VALLAURIS, France) mardi 1 février 2011 20:56:38