Ben Ward wrote:
My web application run on a websphere server, and when a client press the print button to print my svg calendar, it show the print dialog on the server side and the client can't choose the paper size and the printer. I use the code below :

Hi Ben,


   Yes...  What do you want it to do?
   Do you want to bypass the window? Do you want to 'forward'
the dialog to the client?

   Either way you need to use the JDK's printing API's and
you won't be able to use our PrintTranscoder "out of the Box"
(although much of the code will remain similar).

   There are ways to automatically select the paper/printer
in the JDK 1.4 Print API's.  Similarly the JDK 1.4 print API's
provide mechanisms to query printer capabilities which you
can then reformat somehow for the user (Html, Applet, I don't know),
and then use the response to 'bypass' the window respecting
the users request.

   Anyway at this point it is not really a Batik question it is a
Java printing question, which will be better answered on Java2D.

Writer out = null ;

boolean useCSS = false ;

try {

Element roots[] = new Element[page.getNombrePage()+1];

for ( int i = 0 ; i <= page.getNombrePage();i++){

svgGenerator[i].setSVGCanvasSize( new Dimension( ( int )page.getWithSansReamarqueTravaux() >= 250 ? ( int )page.getWithSansReamarqueTravaux() : 250 , Integer.parseInt(page.getSautPage().get(i)+ "" ) ));

roots[i] = svgGenerator[i].getRoot();

}

TranscoderInput inputs[] = new TranscoderInput[page.getNombrePage()+1];

TranscoderOutput transout = new TranscoderOutput();

PrintTranscoder p = new PrintTranscoder();

java.io.ByteArrayOutputStream outBuff[] = new ByteArrayOutputStream[page.getNombrePage()+1];

java.io.ByteArrayInputStream inBuff[] = new ByteArrayInputStream[page.getNombrePage()+1];

for ( int i = 0 ; i <= (page.getNombrePage());i++){

outBuff[i] = new ByteArrayOutputStream();

roots[i].setAttribute( "viewBox" , "0 0 " + (( int )page.getWithSansReamarqueTravaux() >= 250 ? ( int )page.getWithSansReamarqueTravaux()+page.MARGE : 250 )+ " " +page.getSautPage().get(i) );

out = new OutputStreamWriter(outBuff[i] , "iso-8859-1" );

svgGenerator[i].stream(roots[i],out,useCSS);

//debug mode only

out = new OutputStreamWriter( new FileOutputStream( new File( "C:/WINNT/Temp/svg" +i+ ".svg" )) , "iso-8859-1" );

svgGenerator[i].stream(roots[i],out,useCSS);

inBuff[i] = new ByteArrayInputStream(outBuff[i].toByteArray());

}



for ( int i = 0 ; i <= page.getNombrePage();i++){

inputs[i] = new TranscoderInput(inBuff[i]);

p.transcode(inputs[i], transout);

}

//dialog

org.apache.batik.transcoder.keys.LengthKey a = new org.apache.batik.transcoder.keys.LengthKey();

p.addTranscodingHint(p.KEY_PAGE_ORIENTATION,page.orientation);

p.addTranscodingHint(p.KEY_SHOW_PAGE_DIALOG,Boolean.TRUE);

p.addTranscodingHint(p.KEY_SCALE_TO_PAGE,Boolean.TRUE);

p.addTranscodingHint(p.KEY_SHOW_PRINTER_DIALOG,Boolean.TRUE);

p.print();

} catch (PrinterException be){

be.printStackTrace();

} catch (Exception e){

e.printStackTrace();

}

need help quick please.

thanks


Post your free ad now! *Yahoo! Canada Personals* <http://ca.personals.yahoo.com/>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to