• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Force Landscape Printing

 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a printjob set up that is working with one problem.

While the layout is landscape the target printer orientation is portrait by default. The user has to remember to switch it to landscape. Short of generating a reminder message during the print dialog, is there not a way to force the print driver to use landscape rather than the default? TIA.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not an area I'm particularly experienced in so the following advice may or may not be useful.
Have you tried using the printDialog(PrintRequestAttributeSet attribs) method adding the OrientationRequested.LANDSCAPE attribute to the attribute set?
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. I have not since I was not aware of it. I'll have to read up on it.
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not having much success getting what I need. I was successful in implementing PageRequestAttributeSet. The page setup pops up with landscape selected, although I don't know why I need that since it is now selected. However, that does not help since the print services apparently ignore that. I then tried using PrintService and created a combobox so the user can select the printer in my application. Again that all works and the correct printer is selected when the print dialog comes up. Unfortunately the orientation is still the default rather than landscape. I now have 2 issues to over come. The first is to eliminate the page setup popup which is not needed even if it worked. The second is to set landscape orientation. FWIW, here is the new print class:

This is how I get the selected printer service:
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It may be that your printer ignores the orientation setting. If you get the PrintService object it has some methods for querying if the printer supports certain attributes and values. It may be worth checking to see if your print does support this although I would be surprised if any printer that can print landscape does not support the setting.
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks and I agree that it is unlikely since I have several different printers and all (mis)behave the same.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that makes it even more unlikely then.

I think I may have spotted your error, when you call setPrintable() I think you may need to pass the required page format to it as a second parameter, as follows:
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bingo!!! That was it. However, I am still getting the print dialog which I neither need nor want. That only started happening when I added the PrintRequestAttributeSet code. Is there a way to eliminate it?
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never mind. I got it. The call to pageDialog() was not necessary.
 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to achieve this without using the Printable interface? Have been stuck on this for a while.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic