List of usage examples for com.itextpdf.text Element ALIGN_JUSTIFIED
int ALIGN_JUSTIFIED
To view the source code for com.itextpdf.text Element ALIGN_JUSTIFIED.
Click Source Link
From source file:view.RelatorioSalaView.java
public void gerarDocumento() throws FileNotFoundException { try {/*w ww . j a v a 2 s . c om*/ int numeroSala = Integer.parseInt(tbeSala.getValueAt(tbeSala.getSelectedRow(), 0).toString()); listaPatrimonio = patrimonioDAO.listaTodosSala(numeroSala); doc = new Document(PageSize.A4, 41.5f, 41.5f, 55.2f, 55.2f); String caminho = "C:/Relatorios Sala/Relatorio " + tbeSala.getValueAt(tbeSala.getSelectedRow(), 1).toString() + ".pdf"; PdfWriter.getInstance(doc, new FileOutputStream(caminho)); doc.open(); Font f1 = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD); Font f2 = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); Font f3 = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); Font f4 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD); Font f5 = new Font(Font.FontFamily.HELVETICA, 10, Font.NORMAL); Paragraph titulo1 = new Paragraph("Universidade do Estado de Minas Gerais", f2); titulo1.setAlignment(Element.ALIGN_CENTER); titulo1.setSpacingAfter(10); Paragraph titulo2 = new Paragraph("" + tbeSala.getValueAt(tbeSala.getSelectedRow(), 1).toString(), f2); titulo2.setAlignment(Element.ALIGN_CENTER); titulo2.setSpacingAfter(10); doc.add(titulo1); doc.add(titulo2); PdfPTable tabela = new PdfPTable(new float[] { 0.20f, 0.80f, 0.18f, 0.42f }); tabela.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.setWidthPercentage(100f); PdfPCell cabecalho1 = new PdfPCell(new Paragraph("Codigo", f3)); cabecalho1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cabecalho1.setBorder(0); PdfPCell cabecalho2 = new PdfPCell(new Paragraph("Descrio", f3)); cabecalho2.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cabecalho2.setBorder(0); PdfPCell cabecalho3 = new PdfPCell(new Paragraph("Estado", f3)); cabecalho3.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cabecalho3.setBorder(0); PdfPCell cabecalho4 = new PdfPCell(new Paragraph("Orgo", f3)); cabecalho4.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cabecalho4.setBorder(0); tabela.addCell(cabecalho1); tabela.addCell(cabecalho2); tabela.addCell(cabecalho3); tabela.addCell(cabecalho4); for (PatrimonioM patrimonio : listaPatrimonio) { if (patrimonio.getKit()) { listaComposto = patri.listaTodosExistentes(patrimonio); for (PatrimonioCompostoM composto : listaComposto) { Paragraph p1 = new Paragraph(patrimonio.getCodigo(), f5); p1.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col1 = new PdfPCell(p1); col1.setBorder(0); Paragraph p2 = new Paragraph(composto.getDescricao(), f5); p2.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col2 = new PdfPCell(p2); col2.setBorder(0); Paragraph p3 = new Paragraph(composto.getGrau().getDescricao(), f5); p3.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col3 = new PdfPCell(p3); col3.setBorder(0); Paragraph p4 = new Paragraph(patrimonio.getEntidade().getNome(), f5); p4.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col4 = new PdfPCell(p4); col4.setBorder(0); tabela.addCell(col1); tabela.addCell(col2); tabela.addCell(col3); tabela.addCell(col4); } } else { Paragraph p1 = new Paragraph(patrimonio.getCodigo(), f5); p1.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col1 = new PdfPCell(p1); col1.setBorder(0); Paragraph p2 = new Paragraph(patrimonio.getDescricao(), f5); p2.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col2 = new PdfPCell(p2); col2.setBorder(0); Paragraph p3 = new Paragraph(patrimonio.getGrau_conservacao().getDescricao(), f5); p3.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col3 = new PdfPCell(p3); col3.setBorder(0); Paragraph p4 = new Paragraph(patrimonio.getEntidade().getNome(), f5); p4.setAlignment(Element.ALIGN_JUSTIFIED); PdfPCell col4 = new PdfPCell(p4); col4.setBorder(0); tabela.addCell(col1); tabela.addCell(col2); tabela.addCell(col3); tabela.addCell(col4); } } doc.add(tabela); doc.close(); JOptionPane.showMessageDialog(null, "Relatrio salvo com sucesso em C:/Relatorios Sala/"); Desktop.getDesktop().open(new File(caminho)); } catch (DocumentException e) { e.printStackTrace(); } catch (SQLException ex) { ex.printStackTrace(); } catch (IOException exx) { exx.printStackTrace(); JOptionPane.showMessageDialog(null, "Documento de Relatorios aberto. Feche para gerar um novo."); } }
From source file:WeeklyReport.Sections.RegionalQuoteData.java
public PdfPTable regionalAnalysis() { PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.setWidthPercentage(100f);/*from ww w.jav a 2 s .c om*/ table.setSpacingBefore(10f); cell = new PdfPCell(new Phrase("Regional Quote Data", SECTION_HEADING)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(Rectangle.BOTTOM); cell.setBorderWidthBottom(2f); cell.setPaddingBottom(10f); table.addCell(cell); String pending = null; if (PENDING_RESPONSE == 1) { pending = PENDING_RESPONSE + " is pending further action."; } else { pending = PENDING_RESPONSE + " are pending further action."; } cell = new PdfPCell(new Phrase("In week " + new ReportingDates().reportPeriod() + " a total of " + new CustomerQuoteData().totalNAQuotes() + " quotes were generated through RQS to North American customers (not including Canada). Of these quotes there were " + DECLINES + " declines, " + BOOKINGS + " bookings, and " + FEEDBACK + " received customer feedback, and " + pending, TEXT_FONT)); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); return table; }