The following code is an example of how formatted output can be printed using a template file which was previously saved in the 'rtf' (Rich Text File) format using a word processing program, in this case ClarisWorks. This sample code and an example form letter 'rtf' template file (which includes a logo graphic in the letterhead) can be downloaded from http://macperl.com/depts/Code/_seay/Printer.hqx. Compare the "template_sample.rtf" file with the ClarisWorks file that is produced when you run "rtf_printer.pl" so you can see how it works. David Seay http://www.mastercall.com/g-s/ ---- #!perl # rtf_printer.pl # v1.0 # by David D. Seay -- g-s@navix.net # # Sample program to demonstrate printing formatted output # using a previously saved 'rtf' template file. &get_rtf_file; &substitute_data; &save_changed_rtf_file; &open_new_file; exit(0); sub get_rtf_file { =3D09$programFolderPath =3D3D `pwd`; =3D09chomp($programFolderPath); =3D09$rtfFilePath =3D3D $programFolderPath . ":template_sample.rtf"; =3D09$fileSize =3D3D -s $rtfFilePath; =3D09open(FILEDATA, "$rtfFilePath" || die "Can't get $rtfFilePath... $^E" )= ; =3D09read(FILEDATA, $rtfTemplate, $fileSize); =3D09close(FILEDATA); } sub substitute_data { =3D09$to =3D3D "Ms. Example"; =3D09$rtfTemplate =3D3D~ s/toWhom/$to/; =3D09$newLine1 =3D3D "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise."; =3D09$rtfTemplate =3D3D~ s/line1/$newLine1/; =3D09$newLine2 =3D3D "--Larry Wall"; =3D09$rtfTemplate =3D3D~ s/line2/$newLine2/; =3D09$rtfTemplate =3D3D~ s/columns1/One\tTwo\tThree/; =3D09$from =3D3D "Mr. Example"; =3D09$rtfTemplate =3D3D~ s/fromWhom/$from/; } sub save_changed_rtf_file { =3D09$to =3D3D~ s/ /_/g; =3D09$filePathNew =3D3D $programFolderPath . ":$to.rtf"; =3D09open(SAVEOUT, ">$filePathNew") || die "Could not save $filePathNew... $^E"; =3D09print SAVEOUT "$rtfTemplate"; =3D09close(SAVEOUT); =3D09$newCreator =3D3D "BOBO"; # CLARISWORKS =3D09&MacPerl::SetFileInfo($newCreator, "TEXT", "$filePathNew"); } sub open_new_file { =3D09$script =3D3D <<END_SCRIPT; =3D09tell application "ClarisWorks" =3D09 activate =3D09=3D09open file "$filePathNew" =3D09 do menu menu item "Print=3D8A" of menu "File" =3D09end tell END_SCRIPT =3D09&MacPerl::DoAppleScript($script); } __END__ # =3D3D=3D3D=3D3D=3D3D=3D3D Want to unsubscribe from this list? # =3D3D=3D3D=3D3D=3D3D=3D3D Send mail with body "unsubscribe" to macperl-re= quest@macp=3D erl.org