List of usage examples for com.lowagie.text.pdf PdfPTable spacingAfter
float spacingAfter
To view the source code for com.lowagie.text.pdf PdfPTable spacingAfter.
Click Source Link
From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfTable.java
License:Open Source License
/** * Imports the rows and settings from the Table into this PatchRtfTable. * * @param table// w w w. j a v a 2 s . c o m * The source PdfPTable * @since 2.1.3 */ private void importTable(PdfPTable table) { this.rows = new ArrayList<PatchRtfRow>(); this.tableWidthPercent = table.getWidthPercentage(); // this.tableWidthPercent = table.getWidth(); this.proportionalWidths = table.getAbsoluteWidths(); // this.proportionalWidths = table.getProportionalWidths(); this.cellPadding = (float) (table.spacingAfter() * TWIPS_FACTOR); // this.cellPadding = (float) (table.getPadding() * TWIPS_FACTOR); this.cellSpacing = (float) (table.spacingAfter() * TWIPS_FACTOR); // this.cellSpacing = (float) (table.getSpacing() * TWIPS_FACTOR); // this.borders = new PatchRtfBorderGroup(this.document, PatchRtfBorder.ROW_BORDER, table.getBorder(), // table.getBorderWidth(), table.getBorderColor()); // this.borders = new PatchRtfBorderGroup(this.document, PatchRtfBorder.ROW_BORDER, table.getBorder(), // table.getBorderWidth(), table.getBorderColor()); this.alignment = table.getHorizontalAlignment(); // this.alignment = table.getAlignment(); int i = 0; Iterator rowIterator = table.getRows().iterator(); // Iterator rowIterator = table.iterator(); while (rowIterator.hasNext()) { this.rows.add(new PatchRtfRow(this.document, this, (PdfPRow) rowIterator.next(), i)); i++; } for (i = 0; i < this.rows.size(); i++) { this.rows.get(i).handleCellSpanning(); this.rows.get(i).cleanRow(); } this.headerRows = table.getHeaderRows(); // this.headerRows = table.getLastHeaderRow(); this.cellsFitToPage = table.getKeepTogether(); // this.cellsFitToPage = table.isCellsFitPage(); this.tableFitToPage = table.getKeepTogether(); // this.tableFitToPage = table.isTableFitsPage(); // if(!Float.isNaN(table.getOffset())) { // this.offset = (int) (table.getOffset() * 2); // } // if(!Float.isNaN(table.getOffset())) { // this.offset = (int) (table.getOffset() * 2); // } }
From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java
private void saveAsPdfBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsPdfBtnActionPerformed Document document = new Document(PageSize.A4.rotate()); String[] headers = new String[] { "Name", "TimeStamp", "Resp Rate", "Heart Rate", "Blood Pressure", "Temperature", "Status" }; String filename = fileNameTxt.getText(); try {//from w ww . j a v a 2 s . c o m if (!filename.equals("")) { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename + ".pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); PdfPTable table = new PdfPTable(headers.length); for (int i = 0; i < headers.length; i++) { String header = headers[i]; PdfPCell cell = new PdfPCell(); cell.setGrayFill(0.9f); cell.setPhrase(new Phrase(header.toUpperCase(), new Font(Font.HELVETICA, 8, Font.BOLD))); table.addCell(cell); } table.completeRow(); table.spacingBefore(); table.spacingAfter(); document.add(table); Graphics2D g2 = cb.createGraphicsShapes(500, 500); //cb.showTextAligned(PdfContentByte.ALIGN_CENTER, g2, 200, 300, 0); Shape oldClip = g2.getClip(); g2.clipRect(0, 0, 700, 500); vitalSignjTable.print(g2); g2.setClip(oldClip); g2.dispose(); cb.restoreState(); JOptionPane.showMessageDialog(null, "file saved", "Saved", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "enter the filename", "FileName", JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }