List of usage examples for com.itextpdf.text Font BOLD
int BOLD
To view the source code for com.itextpdf.text Font BOLD.
Click Source Link
From source file:com.etest.pdfgenerator.TQCoveragePDF.java
public TQCoveragePDF(int tqCoverageId) { this.tqCoverageId = tqCoverageId; Document document = null;/*from w w w . ja va2s . c o m*/ try { document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, outputStream); document.open(); Font header1 = FontFactory.getFont("Times-Roman", 14, Font.BOLD); Font header2 = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font content = FontFactory.getFont("Times-Roman", 10); Image img = null; try { img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png"); img.scaleToFit(60, 60); img.setAbsolutePosition(100, 720); } catch (BadElementException | IOException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } document.add(img); Paragraph title = new Paragraph(); title.setAlignment(Element.ALIGN_CENTER); title.add(new Phrase("COLLEGE OF NURSING", header2)); document.add(title); Paragraph school = new Paragraph(); school.setAlignment(Element.ALIGN_CENTER); school.add(new Phrase("Siliman University", header2)); document.add(school); Paragraph location = new Paragraph(); location.setSpacingAfter(10f); location.setAlignment(Element.ALIGN_CENTER); location.add(new Phrase("Dumaguete City", header2)); document.add(location); Paragraph examTitle = new Paragraph(); examTitle.setSpacingAfter(20f); examTitle.setAlignment(Element.ALIGN_CENTER); examTitle .add(new Phrase( cs.getCurriculumById(tq.getTQCoverageById(getTQCoverageId()).getCurriculumId()) .getSubject() + " " + tq.getTQCoverageById(getTQCoverageId()).getExamTitle(), header2)); document.add(examTitle); Paragraph instruction = new Paragraph(); instruction.setSpacingAfter(5f); instruction.setAlignment(Element.ALIGN_LEFT); instruction.add( new Phrase("INSTRUCTIONS: Read the cases carefully. Choose the letter of the correct answer. " + "Use an answer sheet and follow instruction for its use.", content)); document.add(instruction); int itemNo = 1; Map<Integer, Map<Integer, Integer>> tqCoverage = tq.getTQCoverage(getTQCoverageId()); for (Map.Entry<Integer, Map<Integer, Integer>> tqCases : tqCoverage.entrySet()) { Integer tqCaseId = tqCases.getKey(); Label caseTopic = new Label(); caseTopic.setValue(ccs.getCellCaseById(tqCaseId).getCaseTopic()); caseTopic.setContentMode(ContentMode.HTML); document.add(new Paragraph(caseTopic.getValue().replaceAll("(?i)<p.*?>.*?</p>", ""), content)); Map<Integer, Integer> value = tqCases.getValue(); for (Map.Entry<Integer, Integer> itemIds : value.entrySet()) { Integer itemId = itemIds.getKey(); Integer itemKeyId = itemIds.getValue(); List<String> keyList = k.getAllItemKey(itemId); if (keyList.isEmpty()) { ShowErrorNotification.error( "No Item Key was found for STEM: \n" + cis.getCellItemById(itemId).getItem()); return; } Label stem = new Label(); // stem.setValue(itemNo+". "+cis.getCellItemById(itemId).getItem().replace("{key}", keyList.get(0))); stem.setValue(itemNo + ". " + cis.getCellItemById(itemId).getItem().replace("{key}", k.getItemKeyById(itemKeyId))); stem.setContentMode(ContentMode.HTML); document.add(new Paragraph(stem.getValue(), content)); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setSpacingBefore(10f); table.setSpacingAfter(10f); //Set Column widths float[] columnWidths = { 1f, 1f }; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell( new Paragraph("A) " + cis.getCellItemById(itemId).getOptionA(), content)); // cell1.setBorderColor(BaseColor.BLUE); cell1.setBorder(0); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell( new Paragraph("C) " + cis.getCellItemById(itemId).getOptionC(), content)); // cell2.setBorderColor(BaseColor.GREEN); cell2.setBorder(0); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell( new Paragraph("B) " + cis.getCellItemById(itemId).getOptionB(), content)); // cell3.setBorderColor(BaseColor.RED); cell3.setBorder(0); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell4 = new PdfPCell( new Paragraph("D) " + cis.getCellItemById(itemId).getOptionD(), content)); // cell4.setBorderColor(BaseColor.RED); cell4.setBorder(0); cell4.setPaddingLeft(10); cell4.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); document.add(table); itemNo++; } } document.newPage(); Paragraph ticketNo = new Paragraph(); ticketNo.setSpacingAfter(30f); ticketNo.setAlignment(Element.ALIGN_LEFT); ticketNo.add(new Phrase("TQ Ticket #: " + tq.getTqCoverageTicketNo(getTQCoverageId()), content)); document.add(ticketNo); document.add(new Paragraph("Answer Key: ")); itemNo = 1; List<TQAnswerKey> answerKey = tq.getTQCoverageAnswerKey(getTQCoverageId()); for (TQAnswerKey t : answerKey) { document.add(new Paragraph( t.getItemNo() + ": " + cis.getOptionAnswer(t.getCellItemId()).get(t.getAnswer()))); } } catch (DocumentException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } finally { if (document != null) { document.close(); } } }
From source file:com.etest.pdfgenerator.TQCriticalIndexValuesReportPDF.java
public TQCriticalIndexValuesReportPDF(int tqCoverageId) { this.tqCoverageId = tqCoverageId; Document document = null;/*w ww . j a v a2 s . c o m*/ try { document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, outputStream); document.open(); Font header = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font content = FontFactory.getFont("Times-Roman", 10); Paragraph reportTitle = new Paragraph(); reportTitle.setSpacingAfter(10f); reportTitle.setAlignment(Element.ALIGN_CENTER); reportTitle.add(new Phrase("Interactive Querying", header)); document.add(reportTitle); Paragraph title2 = new Paragraph(); title2.setSpacingAfter(10f); title2.setAlignment(Element.ALIGN_CENTER); title2.add(new Phrase("View Item Analysis Critical Values of a Test", content)); document.add(title2); Paragraph subject = new Paragraph(); subject.setAlignment(Element.ALIGN_LEFT); subject.add(new Phrase("Subject: " + cs.getCurriculumById(tq.getTQCoverageById(getTqCoverageId()).getCurriculumId()).getSubject() .toUpperCase() + "(" + cs.getCurriculumById(tq.getTQCoverageById(getTqCoverageId()).getCurriculumId()) .getDescriptiveTitle() + ")", content)); document.add(subject); Paragraph term = new Paragraph(); term.setAlignment(Element.ALIGN_LEFT); term.add(new Phrase("SY and Semester Administered: 2015-16 2nd Semester", content)); document.add(term); Paragraph descriptiveTitle = new Paragraph(); descriptiveTitle.setSpacingAfter(10f); descriptiveTitle.setAlignment(Element.ALIGN_LEFT); descriptiveTitle.add( new Phrase("Type of Test: " + tq.getTQCoverageById(getTqCoverageId()).getExamTitle(), content)); document.add(descriptiveTitle); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(75); PdfPCell cellOne = new PdfPCell(new Phrase("Difficulty")); cellOne.setBorder(0); cellOne.setHorizontalAlignment(Element.ALIGN_CENTER); cellOne.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellTwo = new PdfPCell(new Phrase("Discrimination")); cellTwo.setBorder(0); cellTwo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTwo.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellThree = new PdfPCell(new Phrase( String.valueOf(rs.getTQCriticalIndexValue(getTqCoverageId(), "DifficultIndex", 0.00, 0.19)) + " Very difficult item(s)", content)); cellThree.setBorder(0); cellThree.setPaddingLeft(50); cellThree.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cellThree.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellFour = new PdfPCell(new Phrase( String.valueOf(rs.getTQCriticalIndexValue(getTqCoverageId(), "DiscriminationIndex", 0.00, 0.19)) + " Poor items(s)", content)); cellFour.setBorder(0); cellFour.setHorizontalAlignment(Element.ALIGN_CENTER); cellFour.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellFive = new PdfPCell(new Phrase( String.valueOf(rs.getTQCriticalIndexValue(getTqCoverageId(), "DifficultIndex", 0.81, 1)) + " Very easy item(s)", content)); cellFive.setBorder(0); cellFive.setPaddingLeft(50); cellFive.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cellFive.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellSix = new PdfPCell(new Phrase("")); cellSix.setBorder(0); cellSix.setHorizontalAlignment(Element.ALIGN_CENTER); cellSix.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cellOne); table.addCell(cellTwo); table.addCell(cellThree); table.addCell(cellFour); table.addCell(cellFive); table.addCell(cellSix); table.getDefaultCell().setBorderWidth(0f); document.add(table); } catch (DocumentException ex) { Logger.getLogger(TQCriticalIndexValuesReportPDF.class.getName()).log(Level.SEVERE, null, ex); } finally { if (document != null) { document.close(); } } }
From source file:com.farouk.projectapp.ManagerGUI.java
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed String pdfName = JOptionPane.showInputDialog(rootPane, "Enter Title", "Please enter a title", WIDTH); if (pdfName.isEmpty()) { pdfName = "Global Report"; }/* w w w . ja v a 2 s.co m*/ Document document = new Document(); int numEMployees = 1; try { PdfWriter.getInstance(document, new FileOutputStream(pdfName + ".pdf")); document.open(); document.addAuthor("TeamPirates"); document.addTitle("Global Report"); Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.BOLD); Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.UNDERLINE); for (User u : SQLConnectMana.getEmployeesFromDb()) { JTable jTableTran = new JTable(); JTable jTableReport = new JTable(); Chapter chapter = new Chapter( new Paragraph(new Phrase("Employee : " + u.getLogin() + "\n\n", font1)), numEMployees); Section section1 = chapter.addSection(new Paragraph(new Phrase("Recent Transactions :\n", font2)), 9); Section section2 = chapter.addSection(new Paragraph(new Phrase("Reported Companies :\n", font2)), 9); // Transactions : DefaultTableModel modelPDFtrans = new DefaultTableModel(); modelPDFtrans.setColumnIdentifiers( new String[] { "Name", "Operation", "Quantity", "Price Paid", "Date" }); for (Transaction t : SQLConnectMana.getTransactions(u.getId())) { modelPDFtrans.addRow(new String[] { t.getSymbol(), t.getOperation(), Integer.toString(t.getQuantity()), Double.toString(t.getPricePaid()), t.getDate() }); } jTableTran.setModel(modelPDFtrans); PdfPTable pdfTableTrans = new PdfPTable(jTableTran.getColumnCount()); for (int i = 0; i < jTableTran.getColumnCount(); i++) { pdfTableTrans.addCell(jTableTran.getColumnName(i)); } //extracting data from the JTable and inserting it to PdfPTable for (int rows = 0; rows < jTableTran.getRowCount(); rows++) { for (int cols = 0; cols < jTableTran.getColumnCount(); cols++) { pdfTableTrans.addCell(jTableTran.getModel().getValueAt(rows, cols).toString()); } } Paragraph blank = new Paragraph("\n\n"); section1.add(blank); section1.add(pdfTableTrans); section1.add(blank); //Reported Companies : DefaultTableModel modelPDFReported = new DefaultTableModel(); modelPDFReported.setColumnIdentifiers( new String[] { "Name", "Symbol", "Stock Price ()", "Quantity Bought" }); for (Company c : SQLConnectMana.getNameOfReported(u.getId())) { modelPDFReported.addRow(new String[] { c.getName(), c.getSymbol(), String.valueOf(c.getStockPrice().doubleValue()), Integer.toString(c.getNumberOwned()) }); } jTableReport.setModel(modelPDFReported); PdfPTable pdfTableReport = new PdfPTable(jTableReport.getColumnCount()); for (int i = 0; i < jTableReport.getColumnCount(); i++) { pdfTableReport.addCell(jTableReport.getColumnName(i)); } //extracting data from the JTable and inserting it to PdfPTable for (int rows = 0; rows < jTableReport.getRowCount(); rows++) { for (int cols = 0; cols < jTableReport.getColumnCount(); cols++) { pdfTableReport.addCell(jTableReport.getModel().getValueAt(rows, cols).toString()); } } section2.add(blank); section2.add(pdfTableReport); section2.add(blank); //End of doc for a single employee document.add(chapter); numEMployees++; } Chapter ban = new Chapter(new Paragraph(new Phrase("Prohibited Companies :\n\n", font1)), ++numEMployees); com.itextpdf.text.List bannedCompanies = new List(List.ORDERED); for (String lii : SQLConnectMana.getBannedCompForAll()) { bannedCompanies.add(new com.itextpdf.text.ListItem(lii)); } ban.add(bannedCompanies); document.add(ban); document.close(); } catch (DocumentException | FileNotFoundException e) { System.err.println("Sorry Problem in pdf.\n" + e); } }
From source file:com.gadroves.gsisinve.controller.FacturarController.java
void PrintToPDF(TbFacturaVenta facturaVenta, TbCLienteFactura cLienteFactura) throws DocumentException, IOException { Font header = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD); Font normalBold = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); Font normal = new Font(Font.FontFamily.HELVETICA, 12); String fileName = "Factura_" + facturaVenta.getId() + ".pdf"; // step 1// w ww . j a v a 2 s . c o m Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(fileName)); // step 3 document.open(); // step 4 document.add(new Paragraph("Gadroves S.A Factura De Venta", header)); document.add(new Paragraph(" ")); document.add(new Paragraph("Factura N" + facturaVenta.getId(), normalBold)); document.add(new Chunk("Cliente: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getName(), normal)); document.add(new Paragraph()); document.add(new Chunk("Direccin: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getAddress(), normal)); document.add(new Paragraph()); document.add(new Chunk("Identificacion: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getId(), normal)); document.add(new Paragraph()); document.add(new Chunk("Credito: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(Boolean.FALSE.toString(), normal)); document.add(new Paragraph()); for (int i = 0; i < 3; i++) document.add(new Paragraph(" ")); createItemsTable(document, facturaVenta); document.add(new Paragraph(" ")); Paragraph subs = new Paragraph(); subs.setAlignment(Element.ALIGN_RIGHT); subs.setIndentationRight(40); subs.add(new Chunk("Subtotal: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getSub())))); subs.add(Chunk.NEWLINE); subs.add(new Chunk( "Impuestos: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getImpuestos())))); subs.add(Chunk.NEWLINE); subs.add(new Chunk( "Total: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getTotal())))); subs.add(Chunk.NEWLINE); document.add(subs); // step 5 document.close(); Desktop.getDesktop().open(new File(fileName)); }
From source file:com.github.luischavez.levsym.modulos.funcion.PDF.java
License:Open Source License
public void GeneraPDF(ResultSet Resultados) throws Exception { ResultSetMetaData metaData = Resultados.getMetaData(); Object[] Columnas = new Object[metaData.getColumnCount()]; String encabezado = "Reportes del Sistema Administrativo" + "\n" + "REGISTROS ACTUALES EN AL BASE DE DATOS" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n"; Calendar c = Calendar.getInstance(); String date = Integer.toString(c.get(Calendar.DAY_OF_MONTH)) + "-" + Integer.toString(c.get(Calendar.MONTH)) + "-" + Integer.toString(c.get(Calendar.YEAR)) + " " + Integer.toString(c.get(Calendar.HOUR_OF_DAY)) + "-" + Integer.toString(c.get(Calendar.MINUTE)) + "-" + Integer.toString(c.get(Calendar.SECOND)); Font fuente = new Font(Font.getFamily("ARIAL"), 12, Font.BOLD); String choro = "Reporte por fecha de los modulos\n" + "de catalogo" + "\n" + "Systema Administrativo" + "\n" + "\n" + "\n" + "\n"; Image imagen = Image.getInstance(System.getProperty("user.dir") + "/Image/logo.png"); imagen.setAlignment(Image.TEXTWRAP); try {//from w w w. j av a 2 s.com Paragraph linea = new Paragraph(encabezado, fuente); Phrase para = new Phrase(choro); Paragraph fecha = new Paragraph(date + "\n" + "\n"); PdfPTable tabla = new PdfPTable(Columnas.length); tabla.setWidthPercentage(100); //Document documento = new Document(PageSize.LETTER); Document documento = new Document(PageSize.A4.rotate(), 50, 50, 100, 72); File Dir = new File(System.getProperty("user.dir") + "/Reportes/"); if (!Dir.exists()) { Dir.mkdirs(); } String file = System.getProperty("user.dir") + "/Reportes/" + metaData.getTableName(1) + " " + date + ".pdf"; PdfWriter.getInstance(documento, new FileOutputStream(file)); documento.open(); documento.add(imagen); documento.add(linea); documento.add(para); documento.add(fecha); for (int x = 0; x < Columnas.length; x++) { PdfPCell Celda = new PdfPCell(new Paragraph(metaData.getColumnName(x + 1), FontFactory.getFont("arial", 9, Font.BOLD, BaseColor.RED))); Celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(Celda); } while (Resultados.next()) { for (int x = 0; x < Columnas.length; x++) { //if(Resultados.getObject(x+1).getClass().getSimpleName().equals("Integer")) PdfPCell Celda = new PdfPCell(new Paragraph(String.valueOf(Resultados.getObject(x + 1)), FontFactory.getFont("arial", 9, BaseColor.BLACK))); Celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(Celda); } } documento.add(tabla); documento.close(); } catch (DocumentException e) { Log.SaveLog(e.toString()); JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { Log.SaveLog(e.toString()); JOptionPane.showMessageDialog(null, e.getMessage(), "error", JOptionPane.ERROR_MESSAGE); } }
From source file:com.github.wolfposd.imsqti2pdf.PDFCreator.java
License:Open Source License
private Chunk getQuestionNumberChunk(Font f, int number) { Chunk c = new Chunk((number + 1) + ". "); Font ff = new Font(f); ff.setStyle(Font.BOLD); c.setFont(ff);/* w ww .jav a 2s . c o m*/ return c; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable addingCommodityValues() throws DocumentException, ParseException, Exception { Font font6 = new Font(FontFamily.COURIER, 6f, Font.BOLD); Font blackContentNormalFont8 = FontFactory.getFont("Arial", 8f, Font.NORMAL); Paragraph p = null;//from w w w .j a v a2s. c o m table = new PdfPTable(5); table.setWidthPercentage(100f); table.setWidths(new float[] { 2.74f, 1f, 6.33f, 1.40f, 1.40f }); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, " " + ipeHotCodeComments, blackContentNormalFont8); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(2f); cell.addElement(p); p = new Paragraph(7f, "" + billingType, totalFontQuote); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(2f); cell.addElement(p); if ("Y".equalsIgnoreCase(receiveKeyValue)) { p = new Paragraph(7f, "*** PLEASE NOTE THAT PAYMENT MUST BE RECEIVED PRIOR TO ISSUING EXPRESS RELEASE / ORIGINAL HBL ***", blackContentNormalFont8); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); } p = new Paragraph(7f, "I HEREBY DECLARE THAT THE ABOVE NAMED MATERIALS ARE PROPERLY CLASSIFIED," + "\n" + "DESCRIBED,PACKAGED, MARKED, AND LABELED, AND ARE IN PROPER CONDITION FOR" + "\n" + "TRANSPORTATION ACCORDING TO THE APPLICABLE REGULATIONS OF THE DEPARTMENT" + "\n" + " OF TRANSPORTATION AND IMO.", font6); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(0); cell.setBorderWidthLeft(0.6f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(5); p = new Paragraph(7f, " Declared value per Package if value is More Than $500 Per Package USD___________________________", blackContentNormalFont8); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingBefore(5f); cell.addElement(p); p = new Paragraph(7f, "These Commodities, Technology Or Software Were Exported From the United States in Accordance with the Export " + "Administration Regulations.", blackContentNormalFont8); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); p = new Paragraph(7f, "Diversion Contrary To U.S. Law Prohibited.", blackContentNormalFont8); p.setSpacingBefore(3f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclConsolidationMiniManifestPdfCreator.java
private Element consolidateTable(String fileId) throws DocumentException, Exception { consolidateTable = new PdfPTable(8); consolidateTable.setWidthPercentage(99f); consolidateTable.setWidths(new float[] { 1f, 2f, 1f, 1f, 1f, 1f, 2f, 2f }); int pieceTotal = 0; DecimalFormat df = new DecimalFormat("0.00"); Double cftTotal = 0.0;/* w w w .j a va 2 s.c o m*/ Double kgsToatl = 0.0; Paragraph p = null; Font blackStarSize = new Font(Font.FontFamily.COURIER, 9f, Font.BOLD); if (CommonUtils.isNotEmpty(fileId)) { LclConsolidateDAO consolidateDAO = new LclConsolidateDAO(); LCLBookingDAO lCLBookingDAO = new LCLBookingDAO(); long fileIDd = Long.parseLong(fileId); List consolidateFileList = consolidateDAO.getConsolidatesFiles(fileIDd); List newList = new ArrayList(); if (null != consolidateFileList && CommonUtils.isNotEmpty(consolidateFileList)) { newList.add(Long.parseLong(fileId)); newList.addAll(consolidateFileList); List<ConsolidationMiniManifestBean> minimanifestBean = lCLBookingDAO.getConsolidateDr(newList); for (ConsolidationMiniManifestBean value : minimanifestBean) { consolidateTable.addCell(makeCellNoBorderFont("", 1f, 8, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("", 1f, 8, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("", 1f, 8, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("D/R", 1f, 0, blackNormalCourierFont10f)); consolidateTable .addCell(makeCellNoBorderFont("Supplier Name", 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("PCS", 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("Type", 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("CFT ", 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("Weight", 1f, 0, blackNormalCourierFont10f)); consolidateTable .addCell(makeCellNoBorderFont("DESCRIPTION ", 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell( makeCellNoBorderFont("PURCHASE ORDER/INVOICE", 1f, 0, blackNormalCourierFont10f)); consigneeCell = new PdfPCell(); consigneeCell.setBorder(0); consigneeCell.setPadding(0f); consigneeCell.setPaddingLeft(-3f); consigneeCell.setPaddingRight(-7f); consigneeCell.setPaddingBottom(4f); consigneeCell.setColspan(19); p = new Paragraph(8f, " ------------- ---------------------------- --------- ---------" + "----------- ------------- ------------- -------------" + "--------------------- -----------------------------", blackStarSize); consigneeCell.addElement(p); consolidateTable.addCell(consigneeCell); String customerpoValue = value.getCustomerPo(); List l = null; if (null != customerpoValue && CommonUtils.isNotEmpty(customerpoValue)) { l = helperClass.wrapAddress(customerpoValue); if (l.isEmpty() || l.size() < 3) { ADDRESS_SIZE += 3; } else { ADDRESS_SIZE += l.size(); } } consolidateTable .addCell(makeCellNoBorderFont(value.getFileNumber(), 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell( makeCellNoBorderFont(value.getSupplierName(), 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont(String.valueOf(value.getPiece()), 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell( makeCellNoBorderFont(value.getPackageName(), 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont( null != value.getCft() ? String.valueOf(df.format(value.getCft())) : "", 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont( null != value.getCft() ? String.valueOf(df.format(value.getKgs())) : "", 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont(value.getComDescrption().toUpperCase(), 1f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont(null != customerpoValue ? customerpoValue : "", 1f, 0, blackNormalCourierFont10f)); consigneeCell = new PdfPCell(); consigneeCell.setBorder(0); consigneeCell.setPadding(0f); consigneeCell.setPaddingLeft(-3f); consigneeCell.setPaddingRight(-7f); consigneeCell.setPaddingBottom(4f); consigneeCell.setColspan(19); p = new Paragraph(8f, " ***********************************************************" + "**************************************************" + "***********************************************************", blackStarSize); consigneeCell.addElement(p); consolidateTable.addCell(consigneeCell); pieceTotal = pieceTotal + value.getPiece(); if (null != value.getCft()) { cftTotal = (cftTotal + value.getCft()); df.format(cftTotal.doubleValue()); } if (null != value.getKgs()) { kgsToatl = kgsToatl + value.getKgs(); df.format(cftTotal.doubleValue()); } } } consolidateTable.addCell(makeCellNoBorderFont("", 2f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("Grand Totals", 2f, 0, blackNormalCourierFont10f)); consolidateTable .addCell(makeCellNoBorderFont(String.valueOf(pieceTotal), 2f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("", 2f, 0, blackNormalCourierFont10f)); consolidateTable.addCell( makeCellNoBorderFont(String.valueOf(df.format(cftTotal)), 2f, 0, blackNormalCourierFont10f)); consolidateTable.addCell( makeCellNoBorderFont(String.valueOf(df.format(kgsToatl)), 2f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("", 2f, 0, blackNormalCourierFont10f)); consolidateTable.addCell(makeCellNoBorderFont("", 2f, 0, blackNormalCourierFont10f)); } return consolidateTable; }
From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java
public PdfPTable onStartPage(String realPath, String scheduleNo, String unitNo, String voyContent) throws Exception { String path = LoadLogisoftProperties.getProperty("application.image.logo"); Font fontArialBold = FontFactory.getFont("Arial", 10f, Font.BOLD); Font colorBoldFont = FontFactory.getFont("Arial", 12f, Font.BOLD, new BaseColor(00, 102, 00)); Phrase p = null;//from w ww .j av a 2 s. c om Paragraph pValues = null; table = new PdfPTable(6); table.setWidths(new float[] { 0.1f, 1.8f, 2.5f, 3.5f, 1.8f, 1.8f }); table.setWidthPercentage(100f); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setRowspan(3); table.addCell(cell); cell = new PdfPCell(); cell.setPadding(0f); cell.setBorder(0); cell.setPaddingBottom(3f); p = new Phrase("", fontArialBold); p.setLeading(20f); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(25f, "", fontArialBold); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setRowspan(3); cell.setBorder(0); cell.setPadding(0f); Image img = Image.getInstance(realPath + path); img.scalePercent(60); img.setAlignment(Element.ALIGN_CENTER); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(20f, "Date:", fontArialBold); pValues.setAlignment(Element.ALIGN_RIGHT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(20f, " " + DateUtils.formatStringDateToAppFormatMMM(new Date()), fontArialBold); pValues.setAlignment(Element.ALIGN_LEFT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setPadding(0f); cell.setBorder(0); cell.setPaddingBottom(3f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPaddingBottom(3f); cell.setPadding(0f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(9f, "Time:", fontArialBold); pValues.setAlignment(Element.ALIGN_RIGHT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); pValues = new Paragraph(9f, " " + DateUtils.formatStringDateToTimeTT(new Date()), fontArialBold); pValues.setAlignment(Element.ALIGN_LEFT); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(0); cell.setPadding(0f); cell.setPaddingBottom(3f); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(0); cell.setPaddingBottom(3f); table.addCell(cell); //voyage cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setPaddingLeft(5f); pValues = new Paragraph(8f, "VOYAGE NOTIFICATION", colorBoldFont); pValues.setAlignment(Element.ALIGN_CENTER); cell.addElement(pValues); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(2); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java
public PdfPTable voyInfo(LclUnitSs lclUnitSs) throws DocumentException { StringBuilder originValues = new StringBuilder(); if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationName())) { originValues.append(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationName()).append(","); }//from w ww. j a v a 2s. co m if (null != lclUnitSs.getLclSsHeader().getOrigin().getCountryId() && CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getOrigin().getCountryId().getCodedesc())) { originValues.append(lclUnitSs.getLclSsHeader().getOrigin().getCountryId().getCodedesc()).append(" "); } if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationCode())) { originValues.append("(").append(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationCode()).append(")"); } StringBuilder fdValues = new StringBuilder(); if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getDestination().getUnLocationName())) { fdValues.append(lclUnitSs.getLclSsHeader().getDestination().getUnLocationName()).append(","); } if (null != lclUnitSs.getLclSsHeader().getDestination().getStateId() && CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getDestination().getStateId().getCode())) { fdValues.append(lclUnitSs.getLclSsHeader().getDestination().getStateId().getCode()).append(" "); } if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getDestination().getUnLocationCode())) { fdValues.append("(").append(lclUnitSs.getLclSsHeader().getDestination().getUnLocationCode()) .append(")"); } Font fontCompSub = FontFactory.getFont("Arial", 9f, Font.BOLD); Paragraph pHeading = null; table = new PdfPTable(1); table.setWidthPercentage(100f); PdfPCell cell1 = new PdfPCell(); cell1.setBorder(0); cell1.setColspan(2); cell1.setBorderColor(new BaseColor(00, 51, 153)); cell1.setBorderWidthBottom(3f); cell1.setBorderWidthLeft(3f); cell1.setBorderWidthRight(3f); cell1.setBorderWidthTop(10f); cell1.setPadding(0f); //Heading pHeading = new Paragraph(8f, "Voyage Information", mainHeadingQuote); pHeading.setAlignment(Element.ALIGN_CENTER); cell1.addElement(pHeading); PdfPTable ntable1 = new PdfPTable(6); ntable1.setWidthPercentage(100f); ntable1.setWidths(new float[] { 0.1f, 1.15f, 0.09f, 4.09f, 1f, 2f }); //company Name ntable1.addCell(createEmptyCell(0, 1f, 6)); //Voyage Cell Origin ntable1.addCell(createEmptyCell(0, 1f, 0)); ntable1.addCell(makeCellNoBorderValue("Voyage. . . . . . . . . .", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(lclUnitSs.getLclSsHeader().getScheduleNo().toUpperCase(), 4, 0f, 5f, fontgreenCont)); //1Cell Origin ntable1.addCell(createEmptyCell(0, 1f, 0)); ntable1.addCell(makeCellNoBorderValue("Origin. . . . . . . . . . .", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(originValues.toString().toUpperCase(), 4, 0f, 5f, fontgreenCont)); ///2Cell Destination ntable1.addCell(createEmptyCell(0, 1f, 0)); ntable1.addCell(makeCellNoBorderValue("Destination. . . . . .", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(fdValues.toString().toUpperCase(), 4, 0f, 5f, fontgreenCont)); //3 StringBuilder billValues = new StringBuilder(); if (lclUnitSs.getLclSsHeader().getBillingTerminal().getTrmnum() != null) { billValues.append(lclUnitSs.getLclSsHeader().getBillingTerminal().getTrmnum()).append("-"); } if (lclUnitSs.getLclSsHeader().getBillingTerminal().getTerminalLocation() != null) { billValues.append(lclUnitSs.getLclSsHeader().getBillingTerminal().getTerminalLocation()); } ntable1.addCell(createEmptyCell(0, 1f, 0)); ntable1.addCell(makeCellNoBorderValue("Billing Terminal. . ", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub)); ntable1.addCell(makeCellNoBorderValue(billValues.toString().toUpperCase(), 4, 0f, 4f, fontgreenCont)); ntable1.addCell(createEmptyCell(0, 1f, 6)); cell1.addElement(ntable1); table.addCell(cell1); return table; }