TweetFollow Us on Twitter

June 96 - Print Hints: The Top 10 Printing Crimes Revisited

Print Hints: The Top 10 Printing Crimes Revisited

DAVE POLASCHEK

They say some things never change. Although it's been four years since Pete "Luke" Alexander wrote about the top 10 printing crimes in develop, people are still committing some of the same crimes. There are also a few new crimes to add to the list. So, here they are, the updated top 10 printing crimes (ordered on a combined frequency and hideousness scale):


    10. Having insufficient free memory at print time.

    9. Coloring outside the lines.

    8. Misusing the PostScriptHandle picture comment.

    7. Calling PrintDefault or PrValidate before PrOpen.

    6. Avoiding the print dialogs, especially PrJobDialog.

    5. Accessing undocumented fields in the print record.

    4. Not checking error return values.

    3. Making low-level Printing Manager calls.

    2. Not using QuickDraw GX print dialogs if QuickDraw GX is present.

    1. Adding printing to your application last.

Now let's look at how to avoid these crimes. The solutions are relatively easy.

SOLVING THE PRINTING CRIMES

10. Having insufficient free memory at print time.

Some printer drivers use a lot of memory. When a driver runs out of memory, the results are usually pretty bad, so you should give printer drivers as much memory as possible. Unfortunately, memory requirements vary from driver to driver, so it's hard to predict how much memory a driver will need.

Solution: Unload all unneeded code and resources before printing.

9. Coloring outside the lines.

Many applications draw outside the printable area of the page when printing. This can happen if the user has extended objects beyond the printable area. Drawing unneeded objects causes extra work for the driver and the printer, which affects performance. In some cases, the driver also needs to allocate extra memory to hold the objects or the enclosing rectangle.

Solution: Draw only the portions of objects that will appear on the page. This can be determined by looking at the rPage field in the printer information record (which is in the prInfo field of the print record).

8. Misusing the PostScriptHandle picture comment.

The PostScriptHandle picture comment is designed to add PostScript (TM) code to a page containing QuickDraw graphics. It's not designed to send multiple pages of pre-generated PostScript code to a printer (for that, you need to use the Pap.WorkStation.o library).

Solution: Use the PostScriptHandle picture comment only to draw a self-contained image, which will be added to any QuickDraw graphics already on the page. If the PostScript code needs to change the graphics state, it should save and restore the state. Think of the picture comment as a way to include an EPS image, with all the restrictions placed on EPS by Adobe (TM) (as specified in Appendix H of the PostScript Language Reference Manual, second edition). The PostScript code should be compatible with both Level 1 and Level 2 PostScript, and you should include a QuickDraw version of the graphic so that your users can print to a non-PostScript printer.

    For more information on how to use the PostScriptHandle picture comment, see Technote 1032, "Mixing QuickDraw & PostScript Printing from Your App: Some Gotchas," and Appendix B of Inside Macintosh: Imaging With QuickDraw.*

7. Calling PrintDefault or PrValidate before PrOpen.

The documentation for the Printing Manager (Chapter 9 of Inside Macintosh: Imaging With QuickDraw) mentions that you need to call PrOpen before calling any other Printing Manager functions. Unfortunately, the descriptions for PrintDefault and PrValidate don't repeat this warning.

Solution: Always call PrOpen before calling any other Printing Manager calls.

6. Avoiding the print dialogs, especially PrJobDialog.

Some applications try to avoid print dialogs because either user interaction isn't possible or the developer thinks the user will make a mistake. Because all of the many options for the current drivers, most notably LaserWriter 8, cannot be stored in the print record, you need to call PrJobDialog so that the driver can read in the options from where they're stored (usually in the preferences file). If you don't call PrJobDialog, the driver can't set up the print record correctly, and you might not get the output you expected. The solution should be to call PrJobMerge, but in many drivers PrJobMerge does a less than perfect job.

