Printer error in this code

Hello,
Can someone tell me what this error message means:

error “Adobe InDesign CS5.5 got an error: Printing Error: Problem initializing the current printer. Check the system print settings.” number 2582

I get it at the same time when the script hits this line:

					print without print dialog

thanks
babs

Not sure if this helps, but this is the entire block of code:

tell application "Adobe InDesign CS5.5"
				activate
				open (oneFile as alias)
				tell front document
					tell print preferences
						set page range to all pages
						set scale proportional to true
						set scale width to 100
						set page position to centered
						set page information marks to true
					end tell
					print without print dialog
					close saving no
				end tell
			end tell

Hello

(1) As this piece of code is a subset of a larger script I wish to get a precision.
Are you using the Finder to set the variable oneFile or are you using my edited version which use System Events ?

With System Events, oneFile is a string so coercing it as alias is required but if you use the Finder, if I remember well, oneFile is an alias so trying to coerce it as an alias generates an error.

(2) Are you sure that the piece of code which you use to set the printer to use is doing correctly its job ?

Given the error message, I’m wondering if it really does.

For those which are unaware of the complete script, it’s available at :

http://macscripter.net/viewtopic.php?id=41244

To be short, the code supposed to select the printer is :


choosePrinter()

on choosePrinter()
   tell application "Printer Setup Utility"
       set printerList to name of every printer
   end tell
   choose from list printerList with prompt "Choose the printer you wish to use."
   set thePrinter to item 1 of result
   
   tell application "Printer Setup Utility"
       set current printer to first printer whose name is thePrinter
   end tell
end choosePrinter

I have only one printer (out of function at this time) so I can’t test this code.

In the pointed thread, I gave you a link to a web site extensively dealing with printing from inDesign using AppleScript.
I looked quickly at the different lessons and in all of them the instruction used to print is :


print using (mgPrintPreset as string) without print dialog

In your script, you use :


print without print dialog

Yes, the piece of code “using (mgPrintPreset as string)” is missing

May you look at inDesign AppleScript dictionary to check if this one is optional or required ?
If it’s required, it’s probably what is causing the error.

KOENIG Yvan (VALLAURIS, France) mardi 30 juillet 2013 18:53:29

Hi Yvan,

I have been playing with this and I was looking at the dictionary and trying things.

This worked fine at my house, but when I tried to do it at my students machine, it stopped at that line I mentioned above. I have been playing with your suggestions and I will see if they work tomorrow when I go back.

thanks again for all your help!!!
babs

Maybe the problem is that somebody else is changing the default printer.

You may try to use this edited version :



# I REFUSE TO CALL THE FINDER WHICH IS A SNAIL WHEN IT IS NOT ABSOLUTELY REQUIRED.
# IN FACT IT'S REQUIRED ONLY WHEN WE HAVE TO MANIPULATE ICONS OR FINDER WINDOWS.


property scriptVersion : "0.3"
property theScriptDesc : "InDesign Print" & return & ""
on run
	choose folder with prompt "Choose an input folder." with multiple selections allowed
	my mainCode(result)
end run

on open sel
	my mainCode(sel)
end open

on mainCode(FileSamples)
	
	display alert (theScriptDesc as string) message ("Version " & (scriptVersion as string)) giving up after 2 buttons "¢"
	# choose the printer which will be used but don't set it here.
	set myPrinter to choosePrinter()
	
	repeat with oneFolder in FileSamples
		(*
	text 1 thru -2 of (oneFolder as text)
	set folderName to text -((offset of ":" in ((reverse of (characters of result)) as text)) - 1) thru -1 of result # disabled because the name is never used
	*)
		--On my machine, Finder as well as System Events return kind = "indd" for inDesign documents
		--I guess that it's because inDesign isn't available here
		
		tell application "System Events" to set theFiles to (path of files of oneFolder whose name extension is "indd" or kind contains "InDesign")
		# would be better using the "type identifier" BUT I DON'T KNOW WHICH IS THE VALUE FOR INDESIGN FILES !
		# tell application "System Events" to set theFiles to (path of files of oneFolder whose type identifier in "co.adobe.complete the indesign identifier")
		# THE TYPE IDENTIFIER USED ABOVE IS A FAKE ONE BECAUSE I DON'T KNOW THE CORRECT ONE
		# OF COURSE, ONLY ONE OF THE TWO INSTRUCTIONS CREATING THE LIST theFiles MUST BE ACTIVATED
		
		repeat with oneFile in theFiles
			# WHEN WE USE THE FINDER, THE TRAILING (DISABLED) INSTRUCTION BEHAVE WELL 
			# BECAUSE APPLESCRIPT IS FAIR ENOUGH TO SPEAK TO THE FINDER WHICH IS NOT EXPLICITELY TARGETTED BY THE CODE.
			# I DISLIKE CODE RELYING OF SUCH FEATURE.
			# AS I SPEAK TO SYSTEM EVENTS, THIS FEATURE DOESN'T APPLY. GOOD POINT FROM MY POINT OF VIEW.
			# THIS IS WHY I EDITED THE INSTRUCTION.
			# I DIDN'T THOUGHT THAT IT WAS USEFUL TO INSIST ABOUT THAT BECAUSE oneFileName IS NOT USED BY THE SCRIPT
			# set onefileName to name of oneFile # YOUR INSTRUCTION
			#
			# tell application "System Events" to set oneFileName to name of disk item oneFile # the original instruction was wrongly coded
			# I EDITED IT. I DISABLED IT BECAUSE THE FILENAME WAS UNUSED !
			#
			
	# set the printer to use here so chance that somebody else change it is reduced.
	tell application "Printer Setup Utility"
	set current printer to first printer whose name is myPrinter
	end tell
