本文整理了Java中com.itextpdf.text.Phrase.add()
方法的一些代码示例,展示了Phrase.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Phrase.add()
方法的具体详情如下:
包路径:com.itextpdf.text.Phrase
类名称:Phrase
方法名:add
[英]Adds a Chunk
, an Anchor
or another Phrase
to this Phrase
.
[中]向该Phrase
添加Chunk
、Anchor
或另一个Phrase
。
代码示例来源:origin: com.itextpdf/itextpdf
/**
* Adds a collection of <CODE>Chunk</CODE>s
* to this <CODE>Phrase</CODE>.
*
* @param collection a collection of <CODE>Chunk</CODE>s, <CODE>Anchor</CODE>s and <CODE>Phrase</CODE>s.
* @return <CODE>true</CODE> if the action succeeded, <CODE>false</CODE> if not.
* @throws ClassCastException when you try to add something that isn't a <CODE>Chunk</CODE>, <CODE>Anchor</CODE> or <CODE>Phrase</CODE>
*/
@Override
public boolean addAll(final Collection<? extends Element> collection) {
for (Element e: collection) {
this.add(e);
}
return true;
}
代码示例来源:origin: com.itextpdf/itextpdf
/**
* Adds an <CODE>Element</CODE> to the <CODE>Paragraph</CODE>.
*
* @param o the element to add.
* @return true is adding the object succeeded
*/
@Override
public boolean add(Element o) {
if (o instanceof List) {
List list = (List) o;
list.setIndentationLeft(list.getIndentationLeft() + indentationLeft);
list.setIndentationRight(indentationRight);
return super.add(list);
}
else if (o instanceof Image) {
super.addSpecial(o);
return true;
}
else if (o instanceof Paragraph) {
super.addSpecial(o);
return true;
}
return super.add(o);
}
代码示例来源:origin: com.itextpdf/itextpdf
success &= this.add(e);
代码示例来源:origin: com.itextpdf/itextg
/**
* Adds a collection of <CODE>Chunk</CODE>s
* to this <CODE>Phrase</CODE>.
*
* @param collection a collection of <CODE>Chunk</CODE>s, <CODE>Anchor</CODE>s and <CODE>Phrase</CODE>s.
* @return <CODE>true</CODE> if the action succeeded, <CODE>false</CODE> if not.
* @throws ClassCastException when you try to add something that isn't a <CODE>Chunk</CODE>, <CODE>Anchor</CODE> or <CODE>Phrase</CODE>
*/
@Override
public boolean addAll(final Collection<? extends Element> collection) {
for (Element e: collection) {
this.add(e);
}
return true;
}
代码示例来源:origin: com.itextpdf/itextg
/**
* Adds an <CODE>Element</CODE> to the <CODE>Paragraph</CODE>.
*
* @param o the element to add.
* @return true is adding the object succeeded
*/
@Override
public boolean add(Element o) {
if (o instanceof List) {
List list = (List) o;
list.setIndentationLeft(list.getIndentationLeft() + indentationLeft);
list.setIndentationRight(indentationRight);
return super.add(list);
}
else if (o instanceof Image) {
super.addSpecial(o);
return true;
}
else if (o instanceof Paragraph) {
super.addSpecial(o);
return true;
}
return super.add(o);
}
代码示例来源:origin: com.itextpdf/itextg
success &= this.add(e);
代码示例来源:origin: com.itextpdf/itextg
/**
* Process the text so that it will render with a combination of fonts
* if needed.
* @param text the text
* @return a <CODE>Phrase</CODE> with one or more chunks
*/
public Phrase process(String text) {
if (fonts.size() == 0)
throw new IndexOutOfBoundsException(MessageLocalization.getComposedMessage("no.font.is.defined"));
char cc[] = text.toCharArray();
int len = cc.length;
StringBuffer sb = new StringBuffer();
Phrase ret = new Phrase();
currentFont = null;
for (int k = 0; k < len; ++k) {
Chunk newChunk = processChar(cc, k, sb);
if (newChunk != null) {
ret.add(newChunk);
}
}
if (sb.length() > 0) {
Chunk ck = new Chunk(sb.toString(), currentFont != null ? currentFont : fonts.get(0));
ret.add(ck);
}
return ret;
}
代码示例来源:origin: com.itextpdf/itextpdf
/**
* Process the text so that it will render with a combination of fonts
* if needed.
* @param text the text
* @return a <CODE>Phrase</CODE> with one or more chunks
*/
public Phrase process(String text) {
if (getSize() == 0)
throw new IndexOutOfBoundsException(MessageLocalization.getComposedMessage("no.font.is.defined"));
char cc[] = text.toCharArray();
int len = cc.length;
StringBuffer sb = new StringBuffer();
Phrase ret = new Phrase();
currentFont = null;
for (int k = 0; k < len; ++k) {
Chunk newChunk = processChar(cc, k, sb);
if (newChunk != null) {
ret.add(newChunk);
}
}
if (sb.length() > 0) {
Chunk ck = new Chunk(sb.toString(), currentFont != null ? currentFont : getFont(0));
ret.add(ck);
}
return ret;
}
代码示例来源:origin: com.itextpdf/itextg
if (index > 0) {
String firstPart = string.substring(0, index);
p.add(new Chunk(firstPart, font));
string = string.substring(index);
string = string.substring(1);
p.add(new Chunk(buf.toString(), symbol));
p.add(new Chunk(string, font));
代码示例来源:origin: com.itextpdf/itextpdf
if (index > 0) {
String firstPart = string.substring(0, index);
p.add(new Chunk(firstPart, font));
string = string.substring(index);
string = string.substring(1);
p.add(new Chunk(buf.toString(), symbol));
p.add(new Chunk(string, font));
代码示例来源:origin: timurstrekalov/saga
private void addFileStatsRows(final TestRunCoverageStatistics runStats, final PdfPTable table) {
final List<ScriptCoverageStatistics> allFileStats = runStats.getFileStats();
for (int i = 0; i < allFileStats.size(); i++) {
final ScriptCoverageStatistics scriptCoverageStatistics = allFileStats.get(i);
final boolean hasStatements = scriptCoverageStatistics.getHasStatements();
final Phrase fileName = new Phrase();
if (scriptCoverageStatistics.getParentName() != null) {
fileName.add(new Chunk(scriptCoverageStatistics.getParentName() + "/", hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE));
fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD_BOLD : FONT_TD_BOLD_EMPTY_FILE));
} else {
fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE));
}
final BaseColor bgColor = (i % 2 == 1) ? COLOR_ROW_ODD : COLOR_ROW_EVEN;
final Font font = FONT_TD;
table.addCell(createCell(fileName, 0, bgColor));
table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getStatements()), font, 1, bgColor));
table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getExecuted()), font, 2, bgColor));
table.addCell(createCell(scriptCoverageStatistics.getCoverage() + "%", FONT_TD, 3, bgColor));
}
}
代码示例来源:origin: com.centurylink.mdw/mdw-common
private void printVariables(Chapter chapter, List<Variable> variables, int parentLevel) {
Paragraph sTitle = new Paragraph("Process Variables", sectionFont);
Section section = chapter.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1));
com.itextpdf.text.List list = new com.itextpdf.text.List(false, false, 10.0f);
for (Variable var : variables) {
Phrase phrase = new Phrase();
phrase.add(new Chunk(var.getName(), fixedWidthFont));
String v = var.getType();
if (var.getDescription() != null)
v += " (" + var.getDescription() + ")";
phrase.add(new Chunk(": " + v + "\n", normalFont));
list.add(new ListItem(phrase));
}
section.add(list);
}
代码示例来源:origin: com.centurylink.mdw/mdw-common
private void printAttributes(Section section, List<Attribute> attrs, int parentLevel) {
Paragraph sTitle = new Paragraph("Activity Attributes", subSectionFont);
Section subsection = section.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1));
com.itextpdf.text.List list = new com.itextpdf.text.List(false, false, 20.0f);
for (Attribute attr : attrs) {
if (excludeAttribute(attr.getAttributeName(), attr.getAttributeValue()))
continue;
Phrase phrase = new com.itextpdf.text.Phrase();
phrase.add(new Chunk(attr.getAttributeName(), fixedWidthFont));
String v = attr.getAttributeValue();
if (v == null)
v = "";
phrase.add(new Chunk(": " + v, normalFont));
list.add(new ListItem(phrase));
}
subsection.add(list);
}
内容来源于网络,如有侵权,请联系作者删除!