forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.0 KiB
87 lines
3.0 KiB
package siprp.higiene.relatorio.print;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.InputStream;
|
|
|
|
import com.evolute.utils.fop.PDFCreator;
|
|
import com.evolute.utils.xml.XSLTransformer;
|
|
|
|
public class TestPrint
|
|
{
|
|
public static void main( String args[] )
|
|
throws Exception
|
|
{
|
|
new TestPrint().test();
|
|
}
|
|
|
|
public void test()
|
|
throws Exception
|
|
{
|
|
// FileOutputStream fos;
|
|
//
|
|
//// PlanoActuacaoDBInit.initDB();
|
|
//// PlanoActuacaoToPrint plano = PlanoActuacaoPrintDataProvider.getProvider().getPlanoToPrint( 6 );
|
|
// Element evoluteElement = new Element( "evolute" );
|
|
// Document foDoc = new Document( evoluteElement );
|
|
// Format pretty = Format.getPrettyFormat();
|
|
// pretty.setIndent("\t");
|
|
// XMLOutputter outputter = new XMLOutputter(pretty);
|
|
// ByteArrayOutputStream foBaos = new ByteArrayOutputStream();
|
|
// outputter.output( foDoc, foBaos );
|
|
//// FileOutputStream fos = new FileOutputStream( "/home/fpalma/Desktop/in.xml" );
|
|
//// fos.write( foBaos.toByteArray() );
|
|
//// fos.close();
|
|
//
|
|
// byte fo[] = applyTemplate(
|
|
//// "siprp/planoactuacao/print/plano_actuacao.xsl",
|
|
//// getClass().getClassLoader().getResourceAsStream( "siprp/higiene/relatorio/relatorio.xsl" ),
|
|
// new FileInputStream( "/home/fpalma/projectos2/SIPRP/SIPRPSoft/src/siprp/higiene/relatorio/print/relatorio.xsl" ),
|
|
//// "siprp/planoactuacao/print/teste_input.xml" );
|
|
// new FileInputStream( "/home/fpalma/projectos2/SIPRP/SIPRPSoft/src/siprp/higiene/relatorio/print/teste_input.xml" ) );
|
|
//// new ByteArrayInputStream( foBaos.toByteArray() ) );
|
|
//// new ByteArrayInputStream( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><plano></plano>".getBytes() ) );
|
|
//// System.out.println( new String( fo ) );
|
|
// System.out.println( new String(fo) );
|
|
// createPDFFile( fo, "/home/fpalma/Desktop/out.pdf" );
|
|
//// createPDFFile( fo, "c:/Documents and Settings/Frederico/Ambiente de Trabalho/out.pdf" );
|
|
//
|
|
// fos = new FileOutputStream( "/home/fpalma/Desktop/out.xml" );
|
|
// fos.write( fo );
|
|
// fos.close();
|
|
|
|
for( int n = 59; n <= 59; n++ )
|
|
{
|
|
byte pdf[] = new RelatorioPDFCreator().createPDF( n );
|
|
FileOutputStream fos = new FileOutputStream( "/home/fpalma/Desktop/" + n + ".pdf" );
|
|
fos.write( pdf );
|
|
fos.close();
|
|
}
|
|
}
|
|
|
|
public void createPDFFile( byte fo[], String path )
|
|
throws Exception
|
|
{
|
|
byte pdf[] = PDFCreator.getPDFCreator().createPdfFromFo( fo );
|
|
FileOutputStream fos = new FileOutputStream( path );
|
|
fos.write( pdf );
|
|
fos.close();
|
|
}
|
|
|
|
public byte[] applyTemplate( String template, String data )
|
|
throws Exception
|
|
{
|
|
InputStream xsl = getClass().getClassLoader().getResourceAsStream( template );
|
|
InputStream xml = getClass().getClassLoader().getResourceAsStream( data );
|
|
return( applyTemplate( xsl, xml ) );
|
|
}
|
|
|
|
public byte[] applyTemplate( InputStream xsl, InputStream dataStream )
|
|
throws Exception
|
|
{
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
XSLTransformer.getXSLTransformer().transform( dataStream, xsl, baos );
|
|
return baos.toByteArray();
|
|
}
|
|
}
|