• 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
Re: Requesting advice with TextEdit & Acrobat printing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Requesting advice with TextEdit & Acrobat printing


  • Subject: Re: Requesting advice with TextEdit & Acrobat printing
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 19 Aug 2015 14:15:39 +0200


Le 19/08/2015 à 13:30, Brian Christmas <email@hidden> a écrit :

G’day Yvan

That line was just left over from code I removed from the handler, that wasn’t relevant to my problem.

However, I think I’ve solved the question.

I’ve set the TextEdit page size to default to A4 by setting it in Page Setup, and saving it as the TextEdit Default, and then using this handler to set the CUPS printer to the large page printer. Also, I’ve set the System Preferences Printers & Scanners default printer to the 'Large Page Printer', and the default paper size to ‘A4’ (which will be ‘A3' on my Clients Mac.

try
set nameOfPrinter to ""
repeat with eachChar in characters of (theLargePagePrinter as text) —< ‘Large Page Printer'
if eachChar = " " then
set nameOfPrinter to nameOfPrinter & "_" as text
else
set nameOfPrinter to nameOfPrinter & eachChar as text
end if
end repeat
do shell script ("lpoptions -d " & nameOfPrinter)
end try

G'day Chris

On my side you code fails.

I was forced to edit an instruction to get a code doing the wanted job.

Look.

(1) Original :
set theLargePagePrinter to "une grande imprimante"

set nameOfPrinter to ""
try
repeat with eachChar in characters of (theLargePagePrinter as text) --< ‘Large Page Printer'
if eachChar = " " then
set nameOfPrinter to nameOfPrinter & "_" as text
else
set nameOfPrinter to nameOfPrinter & eachChar as text
end if
end repeat
end try

nameOfPrinter -- >  "une grande imprimante"

(2) Edited version :

set theLargePagePrinter to "une grande imprimante"

set nameOfPrinter to ""
try
repeat with eachChar in characters of (theLargePagePrinter as text) --< ‘Large Page Printer'
if contents of eachChar = " " then
set nameOfPrinter to nameOfPrinter & "_" as text
else
set nameOfPrinter to nameOfPrinter & eachChar as text
end if
end repeat
end try

nameOfPrinter -- >  "une_grande_imprimante"

(3) On my side, I avoid character like the plague and would use :

set theLargePagePrinter to "une grande imprimante"

set nameOfPrinter to ""
try
repeat with eachChar in text of (theLargePagePrinter as text) --< ‘Large Page Printer'
if contents of eachChar = " " then
set nameOfPrinter to nameOfPrinter & "_" as text
else
set nameOfPrinter to nameOfPrinter & eachChar as text
end if
end repeat
end try

nameOfPrinter -- >  "une_grande_imprimante"

(4) As I am lazy, I would not write a new code using a loop when I have a handler using TIDS for this task

set theLargePagePrinter to "une grande imprimante"

set nameOfPrinter to my remplace(theLargePagePrinter, space, "_")
nameOfPrinter -- >  "une_grande_imprimante"

#=====
(*
replaces every occurences of d1 by d2 in the text t
*)
on remplace(t, d1, d2)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d1}
set l to text items of t
set AppleScript's text item delimiters to d2
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end remplace

#=====

(5) When I want to display a dialog, I don't trigger "System Events" but "SystemUIServer"
Maybe somebody will be able to explain what are the advantages of each of them;


Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) mercredi 19 août 2015 14:13:07




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Requesting advice with TextEdit & Acrobat printing
      • From: Brian Christmas <email@hidden>
References: 
 >Requesting advice with TextEdit & Acrobat printing (From: Brian Christmas <email@hidden>)
 >Re: Requesting advice with TextEdit & Acrobat printing (From: Yvan KOENIG <email@hidden>)
 >Re: Requesting advice with TextEdit & Acrobat printing (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Requesting advice with TextEdit & Acrobat printing
  • Next by Date: Re: date syntax not working on 10.10.5?
  • Previous by thread: Re: Requesting advice with TextEdit & Acrobat printing
  • Next by thread: Re: Requesting advice with TextEdit & Acrobat printing
  • Index(es):
    • Date
    • Thread