List of usage examples for com.itextpdf.text.pdf PdfPCell setPadding
public void setPadding(float padding)
From source file:jdbreport.model.io.pdf.itext5.PdfWriter.java
License:Apache License
private PdfPCell writeCell(ReportModel model, jdbreport.model.Cell srcCell, int row, int col) throws BadElementException, IOException, SaveReportException { CellStyle style = model.getStyles(srcCell.getStyleId()); java.awt.Rectangle rect = model.getCellRect(row, col, true, true); float h = (float) Units.PT.setYPixels((int) rect.getHeight()); float w = (float) Units.PT.setXPixels((int) rect.getWidth()); PdfPCell pdfCell; if (srcCell.getPicture() != null) { Icon icon = srcCell.getPicture().getIcon(); java.awt.Image awtImage = ((ImageIcon) icon).getImage(); com.itextpdf.text.Image image = awtImageToImage(awtImage, srcCell, w, h); pdfCell = new PdfPCell(image); } else {/*from w ww . j a v a2 s. c o m*/ pdfCell = new PdfPCell(); String text = null; if (srcCell.getValue() instanceof CellValue<?>) { StringWriter strWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(strWriter); if (!((CellValue<?>) srcCell.getValue()).write(printWriter, model, row, col, this, ReportBook.PDF)) { java.awt.Image awtImage = ((CellValue<?>) srcCell.getValue()).getAsImage(model, row, col); if (awtImage != null) { com.itextpdf.text.Image image = awtImageToImage(awtImage, srcCell, w, h); pdfCell.setImage(image); } } else { text = strWriter.getBuffer().toString(); } } else { if (jdbreport.model.Cell.TEXT_HTML.equals(srcCell.getContentType())) { writeHTMLText(model.getStyles(srcCell.getStyleId()), srcCell, pdfCell); } else { text = model.getCellText(srcCell); } } if (text != null && text.length() > 0) { com.itextpdf.text.Font font; if (fonts.containsKey(style.getId())) { font = fonts.get(style.getId()); } else { font = getFontMapper().styleToPdf(style); fonts.put(style.getId(), font); } Paragraph p; if (font != null) { p = new Paragraph(text, font); } else { p = new Paragraph(text); } pdfCell.setPhrase(p); } } pdfCell.setFixedHeight(h); pdfCell.setPadding(1); pdfCell.setBackgroundColor(new BaseColor(style.getBackground().getRGB())); pdfCell.setHorizontalAlignment(toPdfHAlignment(style.getHorizontalAlignment())); pdfCell.setVerticalAlignment(toPdfVAlignment(style.getVerticalAlignment())); if (style.getAngle() != 0) { pdfCell.setRotation(roundAngle(style.getAngle())); } assignBorders(style, pdfCell); pdfCell.setNoWrap(!style.isWrapLine()); if (srcCell.getColSpan() > 0) { pdfCell.setColspan(srcCell.getColSpan() + 1); } if (srcCell.getRowSpan() > 0) { pdfCell.setRowspan(srcCell.getRowSpan() + 1); } return pdfCell; }
From source file:ManagementPackage.ServiceEnd.java
private void txtDoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDoneActionPerformed // TODO add your handling code here: Document doc = new Document(); try {/*from w ww .j a va 2s . co m*/ long time = new Date().getTime(); TransNo = "" + time; PdfWriter.getInstance(doc, new FileOutputStream("Invoices\\Invoices" + time + ".pdf")); doc.open(); PdfPTable table = new PdfPTable(4); PdfPCell cell1 = new PdfPCell(new Paragraph("Shop Management System \n\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.WHITE))); cell1.setColspan(10); cell1.setPadding(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setBackgroundColor(BaseColor.BLACK); table.addCell(cell1); PdfPCell cell21 = new PdfPCell(new Paragraph("\n\n")); cell21.setColspan(10); cell21.setBorder(2); cell21.setBorderColorLeft(BaseColor.WHITE); table.addCell(cell21); PdfPCell cell2 = new PdfPCell(new Paragraph("Invoice/Money Receipt\n")); cell2.setColspan(10); cell2.setPadding(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell2); PdfPCell cell3 = new PdfPCell(new Paragraph("Transaction No: " + time, FontFactory.getFont(null, 10))); cell3.setColspan(2); cell3.setPaddingBottom(10); cell3.setPaddingTop(10); cell3.setBorder(2); cell3.setBorderColorLeft(BaseColor.WHITE); table.addCell(cell3); PdfPCell cell4 = new PdfPCell( new Paragraph("Date: " + formatedDateTime, FontFactory.getFont(null, 10))); cell4.setColspan(3); cell4.setPaddingBottom(10); cell4.setPaddingTop(10); cell4.setBorder(2); cell4.setHorizontalAlignment(Element.ALIGN_RIGHT); cell4.setBorderColorRight(BaseColor.WHITE); table.addCell(cell4); //table.addCell("Sl No"); table.addCell("Product Name"); table.addCell("Rate"); table.addCell("Qty"); table.addCell("Amount (TK)"); String query = "select product_name, rate, qty, amount from temp_trans WHERE trans_by = '" + user + "'"; try { pst = con.prepareStatement(query); rs = pst.executeQuery(); while (rs.next()) { //String sl_no = rs.getString("sl_no"); String product_name = rs.getString("product_name"); String rate = rs.getString("rate"); String qty = rs.getString("qty"); String amount = rs.getString("amount"); //table.addCell(sl_no); table.addCell(product_name); table.addCell(rate); table.addCell(qty); PdfPCell cellAmount = new PdfPCell(new Paragraph(amount)); cellAmount.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellAmount); } rs.close(); pst.close(); } catch (SQLException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell cellb = new PdfPCell(new Paragraph(" ")); cellb.setColspan(10); cellb.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellb); // PdfPCell celltxtTotal = new PdfPCell(new Paragraph("Total")); celltxtTotal.setColspan(3); celltxtTotal.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal); PdfPCell celltxtTotal1 = new PdfPCell(new Paragraph(txtTotal.getText())); celltxtTotal1.setColspan(2); celltxtTotal1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal1); PdfPCell celltxtAdjust = new PdfPCell(new Paragraph("Adjustment")); celltxtAdjust.setColspan(3); celltxtAdjust.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust); PdfPCell celltxtAdjust1 = new PdfPCell(new Paragraph(txtAdjust.getText())); celltxtAdjust1.setColspan(2); celltxtAdjust1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust1); PdfPCell celltxtTotalPaid = new PdfPCell(new Paragraph("Billed By: " + user)); celltxtTotalPaid.setColspan(2); //celltxtTotalPaid.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid); PdfPCell celltxtTotalPaid0 = new PdfPCell(new Paragraph("Total Paid")); celltxtTotalPaid0.setColspan(1); celltxtTotalPaid0.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid0); PdfPCell celltxtTotalPaid1 = new PdfPCell(new Paragraph(txtTotalPaid.getText())); celltxtTotalPaid1.setColspan(2); celltxtTotalPaid1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid1); doc.add(table); doc.close(); savePermanently(); clearTempTable(); //JOptionPane.showMessageDialog(null, "Report Created!"); // open PDF file File file = new File("Invoices\\Invoices" + time + ".pdf"); if (file.toString().endsWith(".pdf")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file); else { Desktop desktop = Desktop.getDesktop(); desktop.open(file); } } catch (DocumentException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ManagementPackage.Setting.java
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed // TODO add your handling code here: totalAdjustment = 0;// w ww. j a v a 2 s.c o m totalTotalPaid = 0; total = 0; Document doc = new Document(); try { long time = new Date().getTime(); PdfWriter.getInstance(doc, new FileOutputStream("Reports\\Daily" + time + " " + formatedDate + ".pdf")); doc.open(); PdfPTable table = new PdfPTable(5); PdfPCell cell1 = new PdfPCell(new Paragraph("Shop Management System \n\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.WHITE))); cell1.setColspan(10); cell1.setPadding(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setBackgroundColor(BaseColor.BLACK); table.addCell(cell1); PdfPCell cell21 = new PdfPCell(new Paragraph("\n\n")); cell21.setColspan(10); cell21.setBorder(2); cell21.setBorderColorLeft(BaseColor.WHITE); table.addCell(cell21); PdfPCell cell2 = new PdfPCell(new Paragraph("Daily Report\n")); cell2.setColspan(10); cell2.setPadding(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell2); PdfPCell cell4 = new PdfPCell(new Paragraph("Date: " + formatedDateTime)); cell4.setColspan(10); cell4.setPaddingBottom(10); cell4.setPaddingTop(10); cell4.setBorder(2); cell4.setHorizontalAlignment(Element.ALIGN_RIGHT); cell4.setBorderColorRight(BaseColor.WHITE); table.addCell(cell4); table.addCell("Transaction No"); table.addCell("Billed By"); table.addCell("Product Name"); table.addCell("Qty"); table.addCell("Amount (TK)"); String PrevTransNo = " "; String query = "select trans_no, product_name, qty, amount, trans_by from trans_details where date = '" + formatedDate + "'"; try { pst = con.prepareStatement(query); rs = pst.executeQuery(); while (rs.next()) { String NewTransNo = rs.getString("trans_no"); String product_name = rs.getString("product_name"); String qty = rs.getString("qty"); String amount = rs.getString("amount"); String trans_by = rs.getString("trans_by"); total = total + Float.parseFloat(amount); if (PrevTransNo.equals(NewTransNo)) table.addCell(" "); else { table.addCell(NewTransNo); String query1 = "select adjustment, total_paid from paid_amount where trans_no = '" + NewTransNo + "'"; pst1 = con1.prepareStatement(query1); rs1 = pst1.executeQuery(); String adjustment = rs1.getString("adjustment"); String total_paid = rs1.getString("total_paid"); totalAdjustment = totalAdjustment + Float.parseFloat(adjustment); totalTotalPaid = totalTotalPaid + Float.parseFloat(total_paid); rs1.close(); pst1.close(); } PrevTransNo = rs.getString("trans_no"); table.addCell(trans_by); table.addCell(product_name); table.addCell(qty); PdfPCell cellAmount = new PdfPCell(new Paragraph(amount)); cellAmount.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellAmount); } rs.close(); pst.close(); } catch (SQLException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell cellb = new PdfPCell(new Paragraph(" ")); cellb.setColspan(10); cellb.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellb); // PdfPCell celltxtTotal = new PdfPCell(new Paragraph("Total")); celltxtTotal.setColspan(3); celltxtTotal.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal); PdfPCell celltxtTotal1 = new PdfPCell(new Paragraph("" + total)); celltxtTotal1.setColspan(2); celltxtTotal1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal1); PdfPCell celltxtAdjust = new PdfPCell(new Paragraph("Adjustment")); celltxtAdjust.setColspan(3); celltxtAdjust.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust); PdfPCell celltxtAdjust1 = new PdfPCell(new Paragraph("" + totalAdjustment)); celltxtAdjust1.setColspan(2); celltxtAdjust1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust1); PdfPCell celltxtTotalPaid = new PdfPCell(new Paragraph("Total Paid")); celltxtTotalPaid.setColspan(3); celltxtTotalPaid.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid); PdfPCell celltxtTotalPaid1 = new PdfPCell(new Paragraph("" + totalTotalPaid)); celltxtTotalPaid1.setColspan(2); celltxtTotalPaid1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid1); doc.add(table); doc.close(); //JOptionPane.showMessageDialog(null, "Report Created!"); // open PDF file File file = new File("Reports\\Daily" + time + " " + formatedDate + ".pdf"); if (file.toString().endsWith(".pdf")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file); else { Desktop desktop = Desktop.getDesktop(); desktop.open(file); } } catch (DocumentException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ManagementPackage.Setting.java
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed // TODO add your handling code here: totalAdjustment = 0;//from w w w . j a v a 2 s . co m totalTotalPaid = 0; total = 0; Document doc = new Document(); try { long time = new Date().getTime(); PdfWriter.getInstance(doc, new FileOutputStream("Reports\\Monthly" + time + " " + formatedDate + ".pdf")); doc.open(); PdfPTable table = new PdfPTable(5); PdfPCell cell1 = new PdfPCell(new Paragraph("Shop Management System \n\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.WHITE))); cell1.setColspan(10); cell1.setPadding(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setBackgroundColor(BaseColor.BLACK); table.addCell(cell1); PdfPCell cell21 = new PdfPCell(new Paragraph("\n\n")); cell21.setColspan(10); cell21.setBorder(2); cell21.setBorderColorLeft(BaseColor.WHITE); table.addCell(cell21); PdfPCell cell2 = new PdfPCell(new Paragraph("Monthly Report\n")); cell2.setColspan(10); cell2.setPadding(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell2); PdfPCell cell4 = new PdfPCell(new Paragraph("Date: " + formatedDateTime)); cell4.setColspan(10); cell4.setPaddingBottom(10); cell4.setPaddingTop(10); cell4.setBorder(2); cell4.setHorizontalAlignment(Element.ALIGN_RIGHT); cell4.setBorderColorRight(BaseColor.WHITE); table.addCell(cell4); table.addCell("Transaction No"); table.addCell("Billed By"); table.addCell("Product Name"); table.addCell("Qty"); table.addCell("Amount (TK)"); String PrevTransNo = " "; String query = "select trans_no, product_name, qty, amount, trans_by from trans_details where date like '%" + month + "%'"; try { pst = con.prepareStatement(query); rs = pst.executeQuery(); while (rs.next()) { String NewTransNo = rs.getString("trans_no"); String product_name = rs.getString("product_name"); String qty = rs.getString("qty"); String amount = rs.getString("amount"); String trans_by = rs.getString("trans_by"); total = total + Float.parseFloat(amount); if (PrevTransNo.equals(NewTransNo)) table.addCell(" "); else { table.addCell(NewTransNo); String query1 = "select adjustment, total_paid from paid_amount where trans_no = '" + NewTransNo + "'"; pst1 = con1.prepareStatement(query1); rs1 = pst1.executeQuery(); String adjustment = rs1.getString("adjustment"); String total_paid = rs1.getString("total_paid"); totalAdjustment = totalAdjustment + Float.parseFloat(adjustment); totalTotalPaid = totalTotalPaid + Float.parseFloat(total_paid); rs1.close(); pst1.close(); } PrevTransNo = rs.getString("trans_no"); table.addCell(trans_by); table.addCell(product_name); table.addCell(qty); PdfPCell cellAmount = new PdfPCell(new Paragraph(amount)); cellAmount.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellAmount); } rs.close(); pst.close(); } catch (SQLException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell cellb = new PdfPCell(new Paragraph(" ")); cellb.setColspan(10); cellb.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellb); // PdfPCell celltxtTotal = new PdfPCell(new Paragraph("Total")); celltxtTotal.setColspan(3); celltxtTotal.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal); PdfPCell celltxtTotal1 = new PdfPCell(new Paragraph("" + total)); celltxtTotal1.setColspan(2); celltxtTotal1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal1); PdfPCell celltxtAdjust = new PdfPCell(new Paragraph("Adjustment")); celltxtAdjust.setColspan(3); celltxtAdjust.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust); PdfPCell celltxtAdjust1 = new PdfPCell(new Paragraph("" + totalAdjustment)); celltxtAdjust1.setColspan(2); celltxtAdjust1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust1); PdfPCell celltxtTotalPaid = new PdfPCell(new Paragraph("Total Paid")); celltxtTotalPaid.setColspan(3); celltxtTotalPaid.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid); PdfPCell celltxtTotalPaid1 = new PdfPCell(new Paragraph("" + totalTotalPaid)); celltxtTotalPaid1.setColspan(2); celltxtTotalPaid1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid1); doc.add(table); doc.close(); //JOptionPane.showMessageDialog(null, "Report Created!"); // open PDF file File file = new File("Reports\\Monthly" + time + " " + formatedDate + ".pdf"); if (file.toString().endsWith(".pdf")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file); else { Desktop desktop = Desktop.getDesktop(); desktop.open(file); } } catch (DocumentException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ManagementPackage.Setting.java
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed // TODO add your handling code here: totalAdjustment = 0;/*from ww w . jav a2 s. c o m*/ totalTotalPaid = 0; total = 0; Document doc = new Document(); try { long time = new Date().getTime(); PdfWriter.getInstance(doc, new FileOutputStream("Reports\\Yearly" + time + " " + formatedDate + ".pdf")); doc.open(); PdfPTable table = new PdfPTable(5); PdfPCell cell1 = new PdfPCell(new Paragraph("Shop Management System \n\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.WHITE))); cell1.setColspan(10); cell1.setPadding(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setBackgroundColor(BaseColor.BLACK); table.addCell(cell1); PdfPCell cell21 = new PdfPCell(new Paragraph("\n\n")); cell21.setColspan(10); cell21.setBorder(2); cell21.setBorderColorLeft(BaseColor.WHITE); table.addCell(cell21); PdfPCell cell2 = new PdfPCell(new Paragraph("Yearly Report\n")); cell2.setColspan(10); cell2.setPadding(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell2); PdfPCell cell4 = new PdfPCell(new Paragraph("Date: " + formatedDateTime)); cell4.setColspan(10); cell4.setPaddingBottom(10); cell4.setPaddingTop(10); cell4.setBorder(2); cell4.setHorizontalAlignment(Element.ALIGN_RIGHT); cell4.setBorderColorRight(BaseColor.WHITE); table.addCell(cell4); table.addCell("Transaction No"); table.addCell("Billed By"); table.addCell("Product Name"); table.addCell("Qty"); table.addCell("Amount (TK)"); String PrevTransNo = " "; String query = "select trans_no, product_name, qty, amount, trans_by from trans_details where date like '%" + year + "%'"; try { pst = con.prepareStatement(query); rs = pst.executeQuery(); while (rs.next()) { String NewTransNo = rs.getString("trans_no"); String product_name = rs.getString("product_name"); String qty = rs.getString("qty"); String amount = rs.getString("amount"); String trans_by = rs.getString("trans_by"); total = total + Float.parseFloat(amount); if (PrevTransNo.equals(NewTransNo)) table.addCell(" "); else { table.addCell(NewTransNo); String query1 = "select adjustment, total_paid from paid_amount where trans_no = '" + NewTransNo + "'"; pst1 = con1.prepareStatement(query1); rs1 = pst1.executeQuery(); String adjustment = rs1.getString("adjustment"); String total_paid = rs1.getString("total_paid"); totalAdjustment = totalAdjustment + Float.parseFloat(adjustment); totalTotalPaid = totalTotalPaid + Float.parseFloat(total_paid); rs1.close(); pst1.close(); } PrevTransNo = rs.getString("trans_no"); table.addCell(trans_by); table.addCell(product_name); table.addCell(qty); PdfPCell cellAmount = new PdfPCell(new Paragraph(amount)); cellAmount.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellAmount); } rs.close(); pst.close(); } catch (SQLException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell cellb = new PdfPCell(new Paragraph(" ")); cellb.setColspan(10); cellb.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cellb); // PdfPCell celltxtTotal = new PdfPCell(new Paragraph("Total")); celltxtTotal.setColspan(3); celltxtTotal.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal); PdfPCell celltxtTotal1 = new PdfPCell(new Paragraph("" + total)); celltxtTotal1.setColspan(2); celltxtTotal1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotal1); PdfPCell celltxtAdjust = new PdfPCell(new Paragraph("Adjustment")); celltxtAdjust.setColspan(3); celltxtAdjust.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust); PdfPCell celltxtAdjust1 = new PdfPCell(new Paragraph("" + totalAdjustment)); celltxtAdjust1.setColspan(2); celltxtAdjust1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtAdjust1); PdfPCell celltxtTotalPaid = new PdfPCell(new Paragraph("Total Paid")); celltxtTotalPaid.setColspan(3); celltxtTotalPaid.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid); PdfPCell celltxtTotalPaid1 = new PdfPCell(new Paragraph("" + totalTotalPaid)); celltxtTotalPaid1.setColspan(2); celltxtTotalPaid1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(celltxtTotalPaid1); doc.add(table); doc.close(); //JOptionPane.showMessageDialog(null, "Report Created!"); // open PDF file File file = new File("Reports\\Yearly" + time + " " + formatedDate + ".pdf"); if (file.toString().endsWith(".pdf")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file); else { Desktop desktop = Desktop.getDesktop(); desktop.open(file); } } catch (DocumentException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:mvjce.PDF.java
public static PdfPCell getCell(String text, int alignment) { PdfPCell cell = new PdfPCell(new Phrase(text, new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD))); cell.setPadding(1); cell.setHorizontalAlignment(alignment); cell.setBorder(PdfPCell.NO_BORDER);//from ww w .j ava2 s. co m return cell; }
From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java
License:Open Source License
private void addTableRow(PdfPTable table, Change change) throws BadElementException, MalformedURLException, IOException { PdfPCell cell = new PdfPCell(new Phrase(change.getElementType())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell);// www .ja v a2 s .c om cell = new PdfPCell(new Phrase(change.getElementName())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase(change.getPropertyName())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase(change.getDescription())); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setPadding(4f); table.addCell(cell); cell = new PdfPCell(getImageForStatus(change.getStatus()), false); cell.setPadding(10f); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); String reviewed = Messages.no; if (change.isReviewed()) { reviewed = Messages.yes; } cell = new PdfPCell(new Phrase(reviewed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell); }
From source file:org.cejug.yougi.web.report.EventAttendeeReport.java
License:Open Source License
public void printReport(List<Attendee> attendees) throws DocumentException { float[] columnSizes = { 20, 220, 220, 60 }; PdfPTable table = new PdfPTable(columnSizes.length); table.setLockedWidth(true);//from w w w. j av a 2 s .c o m table.setTotalWidth(columnSizes); PdfPCell headerCell = new PdfPCell(new Phrase("Yougi")); headerCell.setColspan(4); headerCell.setBackgroundColor(BaseColor.ORANGE); headerCell.setPadding(3); table.addCell(headerCell); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); PdfPCell checkCell = new PdfPCell(new Phrase(" ")); checkCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(checkCell); PdfPCell productCell = new PdfPCell(new Phrase("Nome")); productCell.setBackgroundColor(BaseColor.LIGHT_GRAY); productCell.setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell(productCell); PdfPCell currentPurchaseCell = new PdfPCell(new Phrase("Email")); currentPurchaseCell.setPadding(3); currentPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER); currentPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(currentPurchaseCell); PdfPCell previousPurchaseCell = new PdfPCell(new Phrase("Presente")); previousPurchaseCell.setPadding(3); previousPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER); previousPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(previousPurchaseCell); table.getDefaultCell().setBackgroundColor(null); table.setHeaderRows(2); Font font = new Font(Font.FontFamily.HELVETICA, 9); int seq = 1; for (Attendee attendee : attendees) { table.addCell(new Phrase(String.valueOf(seq++), font)); table.addCell(new Phrase(attendee.getUserAccount().getFullName(), font)); table.addCell(new Phrase(attendee.getUserAccount().getEmail(), font)); table.addCell(" "); } document.add(table); }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private void writeTitlePage() throws DocumentException { Rectangle page = myDoc.getPageSize(); PdfPTable head = new PdfPTable(1); PdfPTable colontitleTable = createColontitleTable(getProject().getProjectName(), GanttLanguage.getInstance().getMediumDateFormat().format(new Date()), getProject().getOrganization(), getProject().getWebLink()); head.setTotalWidth(page.getWidth() - myDoc.leftMargin() - myDoc.rightMargin()); {/*from w w w . j a v a 2 s. c o m*/ PdfPCell cell = new PdfPCell(colontitleTable); cell.setBorder(PdfPCell.NO_BORDER); head.addCell(cell); } addEmptyRow(head, 20); LinkedHashMap<String, String> attrs = new LinkedHashMap<>(); attrs.put(i18n("label.project_manager"), buildManagerString()); attrs.put(i18n("label.dates"), buildProjectDatesString()); attrs.put(" ", " "); attrs.put(i18n("label.completion"), buildProjectCompletionString()); attrs.put(i18n("label.tasks"), String.valueOf(getProject().getTaskManager().getTaskCount())); attrs.put(i18n("label.resources"), String.valueOf(getProject().getHumanResourceManager().getResources().size())); PdfPTable attrsTable = new PdfPTable(2); writeAttributes(attrsTable, attrs); PdfPCell attrsCell = new PdfPCell(attrsTable); attrsCell.setBorder(PdfPCell.NO_BORDER); head.addCell(attrsCell); addEmptyRow(head, 20); if (getProject().getDescription().length() > 0) { Paragraph p = new Paragraph(getProject().getDescription(), getSansRegular(12)); PdfPCell cell = new PdfPCell(p); cell.setBorder(PdfPCell.TOP | PdfPCell.BOTTOM); cell.setBorderColor(SORTAVALA_GREEN); cell.setBorderWidth(1); cell.setPadding(5); cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER); head.addCell(cell); } myDoc.add(head); }
From source file:org.openlmis.web.view.pdf.requisition.RequisitionCellFactory.java
License:Open Source License
private static PdfPCell getPdfPCell(String value) { PdfPCell cell = new PdfPCell(new Phrase(value)); cell.setPadding(CELL_PADDING); return cell;/*ww w. ja va 2 s . c om*/ }