package siprp.printer; import java.io.File; 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(); } } }