While working on a script converting AppleWorks documents into Pages ones to export them as PDF I discovered an annoying feature.
When the document use the font named Bookman, the imported document looks well in Pages but in the final PDF I get only a rectangle for every character.
So I tried to identify parts of text using Bookman.
As I am curious, I try to identify the documents using the Bookman font.
if I extract the font name of a text, I get the attribute or its 1st character
If I extract the font name of every paragraph I get the attribute of the 1st character of all of them.
If I was able to extract the font name of every Attribute run I would get the attribute of every chunks that all have the same attributes.
At first look it seems that it may be better than grabbing the font name of every character.
Alas, Every attempt to use “attribute run” fails with infamous error -1728
(*
Pages v4.x must be running while Pages v5.x is not loaded
*)
if (get version of application id "com.apple.iWork.Pages") does not start with "4" then error "Oops, this script requires Pages v.4.x"
set cheminDocAW to choose file "choose an AppleWorks WP file" of type {"CWWP"}
tell application id "com.apple.iWork.Pages"
open cheminDocAW
tell document 1
tell its paragraphs
font name
--> {"Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Bookman-Light", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman", "Palatino-Roman"}
end tell
tell its paragraph 1
--font name of attribute runs --> error number -1728 from every attribute run of paragraph 1 of document 1
end tell
tell its text
font name of its attribute runs
--> error "Erreur dans Pages 09 : Il est impossible d'obtenir every attribute run of every text of document 1." number -1728 from every attribute run of every text of document 1
end tell
end tell
end tell
Mac OS error -1728 (errAENoSuchObject): e.g.,: specifier asked for the 3rd, but there are only 2. Basically, this indicates a run-time resolution error.
As the dictionary describes an attribute named “font” which is in fact named “font name” I wonder if “attribute run” must be spelled an other way.
[format]attribute run‚n [inh. item] : This subdivides the text into chunks that all have the same attributes.
elements
contains attachments, attribute runs, characters, paragraphs, words; contained by attribute runs, characters, paragraphs, text, words.
properties
color (color) : The color of the first character.
font (text) : The name of the font of the first character.
size (integer) : The size in points of the first character.[/format]
Maybe one of you know the correct incantation.
Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) dimanche 4 septembre 2016 15:32:30