git-svn-id: https://svn.coded.pt/svn/SIPRP@702 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
Tiago Simão 18 years ago
parent b32e3b9ebe
commit 27d251aa54

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

@ -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…
Cancel
Save