Solution: Call PrJobDialog before printing to set up your print record correctly, or use QuickDraw GX, which supports dialog-free printing.

5. Accessing undocumented fields in the print record.

Many of the fields in the print record are undocumented or documented as private. Printer drivers can use these fields however they choose. What works for one driver might cause another to crash or to print zillions of pages you don't want.

Solution: Use only the fields in the print record that are documented as public in Chapter 9 of Inside Macintosh: Imaging With QuickDraw.

4. Not checking error return values.

After any call to a Printing Manager function, you should check PrError. If you're calling PrGeneral, you should also check the iError field in the TGnlData structure. Be aware that newer drivers return errors that older drivers didn't. For example, PrStlDialog in LaserWriter 8 can return an error if the preferences file is missing or corrupted; many applications don't check for this error, and later crash when they've pushed the driver completely off the cliff.

Solution: Always check and handle printing errors. See the Macintosh Technical Note "A Printing Loop That Cares..." (PR 10) and the article "Meet PrGeneral" in develop Issue 3.

3. Making low-level Printing Manager calls.

The low-level Printing Manager routines, such as PrDrvrOpen, are obsolete and unsupported.

Solution: Never call the low-level routines.

2. Not using QuickDraw GX print dialogs if QuickDraw GX is present.

When you call the classic Printing Manager functions and QuickDraw GX is active, the user gets the old-style "compatibility dialogs," which lack many of the features that are provided in the QuickDraw GX print dialogs. There are two problems with this: the user doesn't have access to all of the QuickDraw GX features; and when some applications call the QuickDraw GX print dialog functions and others don't, two very different printing experiences are presented to the user.

Solution: Call the QuickDraw GX print dialog functions in your print loop if QuickDraw GX is present. For help, see the article "Adding QuickDraw GX Printing to QuickDraw Applications" in develop Issue 19. The complete documentation can be found in Inside Macintosh: QuickDraw GX Printing.

1. Adding printing to your application last.

Four years later, this is still the number-one printing crime. A lot of developers leave printing until near the end of the product development cycle. When problems are encountered, Developer Technical Support gets messages like: "My application can't print, and I've got to ship today. Please answer as soon as possible."

Solution: Hook up your print loop as early as possible. As you add each new feature to your application, print a page or two. Make sure that things are still working as expected. When you take this approach, any features that cause printing problems get noticed early, and you'll have time to fix them.

A CLOSING NOTE

If you're committing any of the crimes on this list, your customers are probably seeing things they don't like when they print. This list is also far from comprehensive, as people continue to find new and unique ways to abuse the Macintosh print architecture.

Looking ahead, printing will be changing in a big way. Mac OS 8 will use QuickDraw GX as the printing model. As changes occur, there will be Technotes, develop articles, and other sources of information. So keep your eyes open, and remember, don't commit too many printing crimes. Crime doesn't pay.

DAVE POLASCHEK supports printing and font-related issues in Apple's Developer Technical Support group. Dave was last seen wandering the halls muttering, "This will all be better in Mac OS 8" and laughing maniacally.*

Thanks to Pete "Luke" Alexander, Paul Danbold, Dave Hersey, and Jim Zandee for reviewing this column.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Adobe Pepper Flash Player 32.0.0.142 - P...
Adobe Pepper Flash Player is a cross-platform, browser-based application runtime that provides uncompromised viewing of expressive applications, content, and videos across browsers and operating... Read more
Duet 2.0.5.0 - Use your iPad as an exter...
Duet is the first app that allows you to use your iDevice as an extra display for your Mac using the Lightning or 30-pin cable. Note: This app requires a $9.99 iOS companion app. Version 2.0.5.0:... Read more
Thunderbird 60.5.1 - Email client from M...
As of July 2012, Thunderbird has transitioned to a new governance model, with new features being developed by the broader free software and open source community, and security fixes and improvements... Read more
OnyX 3.5.7 - Maintenance and optimizatio...
OnyX is a multifunction utility that you can use to verify the startup disk and the structure of its system files, to run miscellaneous maintenance and cleaning tasks, to configure parameters in the... Read more
Sketch 53.1 - Design app for UX/UI for i...
Sketch is an innovative and fresh look at vector drawing. Its intentionally minimalist design is based upon a drawing space of unlimited size and layers, free of palettes, panels, menus, windows, and... Read more
Vivaldi 2.3.1440.48 - An advanced browse...
Vivaldi is a browser for our friends. We live in our browsers. Choose one that has the features you need, a style that fits and values you can stand by. From the look and feel, to how you interact... Read more
Hopper Disassembler 4.5.6- - Binary disa...
Hopper Disassembler is a binary disassembler, decompiler, and debugger for 32- and 64-bit executables. It will let you disassemble any binary you want, and provide you all the information about its... Read more
Civilization VI 1.2.0 - Next iteration o...
Sid Meier’s Civilization VI is the next entry in the popular Civilization franchise. Originally created by legendary game designer Sid Meier, Civilization is a strategy game in which you attempt to... Read more
Parallels Desktop 14.1.2 - Run Windows a...
Parallels allows you to run Windows and Mac applications side by side. Choose your view to make Windows invisible while still using its applications, or keep the familiar Windows background and... Read more
Chromium 72.0.3626.109 - Fast and stable...
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web. Version 72.0.3626.109: A list of changes is... Read more

Latest Forum Discussions

See All

Everything you need to know to win in Kn...
Knights of the Card Table is a really clever, solitaire dungeon crawler that's not just crammed to the gills with monsters to fight and loot to find, it's also got one of the biggest hearts of any game we've seen on the App Store. We definitely... | Read more »
A quick beginner’s guide to Final Blade
Final Blade was developed by newcomer SkyPeople studio, with help from localisation guru Glohow. After two years exclusively in the hands of South Korean and Chinese players, the game is now celebrating its global launch. Hurrah! But if you’re a... | Read more »
The best games for iPhone and iPad that...
How is it already Thursday again? My oh my, doesn't time fly when you're playing the very best mobile games out there? We certainly hope it does, because we've gone ahead and written a list of what we think are the top 5 best games for iPhone and... | Read more »
Three games for iPad and iPhone to keep...
On Monday we told you that Apex Legends is, all being well, eventually going to end up on the App Store. That means you'll be able to play one of the best new battle royale shooters in months in the palm of your hand. However, it hasn't happened... | Read more »
Why you should be excited about Apex Leg...
You've no doubt heard of Apex Legends by now. It's a new take on the battle royale genre developed by Respawn, and published by EA. It went live on EA Origin, PS4, and Xbox One last week, and it's already been generating a lot of buzz around the... | Read more »
Epic fantasy RPG Final Blade celebrates...
Now is a great time for RPG fans the world over as Final Blade has, well, finally got its global release for iOS and Android. The grand-scale RPG developed by Skypeople Inc in association with Glowhow, the has been quite the hit over in Taiwan and... | Read more »
Airheart launches on Nintendo Switch, de...
You’d be forgiven for thinking a game about harpooning fish and fighting pirates would be set on the high seas. But the action in Airheart is entirely airborne. Following up on its PC and Playstation release last year, this award-winning game has... | Read more »
Innovative match-3 puzzler Ingot Rush ha...
Match-3 games are pretty darn popular on mobile, and with so many innovative takes on the core concept, it’s easy to see why. Today we present you Ingot Rush for iOS, a colourful, globetrotting adventure that brings plenty of its own fresh ideas to... | Read more »
The top 5 best games for iPhone and iPad...
It's that time again - Thursday has rolled around which means the latest batch of new mobile games has landed on the App Store. There's loads of them, like there always is, so we've taken steps to make sure you know which are the best games that... | Read more »
The top 5 best word games for iPhone and...
Word games can be a tricky genre to pin down. There are so many variations out there that sometimes it's hard to decide whether or not a game fits into the little pocket you're trying to push it into. That doesn't bother us though, because it's our... | Read more »

Price Scanner via MacPrices.net

B&H offers 2018 13″ 2.3GHz 4-Core Apple M...
B&H Photo has new 2018 13″ 2.3GHz Quad-Core Touch Bar MacBook Pros on sale for $150 off MSRP. These are the same MacBooks sold by Apple in their retail and online stores. Shipping is free: – 2018... Read more
President’s Day Weekend Sale: B&H offers...
B&H Photo has dropped prices on new 2018 15″ 6-Core Touch Bar MacBook Pros with models now on sale for $300-$400 off MSRP, starting at $2099. These are the same models sold by Apple in their... Read more
President’s Day Weekend Sale: New 2018 13″ Ap...
B&H Photo has new 2018 13″ MacBook Airs on sale for $100-$200 off MSRP this weekend, starting at only $1049. Shipping is free: – 13″ 1.6GHz/128GB MacBook Air Space Gray: $1099.99. $100 off MSRP... Read more
New Sprint promotion: Get iPhone 7 preowned f...
Sprint is offering the 32GB iPhone 7, preowned, for $3 per month when combined with a Sprint 18 month Flex lease. Offer is valid from 2/15/19 to 2/21/19. The iPhone cost is applied as a $9 bill... Read more
New Emoji Update Version 12.0 Another Example...
COMMENTARY: 02.15.19- A slew of 15 new emojis reflecting people with disabilities is forthcoming in the version 12.0 update for smartphone devices including the iPhone but whose idea was it in the... Read more
13″ 2.3GHz MacBook Pros available at Apple st...
In the market for a 13″ MacBook Pro and looking for the lowest prices you can find? Apple’s refurbished prices are the lowest available for each model from any reseller. An standard Apple one-year... Read more
People Profiles: This Apple Fan Owns A Collec...
FEATURE: 02.14.19- We Apple fans love almost everything that the Cupertino, California-based tech company doles out to the masses and one particular fellow who has amassed a complete personal... Read more
Update: Amazon now selling Apple Watch Series...
Get an Apple Series 3 Watch today for up to a massive $100 off MSRP at Amazon. That’s up from $50 off previously. Choose Amazon as the seller rather than a third-party, and note that Amazon stock... Read more
Adorama offers new 2018 15″ 6-Core MacBook Pr...
Adorama has new 2018 15″ 6-Core Touch Bar MacBook Pros on sale today for $164-$224 off MSRP. Shipping is free, and Adorama charges sales tax for NY & NJ residents only: – 2018 15″ 2.2GHz Space... Read more
Deal Alert! Get a 256GB 11″ WiFi Apple iPad P...
Amazon has the new 2018 Apple 11″ 256GB WiFi iPad Pro in stock today and on sale for $150 off MSRP. Shipping is free: – 11″ 256GB WiFi iPad Pro: $799.99 $150 off Their price is the lowest available... Read more

Jobs Board

*Apple* Mobile Master - Best Buy (United Sta...
**673204BR** **Job Title:** Apple Mobile Master **Job Category:** Store Associates **Location Number:** 001514-Hutchinson-Store **Job Description:** **What does a Read more
Geek Squad *Apple* Master Consultation Agen...
**673307BR** **Job Title:** Geek Squad Apple Master Consultation Agent **Job Category:** Services/Installation/Repair **Location Number:** 001011-Spulvda Read more
*Apple* / Mac Support Technician - CompuCom...
Previous Apple / Mac Support Technician Next **Ref No.:** 19-00493 **Location:** Richfield, Minnesota As part of a leading IT managed services specialist with more Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States- Apple Blossom Mall 1850 Apple Blossom Dr Job ID:1044618 Date:February 11, Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States- Apple Blossom Mall 1850 Apple Blossom Dr Job ID:1042611 Date:February 11, 2019 Job Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.