diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java index 027b6a57..010a08c9 100644 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.Vector; +import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -602,7 +603,7 @@ public class FichaWindow extends TabbedWindow { TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR ); String fileName = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) ); - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + SimpleDateFormat sdf = new SimpleDateFormat("_dd-MM-yyyy"); Date date = new Date(); fileName = fileName + sdf.format( date ); fileName = fileName.replace( ' ', '_' ); @@ -632,6 +633,7 @@ public class FichaWindow extends TabbedWindow { Printer.printPDFToFile( pdf, fileName, true ); } + JOptionPane.showConfirmDialog( this, "Ficha exportada para: " + fileName, "Exportar", JOptionPane.OK_OPTION ); } } } diff --git a/trunk/SIPRPSoft/src/siprp/printer/Printer.java b/trunk/SIPRPSoft/src/siprp/printer/Printer.java new file mode 100644 index 00000000..bf6a086c --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/printer/Printer.java @@ -0,0 +1,62 @@ +package siprp.printer; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import siprp.ficha.ExamePDF; +import siprp.ficha.FichaAptidaoCreator; +import siprp.ficha.PDFFilePrinter; + +public class Printer +{ + public static void printFO( byte fo[] ) throws Exception + { + if( fo != null ) + { + byte pdf[] = FichaAptidaoCreator.getCreator().createPDF( fo ); + new PDFFilePrinter( pdf, true ); + } + } + + public static void printPDF( byte[] pdf, String tempFileName, String printerName ) throws Exception + { + ExamePDF ePDF = new ExamePDF(); + ePDF.printSilent( pdf, tempFileName, printerName ); + } + + public static void printFoToFile( byte[] fo, String fileName, boolean deleteIfExists ) throws Exception + { + if( fo != null ) + { + byte pdf[] = FichaAptidaoCreator.getCreator().createPDF( fo ); + printToFile( pdf, fileName, deleteIfExists ); + } + } + + public static void printPDFToFile( byte[] pdf, String fileName, boolean deleteIfExists ) throws Exception + { + if( pdf != null ) + { + printToFile( pdf, fileName, deleteIfExists ); + } + } + + private static void printToFile( byte[] array, String fileName, boolean deleteIfExists ) throws IOException + { + File outFile = new File( fileName ); + if(outFile.exists() && deleteIfExists) + { + outFile.delete(); + } + if( !outFile.exists() ) + { + outFile.createNewFile(); + FileOutputStream fos = new FileOutputStream( outFile ); + fos.write( array ); + fos.close(); + } + } + +}