printPaperRectangle & LC7

Paul Hibbert paul at livecode.org
Sat Mar 21 21:28:13 EDT 2015


> On Mar 21, 2015, at 1:44 PM, Terence Heaford <t.heaford at icloud.com> wrote:
> 
> Why would printPaperRectangle not be 8,8,834,587 after I set the pagesetup to landscape on the first pass?

Long answer to a short question, skip this if you're not interested in printing on a Mac…

If you changed the printer settings in the Page setup dialogue or just assume that what you saw there was correct, then I suspect you may be hitting a bug that AFAIK is an old Apple bug and I seem to remember that LC has no control over it.

It is possible to have the print sizes mixed up from page setup to the print command, I just found this still exists. If you change the printer in the Page Setup dialogue it doesn't reflect the change in the Print dialogue, but it does the other way around.

This happens in Apple's Pages too along with some other apps that still use Page Setup, whereas apps like Preview have the Page Setup combined with the Print dialogue, much more sensible.

My conclusion is that the only *reliable* way to choose a print size is to set the correct printer first in the Print Dialogue (don't hit Cancel as the choice will not stick), then go back to Page Setup to choose the correct paper size, orientation etc., now you can print to that size with more confidence.

I haven't found an easy answer to this issue so far, but under certain circumstances this can cause the printPaperRect to be different to what you expect. Of course, if you use the same printer and page setup all the time, then this really shouldn't happen. One odd unintuitive workaround is to call the Answer Page Setup after calling the Answer Print dialogue, then everything lines up correctly e.g.

      case "Print"
         answer printer
         if the result is "Cancel" then exit to top
         answer page Setup
         if the result is "Cancel" then exit to top
         print card
       break

This is fine for personal stuff, but not so much for published apps.

Below is a test script I used in a menu button, you will need 2 printers connected with different margins to test this, usually from different manufacturers or maybe laser vs inkjet then try printing to alternate printers:

       case "Print"
         answer the printerName && the printPaperRect -- Returns the name of the last used printer & the last used printPaperRect
         answer page Setup -- ** Causes a problem if you don't have the correct printer selected here **
         if the result is "Cancel" then exit to top
         answer the printerName && the printPaperRect -- Returns the name of the last used printer & the printPaperRect of the page/paper chosen
         answer printer -- Note previous printer shown, now switch to the desired printer
         if the result is "Cancel" then exit to top
         answer the printerName && the printPaperRect -- Returns the name of the new printer chosen & the printPaperRect of the page/paper chosen in Page Setup
	 -- print card -- Disabled to save paper!
       break

      case "Print Fix"
         answer the printerName && the printPaperRect -- Returns the name of the last used printer & the last used printPaperRect
         answer printer -- You need to switch printers here to ensure correct output
         if the result is "Cancel" then exit to top
         answer the printerName && the printPaperRect -- Returns the name of the new printer chosen & the last used printPaperRect
         answer page Setup -- The correct printer displays in the dialogue box - no confusion!
         if the result is "Cancel" then exit to top
         answer the printerName && the printPaperRect -- Returns the name of the new printer chosen & the correct printPaperRect of the page/paper chosen
	 -- print card -- Disabled to save paper!
       break

In the first case "Print", if the previously used printer is a laser printer with margins of say 18 and in the Page Setup dialogue you choose the paper size of letter, but overlook setting the printer, then in the Print dialogue, you set the printer to an inkjet printer that has margins of say 8, the new margins will not be applied to the printPaperRectangle, they will be 18.

In the second case "Print Fix", choosing the printer in the Print dialogue will update the printer choice in the Page Setup dialogue so when you choose a page size, the margins will be correct for the printer chosen.

Of course this should all go away if/when LC has access to the new style print dialogue like the one used for Apple's Preview app. I notice that Adobe has rolled their own for Photoshop.

Paul



More information about the use-livecode mailing list