PDF Services script won't process one page only
PDF Services script won't process one page only
- Subject: PDF Services script won't process one page only
- From: Michael Grant <email@hidden>
- Date: Fri, 07 Mar 2003 09:27:58 -0600
I have a script (see below) that I use with 10.2.4 PDF Services to
print-to-PDF with type and creator, for import into FileMaker. Unfortunately
I noticed today that it processes all pages of a file even if I set it to
print only one page in the print dialogue. Just previewing one page and
saving that as a PDF works fine. I assume this is a bug in PDF Services and
not in my script, but can anyone confirm? I was printing from Preview;
haven't tried PDFing only one page of a multipage document from other
applications.
(Oh, and if anyone knows a more elegant way to extract the filename and
container path from an HFS file path, please let me know.)
Thanks,
Michael
on open (aPDF)
set thePDF to item 1 of aPDF
set defName to "Untitled.pdf"
-- set default name for PDF to name of front window of application
printed from
try
set app1 to (path to frontmost application as string)
tell application app1
set defName to ((the name of window 1) & ".pdf")
end tell
end try
-- set type and creator codes
tell application "Finder"
try
set the creator type of file thePDF to "CARO"
try
set the file type of thePDF to "PDF "
on error y
display dialog y
end try
on error X
display dialog X
end try
-- save where?
set targetRef to (choose file name with prompt "Save PDF as:"
default name defName) as string
set targetName to my getName(targetRef)
set targetFolder to my getFolder(targetRef)
set the name of file thePDF to targetName
move file thePDF to folder targetFolder with replacing
if button returned of (display dialog ("Open ?" & targetName & "?
now?")) is "OK" then open file thePDF
end tell
end open
on getFolder(pathString)
tell AppleScript
set olD to text item delimiters
set text item delimiters to ":"
try
set thePath to ((text items 1 through -2 of pathString) as
string) & ":"
on error -- it's a disk
set thePath to text item 1 of pathString & ":"
end try
set text item delimiters to olD
return thePath
end tell
end getFolder
on getName(pathString)
if pathString ends with ":" then set pathString to (text 1 thru -2 of
pathString)
tell AppleScript
set olD to text item delimiters
set text item delimiters to ":"
set theName to the last text item of pathString
set text item delimiters to olD
end tell
return theName
end getName
--
"Maybe this world is another planet's hell."
- Aldous Huxley
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.