From eb5b0a8ea71032ad5f34cd47e3c99be5f8bd800e Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Mon, 20 Feb 2006 01:36:25 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@218 bb69d46d-e84e-40c8-a05a-06db0d633741 --- trunk/siprp/ficha/ExamePDF.java | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/trunk/siprp/ficha/ExamePDF.java b/trunk/siprp/ficha/ExamePDF.java index dfd15d77..35f29006 100644 --- a/trunk/siprp/ficha/ExamePDF.java +++ b/trunk/siprp/ficha/ExamePDF.java @@ -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 ) { Document document = new Document();