|  |  | @ -1,14 +1,26 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package siprp.ficha; |  |  |  | package siprp.ficha; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.awt.Color; |  |  |  | import java.awt.Color; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.io.*; |  |  |  | import java.io.ByteArrayOutputStream; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.*; |  |  |  | import java.io.File; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | import java.io.FileOutputStream; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.lowagie.text.*; |  |  |  | import java.util.HashMap; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.lowagie.text.pdf.*; |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | import siprp.SingletonConstants; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.evolute.utils.*; |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import siprp.*; |  |  |  | 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 |  |  |  | public class ExamePDF implements FichaAptidaoConstants | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
	
		
		
			
				
					|  |  | @ -129,6 +141,13 @@ public class ExamePDF implements FichaAptidaoConstants | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public void print( byte []pdf, String nome ) |  |  |  | 	public void print( byte []pdf, String nome ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		throws Exception |  |  |  | 		throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		new PDFFilePrinter( pdf, false ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if( true ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //			return;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		long time = System.currentTimeMillis(); |  |  |  | 		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" ) + "report_ficha" + time + ".pdf" );
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + 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(); |  |  |  | 		ByteArrayOutputStream bos = new ByteArrayOutputStream(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		document.setPageSize( PageSize.A4 ); |  |  |  | 		document.setPageSize( PageSize.A4 ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		try { |  |  |  | 		try { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			PdfWriter pdfw = PdfWriter.getInstance( document, bos ); |  |  |  | 			PdfWriter pdfw = PdfWriter.getInstance( document, bos ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //		try {
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 			document.addTitle( "Ficha de Aptid\u00e3o" ); |  |  |  | 			document.addTitle( "Ficha de Aptid\u00e3o" ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			String acronym = (String) Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM ); |  |  |  | 			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 ) ); |  |  |  | 			table.addCell( new Phrase( 18f, texto.toString(), FONT_NORMAL ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			document.add( table ); |  |  |  | 			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 ) { |  |  |  | 		catch( Exception e ) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			e.printStackTrace(); |  |  |  | 			e.printStackTrace(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 			return null; |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		document.close(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return bos.toByteArray(); |  |  |  | 		return bos.toByteArray(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |