forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@702 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
b32e3b9ebe
commit
27d251aa54
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue