com.lowagie.text.Paragraph.setSpacingBefore()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(366)

本文整理了Java中com.lowagie.text.Paragraph.setSpacingBefore()方法的一些代码示例,展示了Paragraph.setSpacingBefore()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Paragraph.setSpacingBefore()方法的具体详情如下:
包路径:com.lowagie.text.Paragraph
类名称:Paragraph
方法名:setSpacingBefore

Paragraph.setSpacingBefore介绍

[英]Sets the spacing before this paragraph.
[中]设置此段落前的间距。

代码示例

代码示例来源:origin: javamelody/javamelody

Element createParagraphElement(String paragraphTitle, String iconName)
    throws DocumentException, IOException {
  final Paragraph paragraph = new Paragraph("", paragraphTitleFont);
  paragraph.setSpacingBefore(5);
  paragraph.setSpacingAfter(5);
  if (iconName != null) {
    paragraph.add(new Chunk(getParagraphImage(iconName), 0, -5));
  }
  final Phrase element = new Phrase(' ' + paragraphTitle, paragraphTitleFont);
  element.setLeading(12);
  paragraph.add(element);
  // chapter pour avoir la liste des signets
  final ChapterAutoNumber chapter = new ChapterAutoNumber(paragraph);
  // sans numéro de chapitre
  chapter.setNumberDepth(0);
  chapter.setBookmarkOpen(false);
  chapter.setTriggerNewPage(false);
  return chapter;
}

代码示例来源:origin: stackoverflow.com

float spaceBetweenLines = 12;
Paragraph p;
for (final String singleLine : document.getSingleLine()) {
  p = new Paragraph(spaceBetweenLines, singleLine, font);
  if (singleLine.contains("#ACC")) {
    p.setSpacingBefore(spaceBetweenLines);
  }
  if (!singleLine().isEmpty())
    document.add(p);
}

代码示例来源:origin: stackoverflow.com

public void createPdf(String filename) throws IOException, DocumentException {
  Document document = new Document();
  PdfWriter.getInstance(document, new FileOutputStream(filename));
  document.open();
  Paragraph paragraph1 = new Paragraph("First paragraph");
  Paragraph paragraph2 = new Paragraph("Second paragraph");
  paragraph2.setSpacingBefore(380f);
  document.add(paragraph1);
  document.add(paragraph2);
  document.close();
}

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext

if (value != null) {
  try {
    p.setSpacingBefore(Float.parseFloat(value));
  } catch (Exception e) {

代码示例来源:origin: com.github.librepdf/pdf-html

if (value != null) {
  try {
    p.setSpacingBefore(Float.parseFloat(value));
  } catch (Exception e) {

代码示例来源:origin: fr.opensagres.xdocreport.itext-gae/itext-gae

if (value != null) {
  try {
    p.setSpacingBefore(Float.parseFloat(value));
  } catch (Exception e) {

代码示例来源:origin: com.github.linkeer8802/api-resolver-core

private void addSummary(Section section, ApiDoc apiDoc) throws Exception {
  
  Paragraph summary = new Paragraph(itemFont.process("★简要信息"));
  summary.setSpacingBefore(6f);
  summary.setSpacingAfter(8f);
 
  List<String[]> rowDatas = new ArrayList<String[]>();
  rowDatas.add(new String[]{apiDoc.getMapping()});
  rowDatas.add(new String[]{apiDoc.getAuthor()});
  rowDatas.add(new String[]{apiDoc.getVersion()});
  PdfPTable table = DefaultPdfTable.get().create(TBDirection.Vertical, rowDatas.size(), 
            new String[]{"映射地址", "作者", "版本"}, new int[]{1, 10});
  DefaultPdfTable.get().setDataAlignments(new int[]{Element.ALIGN_LEFT});
  DefaultPdfTable.get().setRowDatas(rowDatas);
  Paragraph wrapperTable = new Paragraph();
  wrapperTable.setIndentationLeft(12f);
  wrapperTable.add(table);
  section.add(summary);
  section.add(wrapperTable);
}

代码示例来源:origin: stackoverflow.com

para1.setSpacingBefore(50);
para1.setSpacingAfter(50);
for (int i = 0; i < 10; i++) {

代码示例来源:origin: stackoverflow.com

public PdfPCell getCell4() {
  PdfPCell cell = new PdfPCell();
  Paragraph p1 = new Paragraph("My fantastic data");
  p1.setSpacingAfter(20);
  cell.addElement(p1);
  LineSeparator ls = new LineSeparator();
  cell.addElement(ls);
  Paragraph p2 = new Paragraph("Other data");
  p2.setSpacingBefore(10);
  cell.addElement(p2);
  return cell;
}

代码示例来源:origin: org.seasar.tuigwaa/tuigwaa-cms

public Object visit(WikiDefineList node, Object data) {
  Paragraph p = new Paragraph();
  p.setSpacingBefore(5f);
  p.setSpacingAfter(5f);
  p.setIndentationLeft(5f);
  p.add(Chunk.NEWLINE);
  for (int i = 0; i < node.jjtGetNumChildren(); i++) {
    Object o = node.jjtGetChild(i).jjtAccept(this, data);
    if (o != null)
      p.add(o);
  }
  return p;
}

代码示例来源:origin: org.seasar.tuigwaa/tuigwaa-cms

public Object visit(WikiParagraph node, Object data) {
  Paragraph p = new Paragraph();
  p.setLeading(20f);
  p.setFirstLineIndent(defaultFont_.size());
  p.setSpacingBefore(paragraphSpacing_);
  p.setSpacingAfter(paragraphSpacing_);
  for (int i = 0; i < node.jjtGetNumChildren(); i++) {
    Object o = node.jjtGetChild(i).jjtAccept(this, data);
    if (o != null)
      p.add(o);
  }
  return p;
}

代码示例来源:origin: qcadoo/mes

private void addPalletNumber(final Document document, final String number) throws DocumentException {
  LineSeparator lineSeparator = new LineSeparator(1, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
  Paragraph numberParagraph = new Paragraph(new Phrase(number, FontUtils.getDejavuBold70Dark()));
  numberParagraph.setAlignment(Element.ALIGN_CENTER);
  numberParagraph.setSpacingBefore(70F);
  numberParagraph.setSpacingAfter(180F);
  document.add(Chunk.NEWLINE);
  document.add(numberParagraph);
  document.add(lineSeparator);
}

代码示例来源:origin: com.github.linkeer8802/api-resolver-core

private void addParameters(Section section, ApiDoc apiDoc) throws Exception {
  
 Paragraph inputParams = new Paragraph(itemFont.process("★输入参数"));
 inputParams.setSpacingBefore(6f);
 inputParams.setSpacingAfter(8f);
 
 List<String[]> rowDatas = new ArrayList<String[]>();
 for (ParamDoc paramDoc : apiDoc.getParams()) {
   String required = paramDoc.getRequired() ? "必须" : "可选";
   rowDatas.add(new String[]{paramDoc.getName(), paramDoc.getType(), 
       required, paramDoc.getExampleValue(), paramDoc.getDefaultValue(), paramDoc.getDesc()});
 }
 
 PdfPTable paramTable = DefaultPdfTable.get().create(TBDirection.Horizontal, rowDatas.size()+1,
            new String[]{"名称", "类型", "是否必须", "示例值", "默认值", "描述"}, 
            new int[]{15, 10, 10, 15, 10, 40});
 DefaultPdfTable.get().setDataAlignments(new int[]{Element.ALIGN_CENTER, Element.ALIGN_CENTER,
           Element.ALIGN_CENTER, Element.ALIGN_CENTER, Element.ALIGN_CENTER, Element.ALIGN_LEFT});
 DefaultPdfTable.get().setRowDatas(rowDatas);
 Paragraph wrapperTable = new Paragraph();
 wrapperTable.setIndentationLeft(12f);
 wrapperTable.add(paramTable);
 section.add(inputParams);
 section.add(wrapperTable);
}

代码示例来源:origin: org.seasar.tuigwaa/tuigwaa-cms

public Object visit(WikiExcerpt node, Object data) {
  Properties props = PdfUtils.getDefaultfontProperties(defaultFont_);
  props.setProperty(ElementTags.STYLE, MarkupTags.CSS_ITALIC);
  Paragraph p = new Paragraph(props);
  p.setIndentationLeft(20 * node.level);
  p.setSpacingAfter(paragraphSpacing_);
  p.setSpacingBefore(paragraphSpacing_);
  for (int i = 0; i < node.jjtGetNumChildren(); i++) {
    // if child is paragraph, not generate <p> tag
    if (node.jjtGetChild(i) instanceof WikiParagraph) {
      WikiParagraph c = (WikiParagraph) node.jjtGetChild(i);
      for (int j = 0; j < c.jjtGetNumChildren(); j++) {
        Object o = c.jjtGetChild(j).jjtAccept(this, data);
        if (o != null)
          p.add(o);
      }
    } else {
      Object o = node.jjtGetChild(i).jjtAccept(this, data);
      if (o != null)
        p.add(o);
    }
  }
  return p;
}

代码示例来源:origin: net.bull.javamelody/javamelody-core

Element createParagraphElement(String paragraphTitle, String iconName)
    throws DocumentException, IOException {
  final Paragraph paragraph = new Paragraph("", paragraphTitleFont);
  paragraph.setSpacingBefore(5);
  paragraph.setSpacingAfter(5);
  if (iconName != null) {
    paragraph.add(new Chunk(getParagraphImage(iconName), 0, -5));
  }
  final Phrase element = new Phrase(' ' + paragraphTitle, paragraphTitleFont);
  element.setLeading(12);
  paragraph.add(element);
  // chapter pour avoir la liste des signets
  final ChapterAutoNumber chapter = new ChapterAutoNumber(paragraph);
  // sans numéro de chapitre
  chapter.setNumberDepth(0);
  chapter.setBookmarkOpen(false);
  chapter.setTriggerNewPage(false);
  return chapter;
}

代码示例来源:origin: com.github.linkeer8802/api-resolver-core

private void addTypeAttrs(Section section, List<ResultDoc> attrs) throws Exception {
   paAttrs.setSpacingBefore(6f);
   paAttrs.setSpacingAfter(8f);

代码示例来源:origin: fr.opensagres.xdocreport.itext-gae/itext-gae

/**
 * Constructs a <CODE>Paragraph</CODE> with a certain <CODE>Phrase</CODE>.
 *
 * @param    phrase        a <CODE>Phrase</CODE>
 */    
public Paragraph(Phrase phrase) {
  super(phrase);
  if (phrase instanceof Paragraph) {
    Paragraph p = (Paragraph)phrase;
    setAlignment(p.alignment);
    setLeading(phrase.getLeading(), p.multipliedLeading);
    setIndentationLeft(p.getIndentationLeft());
    setIndentationRight(p.getIndentationRight());
    setFirstLineIndent(p.getFirstLineIndent());
    setSpacingAfter(p.spacingAfter());
    setSpacingBefore(p.spacingBefore());
    setExtraParagraphSpace(p.getExtraParagraphSpace());
  }
}

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext

/**
 * Constructs a <CODE>Paragraph</CODE> with a certain <CODE>Phrase</CODE>.
 *
 * @param    phrase        a <CODE>Phrase</CODE>
 */    
public Paragraph(Phrase phrase) {
  super(phrase);
  if (phrase instanceof Paragraph) {
    Paragraph p = (Paragraph)phrase;
    setAlignment(p.alignment);
    setLeading(phrase.getLeading(), p.multipliedLeading);
    setIndentationLeft(p.getIndentationLeft());
    setIndentationRight(p.getIndentationRight());
    setFirstLineIndent(p.getFirstLineIndent());
    setSpacingAfter(p.spacingAfter());
    setSpacingBefore(p.spacingBefore());
    setExtraParagraphSpace(p.getExtraParagraphSpace());
  }
}

代码示例来源:origin: com.github.librepdf/openpdf

/**
 * Constructs a <CODE>Paragraph</CODE> with a certain <CODE>Phrase</CODE>.
 *
 * @param    phrase        a <CODE>Phrase</CODE>
 */    
public Paragraph(Phrase phrase) {
  super(phrase);
  if (phrase instanceof Paragraph) {
    Paragraph p = (Paragraph)phrase;
    setAlignment(p.alignment);
    setLeading(phrase.getLeading(), p.multipliedLeading);
    setIndentationLeft(p.getIndentationLeft());
    setIndentationRight(p.getIndentationRight());
    setFirstLineIndent(p.getFirstLineIndent());
    setSpacingAfter(p.spacingAfter());
    setSpacingBefore(p.spacingBefore());
    setExtraParagraphSpace(p.getExtraParagraphSpace());
  }
}

代码示例来源:origin: com.github.linkeer8802/api-resolver-core

private void addResultExample(Section section, ApiDoc apiDoc) throws Exception {
    
     Paragraph result = new Paragraph(itemFont.process("★返回示例"));
//          result.setLeading(6f);
     result.setSpacingBefore(6f);
     result.setSpacingAfter(8f);
     
     PdfPTable table = new PdfPTable(1);
     table.setWidthPercentage(95f);
     table.setHorizontalAlignment(Element.ALIGN_LEFT);
     PdfPCell pdfPCell = table.getDefaultCell();
     pdfPCell.setHorizontalAlignment(Element.ALIGN_LEFT);
     pdfPCell.setBackgroundColor(Color.LIGHT_GRAY);
     if (apiDoc.getResultDoc() != null && apiDoc.getResultExample() != null) {
       pdfPCell.setPhrase(DefaultPdfTable.tableBSelector.process(apiDoc.getResultExample()));
     }
     table.addCell(pdfPCell);
     Paragraph wrapperTable = new Paragraph();
     wrapperTable.setSpacingAfter(8f);
     wrapperTable.setIndentationLeft(12f);
     wrapperTable.add(table);
     section.add(result);
     section.add(wrapperTable);
  }
}

相关文章