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 :
 

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

Reply via email to