|  |  | @ -2,7 +2,10 @@ package pdf; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.io.ByteArrayInputStream; |  |  |  | import java.io.ByteArrayInputStream; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.io.ByteArrayOutputStream; |  |  |  | import java.io.ByteArrayOutputStream; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.io.File; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.io.FileOutputStream; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.io.InputStream; |  |  |  | import java.io.InputStream; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.net.URL; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.sql.Time; |  |  |  | import java.sql.Time; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Calendar; |  |  |  | import java.util.Calendar; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Date; |  |  |  | import java.util.Date; | 
			
		
	
	
		
		
			
				
					|  |  | @ -35,6 +38,30 @@ public class PdfGenerator | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected final Recomendacao recomendacoes[]; |  |  |  | 	protected final Recomendacao recomendacoes[]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected final Medida medidas[]; |  |  |  | 	protected final Medida medidas[]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected final Causa causa; |  |  |  | 	protected final Causa causa; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	protected final URL urlSiprp; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	protected final URL urlAuchan; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	public static void main( String args[] ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		byte[] pdf = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			new PdfGenerator( "",  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Estabelecimento(), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Utilizador(), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Utilizador(), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new AnaliseAcidente(),  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Acidentado(), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Seccao(), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Recomendacao[ 0 ], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Medida[ 0 ], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Causa() ).generatePdf(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		File pdfFile = new File( "/home/fpalma/Desktop/siprp.pdf" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		pdfFile.createNewFile(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		FileOutputStream fos = new FileOutputStream( pdfFile ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		fos.write( pdf ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		fos.close(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		System.out.println( "DONE" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public PdfGenerator(  |  |  |  | 	public PdfGenerator(  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			String imagePath,  |  |  |  | 			String imagePath,  | 
			
		
	
	
		
		
			
				
					|  |  | @ -58,6 +85,8 @@ public class PdfGenerator | 
			
		
	
		
		
			
				
					
					|  |  |  | 		this.recomendacoes = recomendacoes; |  |  |  | 		this.recomendacoes = recomendacoes; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		this.medidas = medidas; |  |  |  | 		this.medidas = medidas; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		this.causa = causa; |  |  |  | 		this.causa = causa; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		this.urlSiprp = getClass().getResource( "siprp_logo.gif" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		this.urlAuchan = getClass().getResource( "auchan_logo.gif" ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public byte[] generatePdf() |  |  |  | 	public byte[] generatePdf() | 
			
		
	
	
		
		
			
				
					|  |  | @ -76,6 +105,12 @@ public class PdfGenerator | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected Element createXml() |  |  |  | 	protected Element createXml() | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		Element rootElement = new Element( "AnaliseAcidente" ); |  |  |  | 		Element rootElement = new Element( "AnaliseAcidente" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Element logoTipoSIPRPElement = new Element( "LogotipoSIPRP" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		logoTipoSIPRPElement.setText( urlSiprp.toString() ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		rootElement.addContent( logoTipoSIPRPElement ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Element logoTipoAuchanElement = new Element( "LogotipoAuchan" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		logoTipoAuchanElement.setText( urlAuchan.toString() ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		rootElement.addContent( logoTipoAuchanElement ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		Element numeroElement = new Element( "Numero" ); |  |  |  | 		Element numeroElement = new Element( "Numero" ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		numeroElement.setText( analiseAcidente.getAnalise_nr() ); |  |  |  | 		numeroElement.setText( analiseAcidente.getAnalise_nr() ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		rootElement.addContent( numeroElement ); |  |  |  | 		rootElement.addContent( numeroElement ); | 
			
		
	
	
		
		
			
				
					|  |  | 
 |