You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by BEGUE Pierre <pb...@iftechnologies.net> on 2005/07/26 11:38:53 UTC
method print
Hi thomas,
i want to print my svg file with a pageFormat. So i use a printerJob for
a graphical print.
but i saw in(PrintTranscoder) the function
print(graphics,pageFormat,index) you want a graphics. But how to have a
graphics with the svgFile or the JpegFile
here my code :
/==================================================================/
//declaration variable
final String fichier =
"C:/stage(iftechnologie)/LegeFinal/Lege/sortieFluxfinal.svg";
final String sortie =
"C:/stage(iftechnologie)/LegeFinal/Lege/sortieFluxfinal.jpg";
try{
// Creation d un transcoder input
final String svgURI = new File(fichier).toURL().toString();
final TranscoderInput input = new TranscoderInput(svgURI);
// Creation d un transcoder output
OutputStream ostream = new FileOutputStream(sortie);
final TranscoderOutput output = new TranscoderOutput(ostream);
//methode d impression
//la methode marche par defaut, donc pas de choix de
format,et //pas de surcharge du graphic (printable,printerjob)
final PrintTranscoder fic = new PrintTranscoder();
/******************************/
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
final Document doc = f.createDocument(svgURI);
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat pf0 = printJob.defaultPage();
final PageFormat pf = printJob.pageDialog(pf0);
if (printJob.printDialog())
{
try{
//printJob.print();
SVGGraphics2D graph = new SVGGraphics2D(doc);
// le dialogue d’impression
fic.transcode(input,output);
fic.print((Graphics)graph,pf,0);
}catch(Exception pe){}
}
/==================================================================/
thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: method print
Posted by BEGUE Pierre <pb...@iftechnologies.net>.
sorry excuse me i don't see that you have implement the pageDialog and
the PrinterPage
thanks for all.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: method print
Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Pierre,
BEGUE Pierre wrote:
> i want to print my svg file with a pageFormat. So i use a printerJob for
> a graphical print.
I don't think I really follow what you want to do. You might want
to check out the KEY_SHOW_PAGE_DIALOG, and KEY_SHOW_PRINTER_DIALOG
hints which should do what you are doing with the PageFormat.
> but i saw in(PrintTranscoder) the function
> print(graphics,pageFormat,index) you want a graphics. But how to have a
> graphics with the svgFile or the JpegFile
I don't understand what you are asking here...
>
> here my code :
>
> /==================================================================/
> //declaration variable
> final String fichier =
> "C:/stage(iftechnologie)/LegeFinal/Lege/sortieFluxfinal.svg";
>
> final String sortie =
> "C:/stage(iftechnologie)/LegeFinal/Lege/sortieFluxfinal.jpg";
>
> try{
> // Creation d un transcoder input
> final String svgURI = new File(fichier).toURL().toString();
> final TranscoderInput input = new TranscoderInput(svgURI);
>
> // Creation d un transcoder output
> OutputStream ostream = new FileOutputStream(sortie);
> final TranscoderOutput output = new TranscoderOutput(ostream);
>
> //methode d impression
> //la methode marche par defaut, donc pas de choix de
> format,et //pas de surcharge du graphic (printable,printerjob)
>
> final PrintTranscoder fic = new PrintTranscoder();
>
>
> /******************************/
> String parser = XMLResourceDescriptor.getXMLParserClassName();
> SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
> final Document doc = f.createDocument(svgURI);
>
>
> PrinterJob printJob = PrinterJob.getPrinterJob();
> PageFormat pf0 = printJob.defaultPage();
> final PageFormat pf = printJob.pageDialog(pf0);
> if (printJob.printDialog())
> {
> try{
> //printJob.print();
> SVGGraphics2D graph = new SVGGraphics2D(doc);
> // le dialogue d’impression
> fic.transcode(input,output);
> fic.print((Graphics)graph,pf,0);
>
>
> }catch(Exception pe){}
> }
>
> /==================================================================/
>
> thanks.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org