no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@218 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 20 years ago
parent eddf03a9e0
commit eb5b0a8ea7

@ -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();

Loading…
Cancel
Save