|
|
|
@ -159,6 +159,53 @@ public class ExamePDF {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void printSilent( byte []pdf, String nome, String printerName )
|
|
|
|
|
|
|
|
throws Exception
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
|
|
|
// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
System.out.println( "Windows" );
|
|
|
|
|
|
|
|
Process proc;
|
|
|
|
|
|
|
|
proc = Runtime.getRuntime().exec( "cmd /c \"md c:" + System.getProperty( "file.separator" ) + "temp\"" );
|
|
|
|
|
|
|
|
proc.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileOutputStream fos = new FileOutputStream( "c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" );
|
|
|
|
|
|
|
|
fos.write( pdf );
|
|
|
|
|
|
|
|
fos.close();
|
|
|
|
|
|
|
|
System.out.println( "File saved." );
|
|
|
|
|
|
|
|
System.out.println("cmd /c \"acrord32.lnk /t c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf " + printerName + "\"");
|
|
|
|
|
|
|
|
proc = Runtime.getRuntime().exec( "cmd /c \"acrord32.lnk /t c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf " + printerName + "\"" );
|
|
|
|
|
|
|
|
// proc = Runtime.getRuntime().exec( "cmd /c \"acrord32.lnk /t " + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf " + printerName + "\"" );
|
|
|
|
|
|
|
|
// proc = Runtime.getRuntime().exec( "cmd /c dir" );
|
|
|
|
|
|
|
|
proc.waitFor();
|
|
|
|
|
|
|
|
if( !new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" ).delete() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
System.err.println( "File: report_ficha" + time + ".pdf - NOT DELETED" );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
System.out.println( "Not Windows" );
|
|
|
|
|
|
|
|
FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" );
|
|
|
|
|
|
|
|
fos.write( pdf );
|
|
|
|
|
|
|
|
fos.close();
|
|
|
|
|
|
|
|
System.out.println( "File saved." );
|
|
|
|
|
|
|
|
Process proc;
|
|
|
|
|
|
|
|
//System.out.println( "/usr/bin/open \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" );
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" } );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// proc = Runtime.getRuntime().exec( "/usr/bin/open \"/Users/Shared/teste.pdf.pdf\"" );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public byte[] createPDF( Hashtable values )
|
|
|
|
public byte[] createPDF( Hashtable values )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Document document = new Document();
|
|
|
|
Document document = new Document();
|
|
|
|
|