diff --git a/trunk/siprp/ficha/ExamePDF.java b/trunk/siprp/ficha/ExamePDF.java index 1085615c..a55ab132 100644 --- a/trunk/siprp/ficha/ExamePDF.java +++ b/trunk/siprp/ficha/ExamePDF.java @@ -128,8 +128,8 @@ public class ExamePDF { public void print( byte []pdf ) throws Exception { - - FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf" ); + long time = System.currentTimeMillis(); + FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" ); fos.write( pdf ); fos.close(); System.out.println( "File saved." ); @@ -137,15 +137,18 @@ public class ExamePDF { if( System.getProperty( "os.name" ).startsWith( "Windows" ) ) { //System.out.println( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" ); - proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" ); + proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf\"" ); proc.waitFor(); - new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf" ).delete(); + if( !new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" ).delete() ) + { + System.err.println( "File: report_ficha" + time + ".pdf - NOT DELETED" ); + } } else { //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" ) + "report_ficha.pdf" } ); + proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" } ); } catch( Exception ex ) {