This is the stuff I really want to see in Qt 4.6 and I would appreciate any assistance to get us there. Most other stuff we have work-arounds for, but this stuff can only be done by directly hacking in the heart of QPrinter and QPrintDialog.
* Current Page: This is the option in the Print Dialog to print whatever the currently selected page is in the Application.
* Page Set: This is the option in the Print Dialog to print either Odd or Even or All pages.
* Non-Continuous Page Range: This is the option in the Print Dialog to instead of just entering the From and To page number to instead type in a free text page range that may have gaps in the range, e.g. "3-6,9-13,15".
First a rough and ready explanation about how Qt does cross platform printing support. The underlying Qt print engine has backends implemented for each platform, so you paint onto QPrinter/QPainter and it then translates that into something the native Print System can print (ps/pdf for CUPS or LPR on X11, pdf for CUPS on OSX, GDI or whatever it’s called on Windows). The visible Print Dialog however is only implemented by Qt for the X11 environment, on Windows and OSX the native OS print dialog is called and the selected values are then passed back into QPrinter to be used by the app.
The big problem with adding these three features is that, unlike KDE3, QPrinter only tells the application the From and To page numbers to print, and all Qt and KDE4 programs have been coded to generate all the pages in that range to send to the Print System. The apps have no way of knowing that they must leave out pages in between, so any such features would in theory require all apps to be re-coded to use them and enable them in the dialog individually, which is not ideal. However, on Mac the Odd/Even page option does appear in the native Print Dialog, and works, so what's happening there? I'm assuming the application is still painting the full page range but Qt is quietly telling CUPS to only print the odd or even page set. Not optimal if you have a 500 page document to print over a network, but a solution that can be copied into the X11 dialog when it detects CUPS is being used instead of LPR. That gives us a level of backwards compatibility for X11 and OSX, but it’s not very nice and fails completely on Windows.
So here's a high level on how the full solution will work, largely cribbed from KDE3, but taking cross-platform and backwards compatability into account.
QPrinter: A new enum called something like PageRangeControl {SimplePageRange/AdvancedPageRange} which defaults to SimplePageRange, i.e. is the status quo. If set to SimplePageRange then the Print Dialog displays any range modifiers the current Print System supports, the Application generates all pages in the Page Range, and the Print System applies any range modifiers it supports. If set to AdvancedPageRange then the Print Dialog displays all range modifiers, the Application applies all the range modifiers to only generate the required pages, and the Print System does not apply any range modifiers.
QPrinter: A new pageList() method in QPrinter that will return the exact list of pages for the Application to print, taking into account the setting of PageRangeControl and all the possible range modifiers including reverse page order. If SimplePageRange then return a QList of all page numbers between From and To. If AdvancedPageRange set then return only those pages to be printed after applying the range modifiers.
Current Page: App must set the Current Page number via new QPrinter::setCurrentPage() method, then Print Dialog will display Current Page option. Will work seamlessly with both SimplePrintRange and AdvancedPrintRange. Not supported on Mac?
Odd/Even Page Set: If App sets AdvancedPrintRange or the Print System is CUPS (X11 or OSX) then Print Dialog will display Page Set option. Provide setPageSet() and pageSet() methods
Non-Continuous Range: In SimplePrintRange mode then we have two options, either it's unsupported on all systems, or we add support on X11/CUPS only by telling the app to geneate ALL pages in the document and then let CUPS select the pages. In AdvancedPageRange then supported under X11 and Windows but not OSX.
X11: Full support for Odd/Even and Non-Continuous on CUPS, on LPR only if app chooses AdvancedPageRange. Support for Current Page only if app selects.
OSX: In SimplePageRange mode support for Odd/Even as per current. In AdvancedPageRange mode support via Odd/Even via app selection. No support possible for Non-Continuous and Current Page?
Win: Support for Odd/Even, Non-Continuous and Current Page only if app chooses AdvancedPageRange?
Apps: By default will carry on as currently, even if dialog detects print system supports some extra features. If app wants to support extra features or be more efficient, then will set AdvancedPrintRange and use pageList().
Where am I at? I have the basic Current Page and Page Set done on X11, and the Non-Continuous half done.
What’s left to do / What do I need help with?
* Add all PageRangeContol stuff
* X11 dialog to detect if using CUPS and enable SimplePageRange mode for Page Set and Non-Continuous
* Windows - How to add the Current Page, Page Set, and Non-continuous features to the Windows dialog and connect them back to Qt. I haven’t gone looking yet, but I believe these are standard features that the Win API provides calls for? Any Windows print gurus out there
* OSX – Confirmation that OSX cannot have Current Page and Non-Continuous. Where to hack Qt to not pass Page Set to CUPS in AdvancedPageRange mode.
* Git :-) Especially how the Qt build actually works when you have multiple branches on your local clone that inherit from each other, surely there would have to be separate build directories, does Git seamlessly handle switching those too? My idea is to have a series of small branches adding each feature in turn to make review easier, rather than one giant patch set adding everything. My code is currently in svn, so I need to migrate it over and set it up right before publishing it. There's going to be tutorials at Akademy about this sort of stuff, right???
That's a little sketchy in places, but I should have most of it finished for X11 by Akademy, and then the hard OSX/Win part starts.
P.S. Anyone else having problems with the Akademy offical Travel Agency, I put in an accomodation request a week ago and have yet to hear back. Normal, or something to worry about?
P.P.S. Something I've been meaning to point out for ages: the Qt Print Dialog (and every other Qt dialog / app) uses the KDE File Selector when running under KDE. Thanks for this I believe go to Thomas Zander and David Faure back in the 4.1 timeframe.
Comments
Removing pages in QPrinter
Is there any reason QPrinter can't "remove" pages before sending them to CUPS, instead of asking CUPS to do it? (for advanced page ranges, to save on the amount of data sent)
HoTD
Sounds pretty mind-boggling - I think you deserve a Hero of The Day for taking all this on :)
Not sure about Hero, more
Not sure about Hero, more Masochist... If i was a hero I would have had this done for Qt 4.5 :-(
Interesting...
Thats' an interesing idea, I'll have a think about that. The app does tell QPrinter each end of page so it is doable. I'd probably get the basic solution done first and merged upstream, then look at this. Thanks!
No worries
No worries. I think the work on printing is an important addition to KDE4, and I look very much forward to seeing the result of your work. :)
Printing
Sorry, I do rather seem to have abandoned you to the printer work... I didn't actually own a printer until quite recently, so I didn't really have much motivation. But do grab me at Akademy (I'll most likely be hanging around the Amarok or Plasma guys) and I'll at least try to provide some input.
As for accommodation, apparently the travel agency is kind of snowed under at the moment. I sent payment details in the middle of last week and haven't had confirmation yet.
~randomguy3 (a.k.a Alex Merry)
Hi Alex, no worries ate,
Hi Alex, no worries mate, I've been equally guilty, and your plasma hacking looks way more fun :-) Grab me for a beer at some stage.
I've now heard back from the Travel Agency, so all good now, I'm on my way!
http://3freester.com/
The underlying Qt print engine has backends implemented for each platform, so you paint onto QPrinter/QPainter and it then translates that into something the native Print System can print (ps/pdf for CUPS or LPR on X11, pdf for CUPS on OSX, GDI or whatever it’s called on Windows). The visible Print Dialog however is only implemented by Qt for the X11 environment, on Windows and OSX the native OS print dialog is called and the selected values are then passed back into QPrinter to be used by the app.
3freester
Odd/even page selection
I've been pointed to your blog by an LWN comment after some considerations about the state of printing in KDE 4.3. Great to see things moving and thanks for your effort.
I take the occasion to provide a suggestion on a feature that would be extra useful to me.
Given that the printing backend can make some transformations that rearrange pages (think of 2-up or 4-up printing or the "booklet" page reordering that kdeprint was capable of at 3.5) it would be nice to have both:
Usage cases:
Cheers,
Sergio
interesting idea, bookmarked
interesting idea, bookmarked
My husband just got a new
My husband just got a new iMac and downloaded Open Office 3.0. We went to try to print our Christmas letter today and found no "page range" on the print dialogue panel that you get when you click on "Print" in the File menu. Nor could we find a "page range" option anywhere in the Print Preview window.
We were trying to print a two-page letter on a single page (i.e., back-and-front or double-sided). Normally, you would use the print dialogue to specify that you print only page 1-1; then, once the first page is printed, you turn that sheet over and specify printing only page 2-2.
I finally was able to do this by the clunky method of going to "options" and unchecking "left pages" and printing, turning the sheet over, coming back to the options dialogue and unchecking "right pages" and printing.
However, there are often instances when I want to print, say, pages 4-19 of a 50-page document, and I see no way to do that in Open Office 3.0 on Mac OSx. I am able to do it on my own Windows XP using Open Office 3.0.
Can someone suggest a solution?
Candy
-----------------
Top 5 travel destinations in France
breitling tourbillion watches
As the business grows, breitling watches has also jumped into an international brand. It is worth mentioning that,breitling replica is the ancestor of today's brand-oriented, in order to protect the quality and brand name will be printed on their products, the history of fashion in the world, is the first one first.breitling watch, replica breitling, fake breitling,breitling tourbillion watches.
Post new comment