• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Change the Printer Orientation??

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,..

I have a question and would really appreciate your help.

In the browser when you print, (the default orientation of the printer i am connected to is in Portrait ..) Is there a way using javascript or using any other way i can change the orientation from portrait to landscape, without changing the default orientation in the printer.

In other words default orientation should be portrait, but when anybody prints the web screen from browser, it should always print in landscape.

Is there a way to do this??

Thanks again
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At this current time there is no way of doing it. The next CSS standard is supposed to correct this, but that does not help now. IE has ActiveX controls that can change it, search the net for one.

Eric
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,

Thanks
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use java api..
this is a sample code ...chk it out
//working example

import java.awt.*;
import java.awt.print.*;

public class testPrint implements Printable
{
private static String s[];
private static Font f;
private static int nLines;

public static void main (String arg[])
{
s = new String[10];
f = new Font("Arial", Font.PLAIN, 11);
int i;
s[0] = "This is a printer test";
for (i=1; i<10; i++)
{
s[i] = "The next line";
}
nLines = 10;
testPrint.printa ();
}

public static void printa ()
{
System.out.println("public static void printa () ");
PrinterJob pj=PrinterJob.getPrinterJob();
Book b = new Book();;
PageFormat pf = new PageFormat();
// pf.setOrientation(PageFormat.LANDSCAPE);
pf = pj.defaultPage(pf);
b.append(new testPrint(), pf, 2);
pj.setPageable (b);
try{
if (pj.printDialog()){
pj.print();
}
}
catch (Exception e) { System.out.println ("Error"); }
}
public int print (Graphics g1, PageFormat pf, int n){
System.out.println("public int print");
int x,y,i,fa,fh;
FontMetrics fm;
Graphics2D g = (Graphics2D) g1;
pf.setOrientation(PageFormat.LANDSCAPE);

fm = g.getFontMetrics (f);
fa = fm.getMaxAscent();
fh = fm.getHeight();
x = (int)pf.getImageableX();
y = (int)pf.getImageableY() + fa;

g.setFont (f);
g.setColor(Color.black);
if (n==1){
for (i=0; i<10; i++){
g.drawString (s[i], x, y);
y += fh;
}
return PAGE_EXISTS;
}
else {
for (i=10;i<10; i++){
g.drawString (s[i], x, y);
y += fh;
}
return PAGE_EXISTS;
}
}
}
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does Java in turn work with the browser?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic