List of usage examples for com.lowagie.text.pdf PdfPCell getPaddingLeft
public float getPaddingLeft()
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocument.java
License:Open Source License
public float getWidthLimit() { PdfPCell cell = StylableDocumentSection.getCell(layoutTable, colIdx); return cell.getRight() - cell.getPaddingRight() - cell.getLeft() - cell.getPaddingLeft(); }
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocument.java
License:Open Source License
private void setColIdx(int idx) { colIdx = idx;//w w w .jav a 2 s . c o m PdfPCell cell = StylableDocumentSection.getCell(layoutTable, colIdx); text.setSimpleColumn(cell.getLeft() + cell.getPaddingLeft(), -getAdjustedPageHeight(), cell.getRight() - cell.getPaddingRight(), 0.0f); cell.setColumn(ColumnText.duplicate(text)); }
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocumentSection.java
License:Open Source License
private List<ColumnText> fillTable(float height) { // copy text for simulation List<ColumnText> tt = null; if (breakHandlingParent == null && colIdx >= layoutTable.getNumberOfColumns()) { // more column breaks than available column // we try not to lose content // but results may be different than in open office // anyway it is logical error made by document creator tt = new ArrayList<ColumnText>(); ColumnText t = createColumnText(); tt.add(t);//from w w w. ja va 2s. c om for (int i = 0; i < texts.size(); i++) { PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); PdfPCell cell = new PdfPCell(); cell.setBorder(Table.NO_BORDER); cell.setPadding(0.0f); cell.setColumn(ColumnText.duplicate(texts.get(i))); table.addCell(cell); t.addElement(table); } } else { tt = new ArrayList<ColumnText>(texts); for (int i = 0; i < tt.size(); i++) { tt.set(i, ColumnText.duplicate(tt.get(i))); } } // clear layout table clearTable(layoutTable, true); setWidthIfNecessary(); // try to fill cells with text ColumnText t = tt.get(0); for (PdfPCell cell : layoutTable.getRow(0).getCells()) { cell.setFixedHeight(height >= 0.0f ? height : -1.0f); cell.setColumn(ColumnText.duplicate(t)); // t.setSimpleColumn(cell.getLeft() + cell.getPaddingLeft(), height >= 0.0f ? -height : PdfPRow.BOTTOM_LIMIT, cell.getRight() - cell.getPaddingRight(), 0); int res = 0; try { res = t.go(true); } catch (DocumentException e) { throw new ODFConverterException(e); } if (!ColumnText.hasMoreText(res)) { // no overflow in current column if (tt.size() == 1) { // no more text return null; } else { // some text waiting for new column tt.remove(0); t = tt.get(0); } } } return tt; }
From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableDocumentSection.java
License:Open Source License
private List<ColumnText> fillTable(float height) { // copy text for simulation List<ColumnText> tt = null; if (breakHandlingParent == null && colIdx >= layoutTable.getNumberOfColumns()) { // more column breaks than available column // we try not to lose content // but results may be different than in open office // anyway it is logical error made by document creator tt = new ArrayList<ColumnText>(); ColumnText t = createColumnText(); tt.add(t);//from w ww.jav a2s.co m for (int i = 0; i < texts.size(); i++) { PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); PdfPCell cell = new PdfPCell(); cell.setBorder(Table.NO_BORDER); cell.setPadding(0.0f); cell.setColumn(ColumnText.duplicate(texts.get(i))); table.addCell(cell); t.addElement(table); } } else { tt = new ArrayList<ColumnText>(texts); for (int i = 0; i < tt.size(); i++) { tt.set(i, ColumnText.duplicate(tt.get(i))); } } // clear layout table clearTable(layoutTable, true); setWidthIfNecessary(); // try to fill cells with text ColumnText t = tt.get(0); for (PdfPCell cell : layoutTable.getRow(0).getCells()) { cell.setFixedHeight(height >= 0.0f ? height : -1.0f); cell.setColumn(ColumnText.duplicate(t)); // t.setSimpleColumn(cell.getLeft() + cell.getPaddingLeft(), height >= 0.0f ? -height : PdfPRow.BOTTOM_LIMIT, cell.getRight() - cell.getPaddingRight(), 0); int res = 0; try { res = t.go(true); } catch (DocumentException e) { throw new XWPFConverterException(e); } if (!ColumnText.hasMoreText(res)) { // no overflow in current column if (tt.size() == 1) { // no more text return null; } else { // some text waiting for new column tt.remove(0); t = tt.get(0); } } } return tt; }
From source file:fr.opensagres.xdocreport.itext.extension.ExtendedPdfPTable.java
License:Open Source License
private PdfPTable createTable(PdfPCell cell) { PdfPTable table = new PdfPTable(1); table.setSpacingBefore(this.spacingBefore()); table.setSpacingAfter(this.spacingAfter()); table.setHorizontalAlignment(this.getHorizontalAlignment()); table.setTotalWidth(cell.getPaddingLeft() + this.getTotalWidth() + cell.getPaddingRight()); table.setLockedWidth(true);/*from w ww . ja v a2 s . c om*/ table.setSplitLate(false); table.addCell(cell); return table; }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfCell.java
License:Open Source License
/** * Imports the Cell properties into the PatchRtfCell * * @param cell// w w w.j a v a2 s . c o m * The PdfPCell to import * @since 2.1.3 */ private void importCell(PdfPCell cell) { this.content = new ArrayList<RtfBasicElement>(); if (cell == null) { this.borders = new PatchRtfBorderGroup(this.document, PatchRtfBorder.CELL_BORDER, this.parentRow.getParentTable().getBorders()); return; } // padding this.cellPadding = (int) this.parentRow.getParentTable().getCellPadding(); this.cellPaddingBottom = cell.getPaddingBottom(); this.cellPaddingTop = cell.getPaddingTop(); this.cellPaddingRight = cell.getPaddingRight(); this.cellPaddingLeft = cell.getPaddingLeft(); // BORDERS this.borders = new PatchRtfBorderGroup(this.document, PatchRtfBorder.CELL_BORDER, cell.getBorder(), cell.getBorderWidth(), cell.getBorderColor()); // border colors this.border = cell.getBorder(); this.borderColor = cell.getBorderColor(); this.borderColorBottom = cell.getBorderColorBottom(); this.borderColorTop = cell.getBorderColorTop(); this.borderColorLeft = cell.getBorderColorLeft(); this.borderColorRight = cell.getBorderColorRight(); // border widths this.borderWidth = cell.getBorderWidth(); this.borderWidthBottom = cell.getBorderWidthBottom(); this.borderWidthTop = cell.getBorderWidthTop(); this.borderWidthLeft = cell.getBorderWidthLeft(); this.borderWidthRight = cell.getBorderWidthRight(); this.colspan = cell.getColspan(); this.rowspan = 1; // cell.getRowspan(); // if(cell.getRowspan() > 1) { // this.mergeType = MERGE_VERT_PARENT; // } this.verticalAlignment = cell.getVerticalAlignment(); if (cell.getBackgroundColor() == null) { this.backgroundColor = new RtfColor(this.document, 255, 255, 255); } else { this.backgroundColor = new RtfColor(this.document, cell.getBackgroundColor()); } // does it have column composite info? java.util.List compositeElements = cell.getCompositeElements(); if (compositeElements != null) { Iterator cellIterator = compositeElements.iterator(); // does it have column info? Paragraph container = null; while (cellIterator.hasNext()) { try { Element element = (Element) cellIterator.next(); // should we wrap it in a paragraph if (!(element instanceof Paragraph) && !(element instanceof List)) { if (container != null) { container.add(element); } else { container = new Paragraph(); container.setAlignment(cell.getHorizontalAlignment()); container.add(element); } } else { if (container != null) { RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(container); for (int i = 0; i < rtfElements.length; i++) { rtfElements[i].setInTable(true); this.content.add(rtfElements[i]); } container = null; } // if horizontal alignment is undefined overwrite // with that of enclosing cell if (element instanceof Paragraph && ((Paragraph) element).getAlignment() == Element.ALIGN_UNDEFINED) { ((Paragraph) element).setAlignment(cell.getHorizontalAlignment()); } RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(element); for (int i = 0; i < rtfElements.length; i++) { rtfElements[i].setInTable(true); this.content.add(rtfElements[i]); } } } catch (DocumentException de) { de.printStackTrace(); } } if (container != null) { try { RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(container); for (int i = 0; i < rtfElements.length; i++) { rtfElements[i].setInTable(true); this.content.add(rtfElements[i]); } } catch (DocumentException de) { de.printStackTrace(); } } } // does it have image info? Image img = cell.getImage(); if (img != null) { try { RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(img); for (int i = 0; i < rtfElements.length; i++) { rtfElements[i].setInTable(true); this.content.add(rtfElements[i]); } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // does it have phrase info? Phrase phrase = cell.getPhrase(); if (phrase != null) { try { RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(phrase); for (int i = 0; i < rtfElements.length; i++) { rtfElements[i].setInTable(true); this.content.add(rtfElements[i]); } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // does it have table info? PdfPTable table = cell.getTable(); if (table != null) { this.add(table); // try { // RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(table); // for (int i = 0; i < rtfElements.length; i++) { // rtfElements[i].setInTable(true); // this.content.add(rtfElements[i]); // } // } catch (DocumentException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } } }