本文整理了Java中com.lowagie.text.Paragraph
类的一些代码示例,展示了Paragraph
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Paragraph
类的具体详情如下:
包路径:com.lowagie.text.Paragraph
类名称:Paragraph
[英]A Paragraph
is a series of Chunk
s and/or Phrases
.
A Paragraph
has the same qualities of a Phrase
, but also some additional layout-parameters:
Paragraph p = new Paragraph("This is a paragraph",
FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)));
[中]Paragraph
是一系列的Chunk
和/或[$2$]。Paragraph
与Phrase
具有相同的品质,但也有一些额外的布局参数:
*压痕
*文本的对齐
示例:
Paragraph p = new Paragraph("This is a paragraph",
FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)));
代码示例来源: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: javamelody/javamelody
final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont());
jrobinParagraph.setAlignment(Element.ALIGN_CENTER);
addToDocument(jrobinParagraph);
return;
final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont());
jrobinParagraph.setAlignment(Element.ALIGN_CENTER);
addToDocument(jrobinParagraph);
final Paragraph jrobinParagraph = new Paragraph("",
FontFactory.getFont(FontFactory.HELVETICA, 9f, Font.NORMAL));
jrobinParagraph.setAlignment(Element.ALIGN_CENTER);
jrobinParagraph.add(new Phrase("\n\n\n\n"));
final Collection<byte[]> graphs;
if (mySmallGraphs != null) {
if (i % 3 == 0 && i != 0) {
jrobinParagraph.add(new Phrase("\n\n\n\n\n"));
jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0)));
jrobinParagraph.add(new Phrase(" "));
i++;
jrobinParagraph.add(new Phrase("\n"));
addToDocument(jrobinParagraph);
代码示例来源: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: 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: javamelody/javamelody
private void addText(String text) throws DocumentException {
final Paragraph paragraph = new Paragraph(text, normalFont);
paragraph.setIndentationLeft(margin);
addToDocument(paragraph);
}
代码示例来源:origin: stackoverflow.com
// step 1
Document document = new Document();
// step 2
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
// step 3
document.open();
// step 4
document.add(new Paragraph("Hello"));
// step 5
document.close();
代码示例来源:origin: stackoverflow.com
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello World!"));
document.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
PDDocument document = PDDocument.load(bais);
代码示例来源:origin: stackoverflow.com
Document document = new Document(PageSize.A4.rotate());
document.open();
//Get the image as Buffere Image
BufferedImage awtImage = ImageIO.read(new URL("image url"));
//Crop: Sample, get Upper Half of the image
BufferedImage awtImageUpper = awtImage.getSubimage(0, 0, awtImage.getWidth(), awtImage.getHeight()/2);
//Make BufferedImage and render as Image (in iText)
ByteArrayOutputStream baosImage = new ByteArrayOutputStream();
ImageIO.write(awtImageUpper, "png", baosImage);
Image iTextImage = Image.getInstance(baosImage.toByteArray());
//Display Image in pdf
document.add(new Paragraph("image Upper half"));
document.add((Element) iTextImage);
代码示例来源:origin: stackoverflow.com
ByteArrayOutputStream os = new ByteArrayOutputStream();
Document bigDoc = new Document(PageSize.LETTER, 50, 50, 110, 60);
PdfWriter writer = PdfWriter.getInstance(bigDoc, os);
bigDoc.open();
Paragraph par = new Paragraph("one");
bigDoc.add(par);
bigDoc.add(new Paragraph("three"));
PdfReader pdfReader = new PdfReader("c:/insertable.pdf");
PdfImportedPage page = writer.getImportedPage(pdfReader, 1);
bigDoc.newPage();
PdfContentByte canvas = writer.getDirectContent();
canvas.addTemplate(page, 1, 0, 0, 1, 0, 0);
bigDoc.close();
pdfReader.close();
// result PDF
byte[] result = os.toByteArray();
代码示例来源:origin: stackoverflow.com
Paragraph preface = new Paragraph();
preface.add(new Paragraph("Title of the document", catFont));
preface.add(new Paragraph(
"Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
smallBold));
addEmptyLine(preface, 3);
preface.add(new Paragraph(
"This document describes something which is very important ",
smallBold));
preface.add(new Paragraph(
"This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.de ;-).",
redFont));
subCatPart.add(new Paragraph("Hello"));
subCatPart.add(new Paragraph("Paragraph 1"));
subCatPart.add(new Paragraph("Paragraph 2"));
subCatPart.add(new Paragraph("Paragraph 3"));
Paragraph paragraph = new Paragraph();
addEmptyLine(paragraph, 5);
subCatPart.add(paragraph);
subCatPart.add(new Paragraph("This is a very important message"));
paragraph.add(new Paragraph(" "));
代码示例来源:origin: stackoverflow.com
PdfPCell monday = new PdfPCell(new Paragraph("Monday "));
monday.setMinimumHeight(15f);
monday.setLeading(0f, 1.2f);
PdfPCell mondayvalue = new PdfPCell(new Paragraph("social social,gfdgdf,fdfgfdg,fdgdfgfdsfsdfsd,ggdshgfgskfs,sggfsdfskjfjgshfjsgaf,shgjkfjk"));
mondayvalue.setMinimumHeight(15f);
mondayvalue.setLeading(0f, 1.2f);
PdfPCell Planned = new PdfPCell(new Paragraph("Planned"));
Planned.setMinimumHeight(15f);
Planned.setLeading(0f, 1.2f);
PdfPCell plansubstitue = new PdfPCell(new Paragraph("social social,gfdgdf,fdfgfdg,fdgdfgfdsfsdfsd,ggdshgfgskfs,sggfsdfskjfjgshfjsgaf,shgjkfjk"));
PdfPCell activity = new PdfPCell(new Paragraph("Activities / Approach / Introduction"));
activity.setColspan(4);
activity.setMinimumHeight(15f);
PdfPTable activitynested = new PdfPTable(1);
PdfPCell activitynestedcell = new PdfPCell(new Phrase("Nested Cell 1"));
activitynestedcell.setHorizontalAlignment(Element.ALIGN_CENTER);
activitynested.addCell(activitynestedcell);
row4.addCell(activity);
document.add(row4);
document.close();
} catch (FileNotFoundException e) {
代码示例来源:origin: stackoverflow.com
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(dest));
Rectangle one = new Rectangle(70,140);
Rectangle two = new Rectangle(700,400);
document.setPageSize(one);
document.setMargins(2, 2, 2, 2);
document.open();
Paragraph p = new Paragraph("Hi");
document.add(p);
document.setPageSize(two);
document.setMargins(20, 20, 20, 20);
document.newPage();
document.add(p);
document.close();
代码示例来源:origin: stackoverflow.com
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(image_path+"\\"+image_name+".pdf"));
document.open();
Paragraph p = new Paragraph();
File files[] = new File(path).listFiles();
PdfPTable table = new PdfPTable(1);
for (File file : files) {
table.setWidthPercentage(100);
table.addCell(createImageCell(file.getAbsolutePath()));
}
document.add(table);
document.close();
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-common
/**
* Methode qui ajoute le tableau de data dans le fichier pdf
* @param _data tableau de donnes
* @param _title titre du tableau
* @param _document document pdf
* @throws DocumentException
* @author Adrien Hadoux
*/
public static void addDataToDocPdf(Object[][] _data,String _title,Document _document) throws DocumentException{
PdfPTable table = new PdfPTable(2);
//-- titre --//
PdfPCell cell = new PdfPCell(new Paragraph(_title));
cell.setColspan(2);
table.addCell(cell);
//-- remplissage --//
for(int i=0;i<_data.length;i++)
for(int j=0;j<_data.length;i++)
table.addCell(_data[i][j].toString());
_document.add(table);
}
代码示例来源:origin: qcadoo/mes
private void addPlaceForSignature(final Document document, final Locale locale) throws DocumentException {
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(15);
table.setHorizontalAlignment(Element.ALIGN_RIGHT);
Paragraph signParagraph = new Paragraph(new Phrase(translationService.translate(
"materialFlowResources.dispositionOrder.sign", locale), FontUtils.getDejavuBold7Dark()));
signParagraph.setAlignment(Element.ALIGN_CENTER);
PdfPCell cell1 = new PdfPCell(signParagraph);
cell1.setBorder(Rectangle.TOP);
cell1.setVerticalAlignment(Rectangle.ALIGN_CENTER);
cell1.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
table.addCell(cell1);
document.add(table);
}
代码示例来源:origin: qcadoo/mes
private PdfPTable createIncludedTable(final List<Entity> includedEntities, final String includedType, final Locale locale)
throws DocumentException {
PdfPTable includedTable = new PdfPTable(1);
includedTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
includedTable.getDefaultCell().setPadding(2f);
includedTable.addCell(new Paragraph(translationService.translate("orderSupplies.materialRequirementCoverage.report."
+ includedType + ".title", locale), FontUtils.getDejavuBold10Dark()));
int[] columnWidths = { 40, 60 };
PdfPTable includedTableBody = pdfHelper.createTableWithHeader(2, prepareIncludedTableHeader(includedType, locale), false,
columnWidths);
includedTableBody.getDefaultCell().setVerticalAlignment(PdfPCell.ALIGN_TOP);
for (Entity included : includedEntities) {
String number = included.getStringField(L_NUMBER);
String name = included.getStringField(L_NAME);
includedTableBody.addCell(new Phrase(number, FontUtils.getDejavuRegular7Dark()));
includedTableBody.addCell(new Phrase(name, FontUtils.getDejavuRegular7Dark()));
}
includedTable.addCell(includedTableBody);
return includedTable;
}
代码示例来源:origin: qcadoo/mes
private void addWorkPlanTitle(Document document, Entity workPlan, String title, Locale locale) throws DocumentException {
PdfPTable headerTable = pdfHelper.createPanelTable(2);
PdfPCell titleCell = new PdfPCell();
titleCell.setBorder(Rectangle.NO_BORDER);
Paragraph workPlanTitle = new Paragraph(new Phrase(getWorkPlanTitle(locale), FontUtils.getDejavuBold11Light()));
workPlanTitle.add(new Phrase(" " + getWorkPlanName(workPlan), FontUtils.getDejavuBold11Dark()));
titleCell.addElement(workPlanTitle);
PdfPCell divisionCell = new PdfPCell();
divisionCell.setBorder(Rectangle.NO_BORDER);
Paragraph divisionTitle = new Paragraph(new Phrase(getDivisionTitle(locale), FontUtils.getDejavuBold11Light()));
divisionTitle.add(new Phrase(" " + getDivisionFromTitle(title, locale), FontUtils.getDejavuBold11Dark()));
divisionTitle.setAlignment(Element.ALIGN_RIGHT);
divisionCell.addElement(divisionTitle);
headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
headerTable.setTableEvent(null);
headerTable.setSpacingAfter(4.0f);
headerTable.addCell(titleCell);
headerTable.addCell(divisionCell);
document.add(headerTable);
}
代码示例来源:origin: qcadoo/mes
private void addPlaceForComments(Document document, Locale locale) throws DocumentException {
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100f);
Paragraph paragraph = new Paragraph(new Phrase(translationService.translate(
"materialFlowResources.dispositionOrder.comments", locale), FontUtils.getDejavuBold7Dark()));
paragraph.setAlignment(Element.ALIGN_LEFT);
paragraph.setSpacingAfter(6f);
document.add(paragraph);
PdfPCell cell1 = new PdfPCell(new Paragraph(""));
cell1.setBorder(Rectangle.BOX);
cell1.setFixedHeight(60f);
table.addCell(cell1);
document.add(table);
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
}
代码示例来源:origin: qcadoo/mes
document.add(Chunk.NEWLINE);
document.add(new Paragraph(header.toString(), FontUtils.getDejavuBold11Dark()));
document.add(Chunk.NEWLINE);
productName.append(L_SPACER).append(product.getField(L_NAME));
panel.getDefaultCell().setBorder(PdfCell.NO_BORDER);
panel.addCell(new Phrase(productNumber.toString(), FontUtils.getDejavuBold9Dark()));
panel.addCell(new Phrase(company.toString(), FontUtils.getDejavuBold9Dark()));
panel.addCell(new Phrase(productName.toString(), FontUtils.getDejavuBold9Dark()));
panel.addCell(new Phrase());
Paragraph typeOfReport = new Paragraph(footer.toString(), FontUtils.getDejavuBold9Dark());
typeOfReport.setAlignment(Chunk.ALIGN_CENTER);
document.add(typeOfReport);
内容来源于网络,如有侵权,请联系作者删除!