PDF convert
PDF convert
- Subject: PDF convert
- From: Barry Jaques <email@hidden>
- Date: Sun, 16 Dec 2001 16:33:46 +1000
I am just submitting the following script as it may be useful to some users.
This script gets rid of the hundreds of extra returns generated after copying
and pasting the text of a PDF in Appleworks. This script is used with
Appleworks, which as is well known is not really scriptable. For example the
find/change function in Appleworks should be scriptable but it is not.
Ironically this forces a workaround which results in a much faster script as
apart from the basic copy and paste functions at beginning and end all the
operations are carried out within Applescript. If there are any paragraphs in
bold style which are required to be maintained as a list then that text should
be converted to plain before running the script. I learnt something new while
developing this script (bashing my head against the brick wall of disinformation
a few hundred times), which was not evident in any documentation. That is, you
cannot directly edit a variable (such as myFile), unless it is a list which
would be usless as the styles would be lost (I think). So the only way to alter
the contents of myFile is to force it to 'rewrite' itself as shown. If someone
can suggest an alternative method I would be very interested.
tell application "AppleWorks 6"
activate
if not (file "yourFile" exists) then
open file "Mac HD2:Desktop Folder:zap returns:yourFile"
end if
set myFile to text of front document
set charCount to count of characters of myFile
repeat with x from 1 to charCount - 1
if character x of myFile contains return then
set y to x - 1
set z to x + 1
if item 2 of (style of character y of front document as list) as
string does not contain {"bold"} ,
and character z of myFile does not contain return ,
and character y of myFile does not contain return ,
and character y of myFile "." then
--set character x of front document to space
set myFile to text from character 1 to character {x - 1} ,
of myFile & " " & text from character {x + 1} ,
to character charCount of myFile --rewrite myFile
end if
end if
end repeat
copy myFile to front document
end tell
Regards
Barry Jaques