List of usage examples for com.lowagie.text Element ALIGN_JUSTIFIED
int ALIGN_JUSTIFIED
To view the source code for com.lowagie.text Element ALIGN_JUSTIFIED.
Click Source Link
From source file:org.odftoolkit.odfdom.converter.internal.itext.StyleEngineForIText.java
License:Open Source License
@Override public void visit(StyleParagraphPropertiesElement ele) { StyleParagraphProperties paragraphProperties = currentStyle.getParagraphProperties(); if (paragraphProperties == null) { paragraphProperties = new StyleParagraphProperties(); currentStyle.setParagraphProperties(paragraphProperties); }//from w w w . j ava2 s . c om // background-color String backgroundColor = ele.getFoBackgroundColorAttribute(); if (StringUtils.isNotEmpty(backgroundColor)) { paragraphProperties.setBackgroundColor(ColorRegistry.getInstance().getColor(backgroundColor)); } // border String border = ele.getFoBorderAttribute(); if (StringUtils.isNotEmpty(border)) { paragraphProperties.setBorder(new StyleBorder(border, BorderType.ALL)); } // border-bottom String borderBottom = ele.getFoBorderBottomAttribute(); if (StringUtils.isNotEmpty(borderBottom)) { paragraphProperties.setBorderBottom(new StyleBorder(borderBottom, BorderType.BOTTOM)); } // border-left String borderLeft = ele.getFoBorderLeftAttribute(); if (StringUtils.isNotEmpty(borderLeft)) { paragraphProperties.setBorderLeft(new StyleBorder(borderLeft, BorderType.LEFT)); } // border-bottom String borderRight = ele.getFoBorderRightAttribute(); if (StringUtils.isNotEmpty(borderRight)) { paragraphProperties.setBorderRight(new StyleBorder(borderRight, BorderType.RIGHT)); } // border-top String borderTop = ele.getFoBorderTopAttribute(); if (StringUtils.isNotEmpty(borderTop)) { paragraphProperties.setBorderTop(new StyleBorder(borderTop, BorderType.TOP)); } // line-height String lineHeight = ele.getFoLineHeightAttribute(); if (StringUtils.isNotEmpty(lineHeight)) { paragraphProperties.setLineHeight(new StyleLineHeight(ODFUtils.getDimensionAsPoint(lineHeight), ODFUtils.hasPercentUnit(lineHeight))); } // margin String margin = ele.getFoMarginAttribute(); if (StringUtils.isNotEmpty(margin)) { paragraphProperties.setMargin(ODFUtils.getDimensionAsPoint(margin)); } // margin-bottom String marginBottom = ele.getFoMarginBottomAttribute(); if (StringUtils.isNotEmpty(marginBottom)) { paragraphProperties.setMarginBottom(ODFUtils.getDimensionAsPoint(marginBottom)); } // margin-left String marginLeft = ele.getFoMarginLeftAttribute(); if (StringUtils.isNotEmpty(marginLeft)) { paragraphProperties.setMarginLeft(ODFUtils.getDimensionAsPoint(marginLeft)); } // margin-right String marginRight = ele.getFoMarginRightAttribute(); if (StringUtils.isNotEmpty(marginRight)) { paragraphProperties.setMarginRight(ODFUtils.getDimensionAsPoint(marginRight)); } // margin-top String marginTop = ele.getFoMarginTopAttribute(); if (StringUtils.isNotEmpty(marginTop)) { paragraphProperties.setMarginTop(ODFUtils.getDimensionAsPoint(marginTop)); } // padding String padding = ele.getFoPaddingAttribute(); if (StringUtils.isNotEmpty(padding)) { // cssStyleSheet.setCSSProperty("padding", padding); } // padding-bottom String paddingBottom = ele.getFoPaddingBottomAttribute(); if (StringUtils.isNotEmpty(paddingBottom)) { // cssStyleSheet.setCSSProperty("padding-bottom", paddingBottom); } // padding-left String paddingLeft = ele.getFoPaddingLeftAttribute(); if (StringUtils.isNotEmpty(paddingLeft)) { // cssStyleSheet.setCSSProperty("padding-left", paddingLeft); } // padding-bottom String paddingRight = ele.getFoPaddingRightAttribute(); if (StringUtils.isNotEmpty(paddingRight)) { // cssStyleSheet.setCSSProperty("padding-right", paddingRight); } // padding-top String paddingTop = ele.getFoPaddingTopAttribute(); if (StringUtils.isNotEmpty(paddingTop)) { // cssStyleSheet.setCSSProperty("padding-top", paddingTop); } // text-align String textAlign = ele.getFoTextAlignAttribute(); if (StringUtils.isNotEmpty(textAlign)) { int alignment = Element.ALIGN_UNDEFINED; if ("start".equals(textAlign)) { alignment = Element.ALIGN_LEFT; } else if ("end".equals(textAlign)) { alignment = Element.ALIGN_RIGHT; } else if ("left".equals(textAlign)) { alignment = Element.ALIGN_LEFT; } else if ("right".equals(textAlign)) { alignment = Element.ALIGN_RIGHT; } else if ("center".equals(textAlign)) { alignment = Element.ALIGN_CENTER; } else if ("justify".equals(textAlign)) { alignment = Element.ALIGN_JUSTIFIED; } paragraphProperties.setAlignment(alignment); } // auto-text-indent Boolean autoTextIndent = ele.getStyleAutoTextIndentAttribute(); if (autoTextIndent != null) { paragraphProperties.setAutoTextIndent(autoTextIndent); } // text-indent String textIndent = ele.getFoTextIndentAttribute(); if (StringUtils.isNotEmpty(textIndent)) { paragraphProperties.setTextIndent(ODFUtils.getDimensionAsPoint(textIndent)); } // keep-together String keepTogether = ele.getFoKeepTogetherAttribute(); if (StringUtils.isNotEmpty(keepTogether)) { if (FoKeepTogetherAttribute.Value.ALWAYS.toString().equals(keepTogether)) { paragraphProperties.setKeepTogether(Boolean.TRUE); } else { paragraphProperties.setKeepTogether(Boolean.FALSE); } } // fo:break-before String breakBefore = ele.getFoBreakBeforeAttribute(); if (StringUtils.isNotEmpty(breakBefore)) { if (FoBreakBeforeAttribute.Value.PAGE.toString().equals(breakBefore)) { paragraphProperties.setBreakBefore(StyleBreak.createWithPageBreak()); } else if (FoBreakBeforeAttribute.Value.COLUMN.toString().equals(breakBefore)) { paragraphProperties.setBreakBefore(StyleBreak.createWithColumnBreak()); } else { paragraphProperties.setBreakBefore(StyleBreak.createWithNoBreak()); } } super.visit(ele); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java
License:Open Source License
private int mapAlignment(final RenderableComplexText node) { ElementAlignment alignment;// w w w .j av a 2s . c o m if (node.getNext() == null) { alignment = paragraphContext.getLastLineAlignment(); } else { alignment = paragraphContext.getTextAlignment(); } if (ElementAlignment.LEFT.equals(alignment)) { return Element.ALIGN_LEFT; } else if (ElementAlignment.RIGHT.equals(alignment)) { return Element.ALIGN_RIGHT; } else if (ElementAlignment.CENTER.equals(alignment)) { return Element.ALIGN_CENTER; } else { return Element.ALIGN_JUSTIFIED; } }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.helper.RTFPrinter.java
License:Open Source License
private void computeCellStyle(final RenderBox content, final Cell cell) { final ElementAlignment verticalAlign = content.getNodeLayoutProperties().getVerticalAlignment(); if (ElementAlignment.BOTTOM.equals(verticalAlign)) { cell.setVerticalAlignment(Element.ALIGN_BOTTOM); } else if (ElementAlignment.MIDDLE.equals(verticalAlign)) { cell.setVerticalAlignment(Element.ALIGN_MIDDLE); } else {// w w w . ja v a 2 s . c o m cell.setVerticalAlignment(Element.ALIGN_TOP); } final ElementAlignment textAlign = (ElementAlignment) content.getStyleSheet() .getStyleProperty(ElementStyleKeys.ALIGNMENT); if (ElementAlignment.RIGHT.equals(textAlign)) { cell.setHorizontalAlignment(Element.ALIGN_RIGHT); } else if (ElementAlignment.JUSTIFY.equals(textAlign)) { cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); } else if (ElementAlignment.CENTER.equals(textAlign)) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); } else { cell.setHorizontalAlignment(Element.ALIGN_LEFT); } }
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.//from w ww. ja v a2 s . 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); } }
From source file:org.pz.platypus.plugin.pdf.PdfOutfile.java
License:Open Source License
/** * Implement the paragraph alignment/*from w ww . j a v a 2 s .c o m*/ * * @param para the paragraph to align * @param pData the PdfData container holding the current settings of the PDF output */ void doParagraphAlignment(final Paragraph para, final PdfData pData) { switch (pData.getAlignment()) { case Alignment.CENTER: para.setAlignment(Element.ALIGN_CENTER); break; case Alignment.JUST: para.setAlignment(Element.ALIGN_JUSTIFIED); break; case Alignment.LEFT: para.setAlignment(Element.ALIGN_LEFT); break; case Alignment.RIGHT: para.setAlignment(Element.ALIGN_RIGHT); break; default: // ignore in case of other possibility break; } }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private Paragraph getObjectDescription() { Paragraph p = new Paragraph(); p.setLeading(0, 1.2f);/*from w w w.ja v a2 s. co m*/ p.setAlignment(Element.ALIGN_JUSTIFIED); p.setSpacingAfter(10); p.setSpacingBefore(50); if (o.getDescription() != null) { p.add(new Chunk(o.getDescription(), bodyFont)); } else { p.add(new Chunk("No description recorded", bodyFont)); } return p; }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private Paragraph getObjectComments() { Paragraph p = new Paragraph(); p.setLeading(0, 1.2f);/*from w w w .ja v a 2 s .com*/ p.setAlignment(Element.ALIGN_JUSTIFIED); p.setSpacingAfter(10); if (o.getComments() != null) { p.add(new Chunk("Notes: ", commentFont)); p.add(new Chunk(o.getComments(), commentFont)); } return p; }
From source file:questions.compression.CompressionLevelsWriter.java
public static void createPdf(int compressionLevel) { try {//from www . j a va 2 s . c o m Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT[compressionLevel + 1])); writer.setCompressionLevel(compressionLevel); document.open(); BufferedReader reader = new BufferedReader(new FileReader(RESOURCE)); String line; Paragraph p; while ((line = reader.readLine()) != null) { p = new Paragraph(line); p.setAlignment(Element.ALIGN_JUSTIFIED); document.add(p); document.add(Chunk.NEWLINE); } reader.close(); document.close(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:questions.objects.DifferentLeadings.java
public static void main(String[] args) { Document document = new Document(PageSize.A7); try {//from w w w . j a va 2 s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open(); Chunk space = new Chunk(' '); String text = "Quick brown fox jumps over the lazy dog."; Phrase phrase1 = new Phrase(text, new Font(Font.HELVETICA, 12)); Phrase phrase2 = new Phrase(new Chunk(text, new Font(Font.TIMES_ROMAN, 24))); Phrase phrase3 = new Phrase(text, new Font(Font.COURIER, 8)); Phrase phrase4 = new Phrase(text, new Font(Font.HELVETICA, 4)); Paragraph paragraph = new Paragraph(); paragraph.add(phrase1); paragraph.add(space); paragraph.add(phrase2); paragraph.add(space); paragraph.add(phrase3); paragraph.add(space); paragraph.add(phrase4); paragraph.setMultipliedLeading(1.5f); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); ColumnText column = new ColumnText(writer.getDirectContent()); column.setSimpleColumn(document.left(), document.bottom(), document.right(), document.top()); column.addElement(paragraph); column.go(); document.newPage(); document.add(paragraph); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:questions.separators.DottedGlue.java
public static void main(String[] args) { Document document = new Document(); try {//www. j av a 2 s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open(); PdfContentByte canvas = writer.getDirectContent(); canvas.moveTo(document.left(), document.top()); canvas.lineTo(document.left(), 550); canvas.moveTo(document.right(), document.top()); canvas.lineTo(document.right(), 550); canvas.stroke(); Chunk separator = new Chunk(new DottedLineSeparator()); // two parts Paragraph p1 = new Paragraph(); p1.add(new Chunk("Chapter 1")); p1.add(separator); p1.add(new Chunk("p 10")); // 3 parts Paragraph p2 = new Paragraph(); p2.add(new Chunk("Chapter 2")); p2.add(separator); p2.add(new Chunk("x")); p2.add(separator); p2.add(new Chunk("y")); // line ends with separator Paragraph p3 = new Paragraph(); p3.add(new Chunk("Chapter 3")); p3.add(separator); // line starts with a separator Paragraph p4 = new Paragraph(); p4.add(separator); p4.add(new Chunk("chapter 4")); // line IS a separator Paragraph p5 = new Paragraph(); p5.add(separator); // line IS a separator + leading Paragraph p6 = new Paragraph(40); p6.add(separator); // separator galore Paragraph p7 = new Paragraph(); p7.setAlignment(Element.ALIGN_JUSTIFIED); for (int i = 0; i < 10; i++) { p7.add(new Chunk("This is a test hippopotamus hippopotamus")); if (i % 4 == 0) p7.add(" hippopotamus hippopotamus hippopotamus hippopotamus"); p7.add(separator); } document.add(p1); document.add(p1); document.add(p2); document.add(p3); document.add(p4); document.add(p5); document.add(p6); document.add(p7); ColumnText ct = new ColumnText(writer.getDirectContent()); ct.addElement(p1); ct.addElement(p1); ct.addElement(p2); ct.addElement(p3); ct.addElement(p4); ct.addElement(p5); ct.addElement(p6); ct.addElement(p7); ct.setSimpleColumn(36, 36, 436, 536); ct.go(); canvas.rectangle(36, 36, 400, 500); canvas.stroke(); document.close(); } catch (Exception de) { de.printStackTrace(); } }