#
		tell application "Adobe InDesign CS5.5"
			activate
			open (oneFile as alias)
			tell front document
				tell print preferences
					set page range to all pages
					set scale proportional to true
					set scale width to 100
					set page position to centered
					--set mark offset to 0.0833 --as real? # NO NEED TO COERCE AS A REAL, 0.0833 IS ALREADY A REAL !
					set page information marks to true
				end tell
	(*
	# I don't know which is the owner of the print preferences defined above.
	#If it's the document, you may try to set the printer to use here so chance that somebody else change it is reduced.
	tell application "Printer Setup Utility"
	set current printer to first printer whose name is myPrinter
	end tell			
	*)
				print without print dialog
				close saving no
			end tell
		end tell
		
		end repeat # with oneFile
	end repeat # with oneFolder
	#
	#
	# THERE IS NO NEED TO TRIGGER THE FINDER TO CALL DISPLAY DIALOG
	# THIS IS WHY I DISABLED THESE INSTRUCTIONS !
	# DON'T ASK FOR HELP IF YOU REFUSE TO TAKE CARE OF GIVEN ANSWERS !
	# tell application "Finder"
	#	activate
	#
	#
	beep
	display dialog "All input files have been printed." buttons "Ok" default button 1
	#
	# end tell
	#
end mainCode


on choosePrinter()
	tell application "Printer Setup Utility"
		set printerList to name of every printer
	end tell
	choose from list printerList with prompt "Choose the printer you wish to use."
	return item 1 of result
end choosePrinter

As you may see I’m offering two locations to set the printer to use for each document.
My preferred location is the second one (disabled at this time) but as I don’t know inDesign I’m not sure that it’s a correct one.

KOENIG Yvan (VALLAURIS, France) mercredi 31 juillet 2013 10:59:10

Well…I think I surrender…
It works fine in my house, so the script works…but just not in this office??

I have tried every combination I can think of here, after switching things around per your instructions, or at least to the best of my abilities. I do think I have tried everything I can.

There must be something strange here???

I will keep trying, but I just wanted to thank you for all of this…it’s a mystery…

Babs

It’s why I assumed that maybe somebody was changing the default printer between your call to the original “choose printer” handler and your attempt to print.

Changing a bit as I did was designed to fight that.

The edited script allowed you to choose a printer once at the very beginning.

Then, the choosen printer was defined as the default one just before the attempt to print.

Are you allowed to change the default printer if an other one is really busy ?

KOENIG Yvan (VALLAURIS, France) mercredi 31 juillet 2013 16:02:10

I tested just the InDesign part in CS, and it failed with an error about printer configuration. After letting a test document go through with the printer dialog enabled, all subsequent attempts worked as expected. I don’t know if this is an isolated problem in CS or not. Does this work?


tell application "Adobe InDesign CS5.5"
              tell make document
			  tell print preferences to set print blank pages to true
			  print with print dialog
			  close saving no
			  end
			                open (choose file)
               tell front document to print without print dialog
           end tell

Hi Yvan,
I don’t think anyone is changing the default printer. I even made sure to go into the system preferences and make sure the one I was picking from the group was the one I wanted. Going with your lead, I figured that might help. Still playing with it… in between my students…
It seems so odd that it would work at my house, but not here…It finds my 2 printers at home and when I come here, if finds her 3 without a problem. Not sure why it dies at that one line?
gonna keep at it…
thanks!!

hi Marc,

If I switch this part out

tell application "Adobe InDesign CS5.5"
				activate
				open (oneFile as alias)
				tell front document
					tell print preferences
						set page range to all pages
						set scale proportional to true
						set scale width to 100
						set page position to centered
						--set mark offset to 0.0833 --as real? # NO NEED TO COERCE AS A REAL, 0.0833 IS ALREADY A REAL !
						set page information marks to true
					end tell
					
					(*tell application "Printer Setup Utility"
						set current printer to (first printer whose name is myPrinter)
					end tell*)
					
					print using (mgPrintPreset as string) without print dialog
					close saving no


with yours

tell application "Adobe InDesign CS5.5"
						tell (make document)
							tell print preferences to set print blank pages to true
							print with print dialog
							close saving no
						end tell
						open (choose file)
						tell front document to print without print dialog
					end tell

This does open the print dialog box, and I have to hit OK, but then it loops to have me find another file?

I have to go teach another class, but will be back to try some more…maybe getting closer.

thanks!!
babs

It’s not my intent that you incorporate this into the existing code; it’s a standalone test. The blank document should “print” without fail; the question is whether or not this step fixes your configuration issue under CS5 and allows you to invisibly print real files.

Hi Marc,
Gotcha!!!
thanks!
babs