Java Code Examples for com.lowagie.text.Paragraph#setIndentationRight()

The following examples show how to use com.lowagie.text.Paragraph#setIndentationRight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElementFactory.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Creates a Paragraph object based on a list of properties.
 * 
 * @param attributes
 * @return a Paragraph
 */
public static Paragraph getParagraph(Properties attributes) {
	Paragraph paragraph = new Paragraph(getPhrase(attributes));
	String value;
	value = attributes.getProperty(ElementTags.ALIGN);
	if (value != null) {
		paragraph.setAlignment(value);
	}
	value = attributes.getProperty(ElementTags.INDENTATIONLEFT);
	if (value != null) {
		paragraph.setIndentationLeft(Float.parseFloat(value + "f"));
	}
	value = attributes.getProperty(ElementTags.INDENTATIONRIGHT);
	if (value != null) {
		paragraph.setIndentationRight(Float.parseFloat(value + "f"));
	}
	return paragraph;
}
 
Example 2
Source File: ElementFactory.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a Paragraph object based on a list of properties.
 * @param attributes
 * @return a Paragraph
 */
public static Paragraph getParagraph(Properties attributes) {
	Paragraph paragraph = new Paragraph(getPhrase(attributes));
	String value;
	value = attributes.getProperty(ElementTags.ALIGN);
	if (value != null) {
		paragraph.setAlignment(value);
	}
	value = attributes.getProperty(ElementTags.INDENTATIONLEFT);
	if (value != null) {
		paragraph.setIndentationLeft(Float.parseFloat(value + "f"));
	}
	value = attributes.getProperty(ElementTags.INDENTATIONRIGHT);
	if (value != null) {
		paragraph.setIndentationRight(Float.parseFloat(value + "f"));
	}
	return paragraph;
}
 
Example 3
Source File: PdfRequestAndGraphDetailReport.java    From javamelody with Apache License 2.0 5 votes vote down vote up
@Override
void toPdf() throws DocumentException, IOException {
	if (request != null) {
		if (request.getRumData() != null && request.getRumData().getHits() != 0) {
			writeRequestRumData();
		}

		writeHeader();

		writeRequests();

		addTableToDocument();

		if (JdbcWrapper.SINGLETON.getSqlCounter().isRequestIdFromThisCounter(request.getId())
				&& !request.getName().toLowerCase(Locale.ENGLISH).startsWith("alter ")) {
			// inutile d'essayer d'avoir le plan d'exécution des requêtes sql
			// telles que "alter session set ..." (cf issue 152)
			writeSqlRequestExplainPlan();
		}
	}

	if (isGraphDisplayed()) {
		writeGraph();
	}

	if (request != null && request.getStackTrace() != null) {
		final Paragraph paragraph = new Paragraph("\n", cellFont);
		paragraph.setIndentationLeft(20);
		paragraph.setIndentationRight(20);
		paragraph.add(new Phrase("Stack-trace\n", boldFont));
		paragraph.add(new Phrase(request.getStackTrace().replace("\t", "        "), cellFont));
		addToDocument(paragraph);
	}
}
 
Example 4
Source File: MarkupParser.java    From MesquiteCore with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Retrieves a Paragraph based on some style attributes.
 * @param font
 * @param styleattributes a Properties object containing keys and values
 * @return an iText Paragraph object
 */
public Element retrieveParagraph(Font font, Properties styleattributes) {
	Paragraph p = new Paragraph((Phrase)retrievePhrase(font, styleattributes));
	if (styleattributes == null) return p;
	String margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGIN);
	float f;
	if (margin != null) {
		f = parseLength(margin);
		p.setIndentationLeft(f);
		p.setIndentationRight(f);
		p.setSpacingBefore(f);
		p.setSpacingAfter(f);
	}
	margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINLEFT);
	if (margin != null) {
		f = parseLength(margin);
		p.setIndentationLeft(f);
	}
	margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINRIGHT);
	if (margin != null) {
		f = parseLength(margin);
		p.setIndentationRight(f);
	}
	margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINTOP);
	if (margin != null) {
		f = parseLength(margin);
		p.setSpacingBefore(f);
	}
	margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINBOTTOM);
	if (margin != null) {
		f = parseLength(margin);
		p.setSpacingAfter(f);
	}
	String align = styleattributes.getProperty(MarkupTags.CSS_KEY_TEXTALIGN);
	if (MarkupTags.CSS_VALUE_TEXTALIGNLEFT.equals(align)) {
		p.setAlignment(Element.ALIGN_LEFT);
	}
	else if (MarkupTags.CSS_VALUE_TEXTALIGNRIGHT.equals(align)) {
		p.setAlignment(Element.ALIGN_RIGHT);
	}
	else if (MarkupTags.CSS_VALUE_TEXTALIGNCENTER.equals(align)) {
		p.setAlignment(Element.ALIGN_CENTER);
	}
	else if (MarkupTags.CSS_VALUE_TEXTALIGNJUSTIFY.equals(align)) {
		p.setAlignment(Element.ALIGN_JUSTIFIED);
	}
	return p;
}
 
Example 5
Source File: DocStyleUtils.java    From DWSurvey with GNU Affero General Public License v3.0 3 votes vote down vote up
/** 
 * 功能说明:设置段落的样式</BR> 
 * 修改日期:2011-04-27 
 * @author myclover 
 * @param content  段落的内容 
 * @param font     字体的样式 
 * @param firstLineIndent  首行缩进多少字符,16f约等于一个字符 
 * @param leading  行间距 
 * @param indentationRight 缩进样式中的文本之后多少毫米,0.6f相当于0.2毫米 
 * @param alignment 对齐方式 
 * @return 
 */  
public static Paragraph setParagraphStyle(String content , Font font , float firstLineIndent , float leading , float indentationRight , int alignment){  
    Paragraph par = new Paragraph(content, font);  
    par.setFirstLineIndent(firstLineIndent);  
    par.setLeading(leading);  
    par.setIndentationRight(indentationRight);  
    par.setAlignment(alignment);  
    return par;  
}