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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 18 years ago
parent bdaeb6322e
commit 912a3887f1

Binary file not shown.

@ -1,14 +1,26 @@
package siprp.ficha;
import java.awt.Color;
import java.io.*;
import java.util.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.evolute.utils.*;
import siprp.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import siprp.SingletonConstants;
import com.evolute.utils.Singleton;
import com.lowagie.text.Cell;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
public class ExamePDF implements FichaAptidaoConstants
{
@ -129,6 +141,13 @@ public class ExamePDF implements FichaAptidaoConstants
public void print( byte []pdf, String nome )
throws Exception
{
new PDFFilePrinter( pdf, false );
if( true )
{
// return;
}
long time = System.currentTimeMillis();
// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" );
@ -206,9 +225,10 @@ public class ExamePDF implements FichaAptidaoConstants
ByteArrayOutputStream bos = new ByteArrayOutputStream();
document.setPageSize( PageSize.A4 );
try {
PdfWriter pdfw = PdfWriter.getInstance( document, bos );
// try {
document.addTitle( "Ficha de Aptid\u00e3o" );
String acronym = (String) Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM );
@ -432,13 +452,51 @@ public class ExamePDF implements FichaAptidaoConstants
table.addCell( new Phrase( 18f, texto.toString(), FONT_NORMAL ) );
document.add( table );
// }
// catch( Exception e ) {
// e.printStackTrace();
// return null;
// }
document.close();
// PdfWriter pdfw = PdfWriter.getInstance( document, bos );
// PdfContentByte pdfcb = new PdfContentByte( pdfw );
//
// PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
// // Step 2: Obtain a print job.
// PrinterJob pj = PrinterJob.getPrinterJob();
// Graphics2D graphics = pdfcb.createPrinterGraphics( 100.0F, 100.0F, pj );
// // Step 3: Find print services.
// PrintService []services = PrinterJob.lookupPrintServices();
// PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
// if(services.length > 0)
// {
// System.out.println("selected printer: " + services[0]);
// try
// {
// PrintService service = defaultService;
//// PrintService service = ServiceUI.printDialog(null, 200, 200,
//// services, defaultService, DocFlavor.SERVICE_FORMATTED.PAGEABLE, aset);
// pj.setPrintService(service);
// // Step 2: Pass the settings to a page dialog and print dialog.
//// pj.pageDialog(aset);
//// if (pj.printDialog(aset))
//// {
// // Step 4: Update the settings made by the user in the dialogs.
// // Step 5: Pass the final settings into the print request.
// pj.print(aset);
//// }
// }
// catch (PrinterException pe ) {
// System.err.println(pe);
// }
// }
}
catch( Exception e ) {
e.printStackTrace();
return null;
}
document.close();
return bos.toByteArray();
}

Loading…
Cancel
Save