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

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

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

Paragraph.<init>介绍

[英]Constructs a Paragraph.
[中]构造一个Paragraph

代码示例

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

protected void addEmptyLine(Paragraph paragraph, int number) {
  for (int i = 0; i < number; i++) {
    paragraph.add(new Paragraph(" "));
  }
}

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

Paragraph preface = new Paragraph(); 
preface.setAlignment(Element.ALIGN_CENTER);

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

protected void addColumnValue(PdfPTable pdfTable, String value) {
  PdfPCell cell = new PdfPCell(new Paragraph(value, facetFont));
  if (facetBgColor != null) {
    cell.setBackgroundColor(facetBgColor);
  }
  pdfTable.addCell(cell);
}

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

private void addText(String text) throws DocumentException {
  final Paragraph paragraph = new Paragraph(text, normalFont);
  paragraph.setIndentationLeft(margin);
  addToDocument(paragraph);
}

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

private void writeFooter() throws DocumentException {
  final Paragraph footer = new Paragraph(getFormattedString("nb_requete_en_cours",
      integerFormat.format(rootCurrentContexts.size())), normalFont);
  footer.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(footer);
}

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

protected void addColumnValue(PdfPTable pdfTable, List<UIComponent> components, Font font, UIColumn column) {
  FacesContext context = FacesContext.getCurrentInstance();
  if (column.getExportFunction() != null) {
    pdfTable.addCell(new Paragraph(exportColumnByFunction(context, column), font));
  }
  else {
    StringBuilder builder = new StringBuilder();
    for (UIComponent component : components) {
      if (component.isRendered()) {
        String value = exportValue(context, component);
        if (value != null) {
          builder.append(value);
        }
      }
    }
    pdfTable.addCell(new Paragraph(builder.toString(), font));
  }
}

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

private void writeFooter() throws DocumentException {
  final List<CounterRequest> requests = counterRequestAggregation.getRequests();
  final CounterRequest globalRequest = counterRequestAggregation.getGlobalRequest();
  // delta ni négatif ni à 0
  final long deltaMillis = Math
      .max(System.currentTimeMillis() - counter.getStartDate().getTime(), 1);
  final long hitsParMinute = 60 * 1000 * globalRequest.getHits() / deltaMillis;
  final String key;
  if (isJobCounter()) {
    key = "nb_jobs";
  } else if (isErrorCounter()) {
    key = "nb_erreurs";
  } else {
    key = "nb_requetes";
  }
  final Paragraph footer = new Paragraph(getFormattedString(key,
      integerFormat.format(hitsParMinute), integerFormat.format(requests.size())),
      normalFont);
  footer.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(footer);
}

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

// Create output PDF
Document document = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open();
PdfContentByte cb = writer.getDirectContent();

// Load existing PDF
PdfReader reader = new PdfReader(templateInputStream);
PdfImportedPage page = writer.getImportedPage(reader, 1); 

// Copy first page of existing PDF into output PDF
document.newPage();
cb.addTemplate(page, 0, 0);

// Add your new data / text here
// for example...
document.add(new Paragraph("my timestamp")); 

document.close();

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

import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class imagesPDF
{     
  public static void main(String arg[])throws Exception
  {                  
    Document document=new Document();
    PdfWriter.getInstance(document,new FileOutputStream("YourPDFHere.pdf"));
    document.open();
    Image image = Image.getInstance ("yourImageHere.jpg");
    document.add(new Paragraph("Your Heading for the Image Goes Here"));
    document.add(image);               
    document.close();
  }
}

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

@Override
public VisitResult visit(VisitContext context, UIComponent target) {
  DataTable dt = (DataTable) target;
  try {
    document.add(exporter.exportPDFTable(context.getFacesContext(), dt, pageOnly, selectionOnly, encoding));
    Paragraph preface = new Paragraph();
    exporter.addEmptyLine(preface, 3);
    document.add(preface);
  }
  catch (DocumentException e) {
    throw new FaceletException(e.getMessage());
  }
  return VisitResult.ACCEPT;
}

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

private void addConfigurationReference() throws DocumentException {
  final Anchor ehcacheAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont());
  ehcacheAnchor.setName("Ehcache configuration reference");
  ehcacheAnchor.setReference(
      "http://ehcache.sourceforge.net/apidocs/net/sf/ehcache/config/CacheConfiguration.html#field_summary");
  ehcacheAnchor.setFont(PdfFonts.BLUE.getFont());
  final Paragraph ehcacheParagraph = new Paragraph();
  ehcacheParagraph.add(ehcacheAnchor);
  ehcacheParagraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(ehcacheParagraph);
}

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

private void addPsCommandReference() throws DocumentException {
  final Anchor psAnchor = new Anchor("ps command reference", PdfFonts.BLUE.getFont());
  psAnchor.setName("ps command reference");
  psAnchor.setReference("http://en.wikipedia.org/wiki/Ps_(Unix)");
  psAnchor.setFont(PdfFonts.BLUE.getFont());
  final Paragraph psParagraph = new Paragraph();
  psParagraph.add(psAnchor);
  psParagraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(psParagraph);
}

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

private void addConfigurationReference() throws DocumentException {
  final Anchor quartzAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont());
  quartzAnchor.setName("Quartz configuration reference");
  quartzAnchor.setReference("http://www.quartz-scheduler.org/docs/index.html");
  quartzAnchor.setFont(PdfFonts.BLUE.getFont());
  final Paragraph quartzParagraph = new Paragraph();
  quartzParagraph.add(quartzAnchor);
  quartzParagraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(quartzParagraph);
}

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

@Override
void toPdf() throws DocumentException {
  writeHeader();
  for (final CacheInformations cacheInformations : cacheInformationsList) {
    nextRow();
    writeCacheInformations(cacheInformations);
  }
  addTableToDocument();
  if (!hitsRatioEnabled) {
    final Paragraph statisticsEnabledParagraph = new Paragraph(
        getString("caches_statistics_enable"), cellFont);
    statisticsEnabledParagraph.setAlignment(Element.ALIGN_RIGHT);
    addToDocument(statisticsEnabledParagraph);
  }
  addConfigurationReference();
}

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

private void writeSqlRequestExplainPlan() throws DocumentException {
  try {
    final String explainPlan;
    if (collectorServer == null) {
      explainPlan = DatabaseInformations.explainPlanFor(request.getName());
    } else {
      explainPlan = collectorServer.collectSqlRequestExplainPlan(
          collector.getApplication(), request.getName());
    }
    if (explainPlan != null) {
      final Paragraph paragraph = new Paragraph("", cellFont);
      paragraph.add(new Phrase('\n' + getString("Plan_d_execution") + '\n', boldFont));
      paragraph.add(new Phrase(explainPlan, courierFont));
      addToDocument(paragraph);
    }
  } catch (final Exception e) {
    final Paragraph paragraph = new Paragraph("", cellFont);
    paragraph.add(new Phrase('\n' + getString("Plan_d_execution") + '\n', boldFont));
    paragraph.add(new Phrase(e.toString(), cellFont));
    addToDocument(paragraph);
  }
}

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

@Override
void toPdf() throws DocumentException, IOException {
  writeHeader();
  for (final ThreadInformations threadInformations : threadInformationsList) {
    nextRow();
    writeThreadInformations(threadInformations);
  }
  addTableToDocument();
  final Paragraph tempsThreads = new Paragraph(getString("Temps_threads") + '\n', cellFont);
  tempsThreads.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(tempsThreads);
  // rq stack-trace: on n'inclue pas dans le pdf les stack-traces des threads
  // car c'est très verbeux et cela remplirait des pages pour pas grand chose
  // d'autant que si le pdf est généré de nuit pour être envoyé par mail
  // alors ces stack-traces n'ont pas beaucoup d'intérêt
  //		if (stackTrace != null && !stackTrace.isEmpty()) {
  //			// même si stackTraceEnabled, ce thread n'a pas forcément de stack-trace
  //			writeln(threadInformations.getName());
  //			for (final StackTraceElement stackTraceElement : stackTrace) {
  //				writeln(stackTraceElement.toString());
  //			}
  //		}
}

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

private void writeRequests(List<CounterRequestContext> contexts)
    throws DocumentException, IOException {
  final PdfPCell defaultCell = getDefaultCell();
  final PdfPCell requestCell = new PdfPCell();
  final Paragraph phrase = new Paragraph("", cellFont);
  int margin = 0;
  for (final CounterRequestContext context : contexts) {
    writeRequest(context, requestCell, margin);
    margin += 5;
  }
  // on utilise ici PdfPCell et addElement pour que les propriétés
  // leading et indentationLeft des paragraphes soient prises en compte
  requestCell.addElement(phrase);
  requestCell.setGrayFill(defaultCell.getGrayFill());
  requestCell.setPaddingTop(defaultCell.getPaddingTop());
  addCell(requestCell);
}

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

private void writeAttributes(MBeanNode mbean) throws DocumentException {
  final String description = mbean.getDescription();
  final List<MBeanAttribute> attributes = mbean.getAttributes();
  if (description != null || !attributes.isEmpty()) {
    currentTable = createAttributesTable();
    if (description != null) {
      currentTable.getDefaultCell().setColspan(3);
      addCell('(' + description + ')');
      currentTable.getDefaultCell().setColspan(1);
    }
    for (final MBeanAttribute attribute : attributes) {
      writeAttribute(attribute);
    }
    final Paragraph paragraph = new Paragraph();
    paragraph.setIndentationLeft(margin);
    paragraph.add(currentTable);
    addToDocument(paragraph);
    addText("\n");
  }
}

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

private void writeRequest(CounterRequestContext context, PdfPCell cell, int margin)
    throws DocumentException, IOException {
  final Paragraph paragraph = new Paragraph(
      getDefaultCell().getLeading() + cellFont.getSize());
  paragraph.setIndentationLeft(margin);
  if (context.getParentCounter().getIconName() != null) {
    paragraph.add(new Chunk(getImage(context.getParentCounter().getIconName()), 0, -1));
  }
  paragraph.add(new Phrase(context.getCompleteRequestName(), cellFont));
  cell.addElement(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;
}

相关文章