• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Print to PDF under OS X and 9.2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Print to PDF under OS X and 9.2


  • Subject: Print to PDF under OS X and 9.2
  • From: MR <email@hidden>
  • Date: Fri, 4 Apr 2003 13:23:20 -0900

After a few weeks of tweeking, the following Filemaker and Applescripts scripts work great on my iMac running OS 10.2.4 and 9.2.2 in the Classic environment. The problem is that there are several users in my office that run just OS 9.2.2 on their Macs and it gives error codes. Why would it work under 9.2.2 in Classic mode running under OS X but not 9.2.2 alone? The MakeNewFolders scripts are the main problem now.

I'll describe each: I have put a file on the desktop named PDFfiles in advance. The first script - Print to PDF detects for OS X or 9.2.2 and then makes a folder with the title "Rev Rpt xx/xx/xxxx to xx/xx/xxxx" the xx's being whatever date range is in Filemaker. Those are global fields.

It then enters a loop to pull out individual dealers and print their reports to a pdf file. I have previously saved into the Page Setup and Print dialogs that it prints on horizontal format and saves as Adobe Acrobat PDF to the PDFfile folder as 1.pdf and clicked the replace Page Setup button when closing the script.

It then detects which system again and prints to a pdf file into the PDFfile folder. The current found records are then deleted and the omitted files come forward. If the current record count is zero it exits the script, otherwise it continues through the loop selecting the next dealer.

On exiting it then moves the files in the PDFfiles folder to the newly made "Rev Rpt xx/xx/xxxx to xx/xx/xxxx folder which the user will then move to an archive folder (later to be e-mailed).

PRINT TO PDF (First Script)

--snippets of code in the following script came from various contributors on this list, THANKS!
Go to Layout [Report]
If[Status(CurrentPlatform) = -1 --Detects for OS X or 9.2 system (-1 or 1)
Perform Script ["MakeNewFolderOSX"] [Sub-scripts]
Else
Perform Script ["MakeNewFolder9.2"] [Sub-scripts]
End If
Go to Record/Request/Page [First]
Loop
Enter Browse Mode
Copy [ dealer_name ] [Select entire contents]
Enter Find Mode
Past [ dealer_name ] [ Select Entire contents ]
Perform Find
Sort
Enter Preview Mode
If[Status(CurrentPlatform) = -1 --Detects for OS X or 9.2 system (-1 or 1)
Perform Script ["printOSX"] [Sub-scripts]
Else
Perform Script ["printr9.2"] [Sub-scripts]
End If
Enter Browse Mode
Delete All Records
Exit Loop If [Status(CurrentRecordCount) = 0]
Go to Record/Request/Page [First}
End Loop
Perform Script [ "MoveFilesToCurrentFolder" ] [Sub-script]

The following two scripts make a new folder after being called from the first script depending on whether it is OS X or 9.2. The only difference between the two scripts is the "as string" screws up when running in Classic under OS X. Why? It works great.

However, when running under 9.2.2 alone, I get the error "Finder got an error:Bad name for file:some object (Error -37)". Working in 9.2.2 alone, I tried modifying the script various ways but got various errors. I opened Script Editor and did a record session and tried to use the resulting script but to no avail when used inside Filemaker. Help!

MAKENEWFOLDEROSX (Second script)

--snippets of code in the following script came from various contributors on this list, THANKS!
Perform Applescript [
set x to cell "report_date_start" as string
set y to cell "report_date_end" as string
tell app "Finder
make new folder at desktop with properties {name: "Rev Rpt " & x & " to " & y}
end tell]

MAKENEWFOLDER9.2 (Third script)

--snippets of code in the following script came from various contributors on this list, THANKS!
Perform Applescript [
set x to cell "report_date_start" --as string doesn't seem to work under 9.2
set y to cell "report_date_end"
tell app "Finder
make new folder at desktop with properties {name: "Rev Rpt " & x & " to " & y}
end tell]

The following two scripts print the current found records to a pdf file into the folder PDFfiles on the desktop. Originally I had the Applescript in the first script above, right after where it calls for the print script. But under 9.2.2 it added two folders called "In" and "Out" into the folder which created errors on subsequent loops. Moving the Applescript into its current position cured that but I don't know why.

The main problem here is setting the source folder desktop location. Under OSX it seems to need the long path e.g. "MacHD:users:Mike:desktop:PDFfiles:" That only works on my specific computer. I need it to find the PDFfile folder on any desktop. How do I do that? I tried incorporating some of the thoughts in another thread concerning making a new folder in the library but couldn't get anything to work. Is there a way to make this universal on any Mac desktop?

Under 9.2 in the classic mode just putting ":PDFfiles:" seems to work but I haven't been able to test it in 9.2.2 alone. Should it work the same?

The applescript finds the first file, which should be 1.pdf, and renames it to the dealer name and attaches the ".pdf" to it. It works great under OS X and in 9.2 in Classic under OSX. I haven't been able to test it under 9.2.2 alone. See any problems?

PRINTOSX (fourth script)

--snippets of code in the following script came from various contributors on this list, THANKS!
Page Setup [Restore setup options, no dialog]
Print [No dialog]
Perform Applescript [
set z to cell "dealer_name"
set sourceFolder to "MacHD:users:Mike:desktop:PDFfiles:" --this needs to be made universal How?
tell app "Finder"
set theFile to first file in folder sourceFolder
set newFileName to z & ".pdf" as string
set name of theFile to newFileName
end tell

PRINT9.2 (fifth script)

--snippets of code in the following script came from various contributors on this list, THANKS!
Page Setup [Restore setup options, no dialog]
Print [No dialog]
Perform Applescript [
set z to cell "dealer_name"
set sourceFolder to ":PDFfiles:" --this seems to be universal under 9.2
tell app "Finder"
set theFile to first file in folder sourceFolder
set newFileName to z & ".pdf" as string --9.2 seems to accept this as string? but not in MakeNewFolder script above
set name of theFile to newFileName
end tell

This final script seems to work great under both OS X and 9.2 in the Classic mode under OSX. Again I haven't been able to test it under just 9.2.2. Do you see any potential problems here?

MOVESFILESTOCURRENTFOLDER

--snippets of code in the following script came from various contributors on this list, THANKS!
New Record/Request
Perform Applescript [
set x to cell "report_date_start" as string
set y to cell "report_date_end" as string
tell app "Finder"
move files in folder "PDFfiles" to folder ("Rev Rpt ' & x & " to " & y)
end tell
Delete Record/Request [No dialog]

I know this is a long post but I wanted to give back the final scripts that so many of you have helped with and I felt you needed to see the whole picture to possibly help me with the last few problems.

Mike
_______________________________________________
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.

  • Prev by Date: quark master pages
  • Next by Date: Re: IF Syntax
  • Previous by thread: quark master pages
  • Next by thread: Re: Print to PDF under OS X and 9.2
  • Index(es):
    • Date
    • Thread