本文整理了Java中com.itextpdf.text.Paragraph.add()
方法的一些代码示例,展示了Paragraph.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Paragraph.add()
方法的具体详情如下:
包路径:com.itextpdf.text.Paragraph
类名称:Paragraph
方法名:add
[英]Adds an Element
to the Paragraph
.
[中]将Element
添加到Paragraph
。
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext5.extension
public void addElement( Element element )
{
// in function add(Element element) chunks are cloned
// it is not correct for chunks with dynamic content (ie page number)
// use function add(int index, Element element) because in this function chunks are added without cloning
super.add( size(), element );
}
代码示例来源:origin: org.technbolts.tzatziki/tzatziki-pdf
public static Paragraph formatStep(StepExec step, boolean includeKeyword, Styles styles, ITextContext emitterContext) {
Font stepKeywordFont = styles.getFontOrDefault(STEP_KEYWORD_FONT);
Font stepPhraseFont = styles.getFontOrDefault(STEP_PHRASE_FONT);
Font stepParamFont = styles.getFontOrDefault(STEP_PARAMETER_FONT);
Paragraph pPhrase = new Paragraph();
if (includeKeyword) {
pPhrase.add(new Chunk(step.keyword(), stepKeywordFont));
pPhrase.add(new Chunk(" "));
}
if (!step.isMatching()) {
pPhrase.add(new Chunk(step.name(), stepPhraseFont));
} else {
for (StepExec.Tok tok : step.tokenizeBody()) {
Font tokFont = stepPhraseFont;
if (tok.param)
tokFont = stepParamFont;
List<Element> richText = emitterContext.emitButCollectElements(new RichText(tok.value, tokFont));
pPhrase.addAll(richText);
}
}
return pPhrase;
}
代码示例来源:origin: timurstrekalov/saga
private Element createFooter() {
final Paragraph footer = new Paragraph();
footer.add(new Phrase("Generated using ", FONT_FOOTER));
final Anchor a = new Anchor(config.getProperty("app.name"), FONT_FOOTER);
a.setReference("http://timurstrekalov.github.com/saga/");
footer.add(a);
footer.add(new Phrase(" version " + config.getProperty("app.version"), FONT_FOOTER));
footer.setAlignment(Element.ALIGN_RIGHT);
return footer;
}
代码示例来源:origin: com.itextpdf/itextpdf
/**
* Adds a new line to the currentParagraph.
* @since 5.0.6
*/
public void newLine() {
if (currentParagraph == null) {
currentParagraph = new Paragraph();
}
currentParagraph.add(createChunk("\n"));
}
代码示例来源:origin: com.itextpdf/itextg
/**
* Adds a new line to the currentParagraph.
* @since 5.0.6
*/
public void newLine() {
if (currentParagraph == null) {
currentParagraph = new Paragraph();
}
currentParagraph.add(createChunk("\n"));
}
代码示例来源:origin: com.itextpdf/itextpdf
/**
* @see com.itextpdf.text.xml.simpleparser.SimpleXMLDocHandler#text(java.lang.String)
*/
public void text(String content) {
if (skipText)
return;
if (currentParagraph == null) {
currentParagraph = createParagraph();
}
if (!insidePRE) {
// newlines and carriage returns are ignored
if (content.trim().length() == 0 && content.indexOf(' ') < 0) {
return;
}
content = HtmlUtilities.eliminateWhiteSpace(content);
}
Chunk chunk = createChunk(content);
currentParagraph.add(chunk);
}
代码示例来源:origin: com.itextpdf/itextg
/**
* @see com.itextpdf.text.xml.simpleparser.SimpleXMLDocHandler#text(java.lang.String)
*/
public void text(String content) {
if (skipText)
return;
if (currentParagraph == null) {
currentParagraph = createParagraph();
}
if (!insidePRE) {
// newlines and carriage returns are ignored
if (content.trim().length() == 0 && content.indexOf(' ') < 0) {
return;
}
content = HtmlUtilities.eliminateWhiteSpace(content);
}
Chunk chunk = createChunk(content);
currentParagraph.add(chunk);
}
代码示例来源:origin: org.technbolts/gutenberg
private void appendSubject(ITextContext context, Paragraph preface) {
if (StringUtils.isEmpty(subject)) {
return;
}
Styles styles = context.styles();
Font font = styles.getFont(FIRST_PAGE_SUBJECT_FONT).or(subjectFont(styles));
for (String titlePart : subject.split("[\n\r]+")) {
Paragraph paragraph = new Paragraph(titlePart, font);
paragraph.setAlignment(Element.ALIGN_RIGHT);
paragraph.setSpacingAfter(15.0f);
preface.add(paragraph);
}
}
代码示例来源:origin: org.technbolts.tzatziki/tzatziki-pdf
protected Paragraph formatTitle(int headerLevel, ITextContext emitterContext, BackgroundExec background) {
Styles styles = emitterContext.styles();
Font font = styles.sectionTitleFontForLevel(headerLevel + 1);
Paragraph p = new Paragraph();
p.add(new Chunk(background.name(), font));
p.add(new Chunk(" (", font));
p.add(new Chunk(background.keyword(), new FontCopier(font).italic().color(styles.getColor(KEYWORD_COLOR).or(BaseColor.LIGHT_GRAY)).get()));
p.add(new Chunk(")", font));
return p;
}
代码示例来源:origin: com.centurylink.mdw/mdw-common
private void printHtmlParagraphs(Section section, String content, int parentLevel)
throws Exception {
if (content == null || content.length() == 0)
return;
Paragraph comb = new Paragraph();
ElementList list = XMLWorkerHelper.parseToElementList(content, null);
for (Element element : list) {
comb.add(element);
}
section.add(comb);
section.add(new Paragraph("\n", normalFont));
}
}
代码示例来源:origin: org.technbolts/gutenberg
private void appendTitle(ITextContext context, Paragraph preface) {
if (StringUtils.isEmpty(title)) {
return;
}
Styles styles = context.styles();
Font font = styles.getFont(FIRST_PAGE_TITLE_FONT).or(titleFont(styles));
Paragraph paragraph = null;
for (String titlePart : title.split("[\n\r]+")) {
paragraph = new Paragraph(titlePart, font);
paragraph.setAlignment(Element.ALIGN_RIGHT);
paragraph.setSpacingAfter(15.0f);
preface.add(paragraph);
}
if (paragraph != null) {
paragraph.setSpacingAfter(30.0f);
}
}
代码示例来源:origin: com.github.dandelion/datatables-export-itext
private void addTitle(Document document) throws DocumentException {
Paragraph title = new Paragraph(exportConf.getFileName());
title.add(new Paragraph(" ")); // empty line
title.setAlignment(Element.ALIGN_CENTER);
document.add(title);
}
代码示例来源:origin: dandelion/dandelion-datatables
private void addTitle(Document document) throws DocumentException {
Paragraph title = new Paragraph(exportConf.getFileName());
title.add(new Paragraph(" ")); // empty line
title.setAlignment(Element.ALIGN_CENTER);
document.add(title);
}
代码示例来源:origin: com.itextpdf/itextg
/**
* Processes an Image.
* @param img
* @param attrs
* @throws DocumentException
* @since 5.0.6
*/
public void processImage(final Image img, final Map<String, String> attrs) throws DocumentException {
ImageProcessor processor = (ImageProcessor)providers.get(HTMLWorker.IMG_PROCESSOR);
if (processor == null || !processor.process(img, attrs, chain, document)) {
String align = attrs.get(HtmlTags.ALIGN);
if (align != null) {
carriageReturn();
}
if (currentParagraph == null) {
currentParagraph = createParagraph();
}
currentParagraph.add(new Chunk(img, 0, 0, true));
currentParagraph.setAlignment(HtmlUtilities.alignmentValue(align));
if (align != null) {
carriageReturn();
}
}
}
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext5.extension
public static Paragraph constructTitle( IParagraphFactory factory, Paragraph ancestorTitle, ArrayList numbers,
int numberDepth, int numberStyle, PdfPCell cell )
{
if ( ancestorTitle != null && cell != null )
{
Paragraph newTitle = factory.createParagraph();
PdfPTable table = new PdfPTable( 1 );
table.setWidthPercentage( 100f );
cell.addElement( ancestorTitle );
table.addCell( cell );
newTitle.add( table );
return newTitle;
}
return ancestorTitle;
}
代码示例来源:origin: org.technbolts/gutenberg
@Override
public void process(int level, Node node, InvocationContext context) {
List<Element> subs = context.collectChildren(level, node);
Paragraph p = new Paragraph();
for (Element sub : subs) {
p.add(discardNewline(sub));
}
KeyValues kvs = context.iTextContext().keyValues();
Float spacingBefore = kvs.<Float>getNullable(PARAGRAPH_SPACING_BEFORE).or(5f);
Float spacingAfter = kvs.<Float>getNullable(PARAGRAPH_SPACING_AFTER).or(5f);
p.setSpacingBefore(spacingBefore);
p.setSpacingAfter(spacingAfter);
applyAttributes(context, p);
context.append(p);
}
代码示例来源:origin: org.technbolts.tzatziki/tzatziki-pdf
@Override
public void emit(Tags tagContainer, ITextContext emitterContext) {
FluentIterable<String> tags = tagContainer.tags();
if (tags.isEmpty())
return;
Styles styles = emitterContext.keyValues().<Styles>getNullable(Styles.class).get();
Paragraph pTags = new Paragraph("Tags: ", styles.getFontOrDefault(Settings.META_FONT));
boolean first = true;
Font tagFont = styles.getFontOrDefault(TAG_FONT);
for (String text : tags) {
if (first) {
first = false;
} else {
text = ", " + text;
}
pTags.add(new Chunk(text, tagFont));
}
emitterContext.append(pTags);
}
}
代码示例来源:origin: org.technbolts/gutenberg
@Override
public void process(int level, Node node, InvocationContext context) {
List<Element> subs = context.collectChildren(level, node);
com.itextpdf.text.List orderedList = new com.itextpdf.text.List(com.itextpdf.text.List.ORDERED);
for (Element sub : subs) {
if (!orderedList.add(sub)) {
// wrap it
ListItem listItem = new ListItem();
listItem.add(sub);
orderedList.add(listItem);
}
}
KeyValues kvs = context.iTextContext().keyValues();
Float spacingBefore = kvs.<Float>getNullable(ORDERED_LIST_SPACING_BEFORE).or(5f);
Float spacingAfter = kvs.<Float>getNullable(ORDERED_LIST_SPACING_AFTER).or(5f);
Paragraph p = new Paragraph();
p.add(orderedList);
p.setSpacingBefore(spacingBefore);
p.setSpacingAfter(spacingAfter);
context.append(p);
}
}
代码示例来源:origin: org.technbolts/gutenberg
@Override
public void process(int level, Node node, InvocationContext context) {
List<Element> subs = context.collectChildren(level, node);
com.itextpdf.text.List orderedList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
orderedList.setListSymbol(context.bulletSymbol());
for (Element sub : subs) {
if (!orderedList.add(sub)) {
// wrap it
ListItem listItem = new ListItem();
listItem.add(sub);
orderedList.add(listItem);
}
}
KeyValues kvs = context.iTextContext().keyValues();
Float spacingBefore = kvs.<Float>getNullable(BULLET_LIST_SPACING_BEFORE).or(5f);
Float spacingAfter = kvs.<Float>getNullable(BULLET_LIST_SPACING_AFTER).or(5f);
Paragraph p = new Paragraph();
p.add(orderedList);
p.setSpacingBefore(spacingBefore);
p.setSpacingAfter(spacingAfter);
context.append(p);
}
}
代码示例来源:origin: org.technbolts/gutenberg
public List<Element> process(SourceCode sourceCode) {
String lang = sourceCode.lang();
String content = sourceCode.content();
boolean linenos = sourceCode.showLineNumbers();
Tokens tokens = pygments.tokenize(lang, content);
Paragraph p = new Paragraph();
for (TokenWithValue token : tokens) {
Style style = styleSheet.styleOf(token.token);
BaseColor color = toColor(style.fg());
int s = calculateStyle(style);
Font font = styles.getFont(Styles.CODE_FONT, s, color).get();
Chunk o = new Chunk(token.value, font);
RGB bg = style.bg();
if (bg != null)
o.setBackground(toColor(bg));
p.add(o);
}
PdfPCell cell = new PdfPCell(p);
cell.setPaddingBottom(5.0f);
cell.setBorder(Rectangle.NO_BORDER);
PdfPTable table = new PdfPTable(1);
table.addCell(cell);
table.setSpacingBefore(5.0f);
table.setSpacingAfter(5.0f);
table.setTableEvent(new TableBackground(toColor(styleSheet.backgroundColor())));
return Arrays.<Element>asList(table);
}
内容来源于网络,如有侵权,请联系作者删除!