You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/trunk/SIPRPSoft/src/siprp/printer/Printer.java

62 lines
1.4 KiB

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