List of usage examples for com.lowagie.text Element ALIGN_JUSTIFIED_ALL
int ALIGN_JUSTIFIED_ALL
To view the source code for com.lowagie.text Element ALIGN_JUSTIFIED_ALL.
Click Source Link
From source file:net.sf.jasperreports.engine.export.AbstractPdfTextRenderer.java
License:Open Source License
/** * /* w w w . ja v a 2s .c o m*/ */ public void initialize(JRPdfExporter pdfExporter, PdfContentByte pdfContentByte, JRPrintText text, int offsetX, int offsetY) { this.pdfExporter = pdfExporter; this.pdfContentByte = pdfContentByte; horizontalAlignment = Element.ALIGN_LEFT; leftOffsetFactor = 0f; rightOffsetFactor = 0f; //FIXMETAB 0.2f was a fair approximation switch (text.getHorizontalAlignmentValue()) { case JUSTIFIED: { horizontalAlignment = Element.ALIGN_JUSTIFIED_ALL; leftOffsetFactor = 0f; rightOffsetFactor = 0f; break; } case RIGHT: { if (text.getRunDirectionValue() == RunDirectionEnum.LTR) { horizontalAlignment = Element.ALIGN_RIGHT; } else { horizontalAlignment = Element.ALIGN_LEFT; } leftOffsetFactor = -0.2f; rightOffsetFactor = 0f; break; } case CENTER: { horizontalAlignment = Element.ALIGN_CENTER; leftOffsetFactor = -0.1f; rightOffsetFactor = 0.1f; break; } case LEFT: default: { if (text.getRunDirectionValue() == RunDirectionEnum.LTR) { horizontalAlignment = Element.ALIGN_LEFT; } else { horizontalAlignment = Element.ALIGN_RIGHT; } leftOffsetFactor = 0f; rightOffsetFactor = 0.2f; break; } } super.initialize(text, offsetX, offsetY); }
From source file:net.sf.jasperreports.engine.export.SimplePdfTextRenderer.java
License:Open Source License
/** * /* w ww .j ava2 s . c o m*/ */ public void render() { ColumnText colText = new ColumnText(pdfContentByte); colText.setSimpleColumn(getPhrase(styledText, text), x + leftPadding, pdfExporter.getCurrentJasperPrint().getPageHeight() - y - topPadding - verticalAlignOffset - text.getLeadingOffset(), //+ text.getLineSpacingFactor() * text.getFont().getSize(), x + width - rightPadding, pdfExporter.getCurrentJasperPrint().getPageHeight() - y - height + bottomPadding, 0, //text.getLineSpacingFactor(),// * text.getFont().getSize(), horizontalAlignment == Element.ALIGN_JUSTIFIED_ALL ? Element.ALIGN_JUSTIFIED : horizontalAlignment); colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize()); colText.setRunDirection(text.getRunDirectionValue() == RunDirectionEnum.LTR ? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_RTL); try { colText.go(); } catch (DocumentException e) { throw new JRRuntimeException(e); } }
From source file:open.dolphin.hiro.PrescriptionPDFMaker.java
/** * ?? * ? * @param pcell */ private void setAlignJustifiedAll(PdfPCell pcell) { pcell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfRow.java
License:Open Source License
/** * Writes the row definition/settings./* w w w .ja va 2s .c o m*/ * * @param result * The <code>OutputStream</code> to write the definitions to. */ private void writeRowDefinition(final OutputStream result) throws IOException { result.write(ROW_BEGIN); this.document.outputDebugLinebreak(result); result.write(ROW_WIDTH_STYLE); result.write(ROW_WIDTH); result.write(intToByteArray(this.width)); if (this.parentTable.getCellsFitToPage()) { result.write(ROW_KEEP_TOGETHER); } float minHeightInTwips = 0; for (int i = 0; i < this.cells.size(); i++) { PatchRtfCell rtfCell = this.cells.get(i); minHeightInTwips = Math.max(minHeightInTwips, rtfCell.getMinimumHeight()); } result.write(ROW_HEIGHT); result.write(intToByteArray((int) (minHeightInTwips * 20))); if (this.rowNumber <= this.parentTable.getHeaderRows()) { result.write(ROW_HEADER_ROW); } switch (this.parentTable.getAlignment()) { case Element.ALIGN_LEFT: result.write(ROW_ALIGN_LEFT); break; case Element.ALIGN_RIGHT: result.write(ROW_ALIGN_RIGHT); break; case Element.ALIGN_CENTER: result.write(ROW_ALIGN_CENTER); break; case Element.ALIGN_JUSTIFIED: case Element.ALIGN_JUSTIFIED_ALL: result.write(ROW_ALIGN_JUSTIFIED); break; } result.write(ROW_GRAPH); PatchRtfBorderGroup borders = this.parentTable.getBorders(); if (borders != null) { borders.writeContent(result); } if (this.parentTable.getCellSpacing() > 0) { result.write(ROW_CELL_SPACING_LEFT); result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2))); result.write(ROW_CELL_SPACING_LEFT_STYLE); result.write(ROW_CELL_SPACING_TOP); result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2))); result.write(ROW_CELL_SPACING_TOP_STYLE); result.write(ROW_CELL_SPACING_RIGHT); result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2))); result.write(ROW_CELL_SPACING_RIGHT_STYLE); result.write(ROW_CELL_SPACING_BOTTOM); result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2))); result.write(ROW_CELL_SPACING_BOTTOM_STYLE); } result.write(ROW_CELL_PADDING_LEFT); result.write(intToByteArray((int) (this.parentTable.getCellPadding() / 2))); result.write(ROW_CELL_PADDING_RIGHT); result.write(intToByteArray((int) (this.parentTable.getCellPadding() / 2))); result.write(ROW_CELL_PADDING_LEFT_STYLE); result.write(ROW_CELL_PADDING_RIGHT_STYLE); this.document.outputDebugLinebreak(result); for (int i = 0; i < this.cells.size(); i++) { PatchRtfCell rtfCell = this.cells.get(i); rtfCell.writeDefinition(result); } }