Printing Difficulties...

I am in the process of creating an app that will output a fax proof sheet for the print shop that I work for. Jobu gave a wonderful explanation of how to set a “form” that the user can fill out in this thread: http://bbs.applescript.net/viewtopic.php?t=8177

The problem that I am facing is that I am getting absurdly large margins (i.e.: 1.25" on average) when I try to print the form to a laser printer. I even created a custom page that has NO built-in margins (i.e.: it can print to the edge of the sheet). No difference! :x

The app’s fax sheet needs to look just like the sheet that is filled out by hand. I have created a PDF of that sheet that I am using for the app. What do I need to do to fix my “huge margin problem”?

Thanks in advance,
Brad Bumgarner, CTA

And thanks Jobu for the explanation on how to set this up in the first place.

Here’s what I just tested…

  1. I created an interface that had an image view, in a box, in a window. In the image view I placed an image that measured 7.5" x 10"… roughly the size to require .5 in margins… that had a black border on every edge, so I could see where the borders lined up in the printout.

  2. I inserted the following code into the handler executing the print routine…

on clicked theObject
	if name of theObject is "printButton" then
		set sharedPrintInfo to call method "sharedPrintInfo" of class "NSPrintInfo"

		(* The "36.0" parameter below refers to .5" in a 72dpi print/monitor environment *)
		call method "setLeftMargin:" of sharedPrintInfo with parameters {36.0}
		call method "setRightMargin:" of sharedPrintInfo with parameters {36.0}
		call method "setTopMargin:" of sharedPrintInfo with parameters {36.0}
		call method "setBottomMargin:" of sharedPrintInfo with parameters {36.0}
		
		(* Tell the box to print using the margin values we set above *)
		tell box "theBox" of window "theWindow"
			call method "print:" of object it
		end tell
	end if
end clicked
  1. When I clicked the button, I got a printout of the image that was ALMOST the way I would expect. I’m not sure if variances in the image resolution, or the rendering of the image were to blame, but I got a little more than a .5 inch margin on the right. You could perhaps tweak your image a bit to fit perfectly on the page, or you could find another way to center the content in the box so it better centers on the page. Regardless, I’d say this is the ticket to getting your margins set the right way. Entering a value of 0 in the margin parameter of each call method would theoretically give you a full-page printout of the view… but I didn’t go so far as to test that. I’ll leave some adventure in it for you to explore. :smiley:

FYI: I did a random print of something else after I did this to make sure that the values were reset automatically. I seems that they were, but you should test this and set them back to their defaults manually, if not. My printer’s defaults were 72 and 90 pixels L/R and T/B respectively. I got the methods for doing this HERE. There are also some other methods that may be of interest to people on this page for managing other print settings.

Good luck,
j

What? You’re not going to “spoon feed” me? :wink:

Thanks for the info. Works great. I couldn’t get my graphic to look good on output, so I recreated the form in IB. Prints out great!

Thanks,
Brad Bumgarner, CTA