当前位置: 首页>>代码示例>>Java>>正文


Java Paragraph类代码示例

本文整理汇总了Java中com.itextpdf.text.Paragraph的典型用法代码示例。如果您正苦于以下问题:Java Paragraph类的具体用法?Java Paragraph怎么用?Java Paragraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Paragraph类属于com.itextpdf.text包,在下文中一共展示了Paragraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getObjectDescription

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
private Paragraph getObjectDescription() 
{

	Paragraph p = new Paragraph();
	p.setLeading(0, 1.2f);
	p.setAlignment(Element.ALIGN_JUSTIFIED);
       p.setSpacingAfter(10);
       p.setSpacingBefore(50);
       
	if(o.getDescription()!=null){
		p.add(new Chunk(o.getDescription(), bodyFont));
	}
	else{
		p.add(new Chunk("No description recorded", bodyFont));
	}
	
	return p;
}
 
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:19,代码来源:ProSheet.java

示例2: buildPdfPCell

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){
	PdfPCell cell=new PdfPCell();
	cell.setPadding(0);
	cell.setBorder(Rectangle.NO_BORDER);
	Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline());
	String fontColor=phf.getForecolor();
	if(StringUtils.isNotEmpty(fontColor)){
		String[] color=fontColor.split(",");
		font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));			
	}
	Paragraph graph=new Paragraph(text,font);
	cell.setPhrase(graph);
	switch(type){
	case 1:
		cell.setHorizontalAlignment(Element.ALIGN_LEFT);
		break;
	case 2:
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
		break;
	case 3:
		cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
		break;
	}
	cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
	return cell;
}
 
开发者ID:youseries,项目名称:ureport,代码行数:27,代码来源:PageHeaderFooterEvent.java

示例3: serialise

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
/**
 * Serialise the input field div and content
 * @param pSerialisationContext
 * @param pSerialiser
 * @param pEvalNode
 */
public void serialise(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EN pEvalNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, INPUT_FIELD_TAG, getInputFieldClasses(), Collections.emptyList());
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPTable lTable = pSerialiser.getElementFactory().getTable(1);
  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
  mInputFieldContent.addContent(pSerialisationContext, pSerialiser, pEvalNode);
  if (lCellParagraph.isEmpty()) {
    // If there is no cell content in all cells in a table row, the row will be 0 height - add a zero width space to
    // ensure that the input field div isn't collapsed like this (the height will be determined from the cell
    // paragraph font)
    lCellParagraph.add(ZERO_WIDTH_SPACE_CHARACTER);
  }
  pSerialiser.endContainer();

  lTable.addCell(lCell);
  pSerialiser.add(lTable);

  pSerialiser.popElementAttributes();
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:31,代码来源:InputField.java

示例4: writeSimplePdf

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
public static void writeSimplePdf() throws Exception{
			//1.新建document对象
			//第一个参数是页面大小。接下来的参数分别是左、右、上和下页边距。
			Document document = new Document(PageSize.A4, 50, 50, 50, 50);
			//2.建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中。
			//创建 PdfWriter 对象 第一个参数是对文档对象的引用,第二个参数是文件的实际名称,在该名称中还会给出其输出路径。
			PdfWriter writer = PdfWriter.getInstance(document, 	new FileOutputStream("D:\\Documents\\ITextTest.pdf"));
			//3.打开文档
			document.open();		
			//4.向文档中添加内容
			//通过 com.lowagie.text.Paragraph 来添加文本。可以用文本及其默认的字体、颜色、大小等等设置来创建一个默认段落
			BaseFont bfChinese = BaseFont.createFont("STSong-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
			Font fontChinese = new Font(bfChinese, 22, Font.BOLD, BaseColor.BLACK);
			
			document.add(new Paragraph("sdfsdfsd全是中文显示了没.fsdfsfs",fontChinese));
			document.add(new Paragraph("Some more text on the 	first page with different color and font type.",
					FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new BaseColor(255, 150, 200))));
			Paragraph pragraph=new Paragraph("你这里有中亠好", fontChinese);
			document.add(pragraph);
			
			//图像支持格式 GIF, Jpeg, PNG, wmf
			Image gif = Image.getInstance("F:/keyworkspace/survey/WebRoot/images/logo/snlogo.png");
			gif.setBorder(5);
			gif.scaleAbsolute(30,30);
			gif.setAlignment(Image.RIGHT|Image.TEXTWRAP);
			document.add(gif);
			Paragraph pragraph11=new Paragraph("你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好你这里有中亠好", fontChinese);
			document.add(pragraph11);
			
			Image gif15 = Image.getInstance("F:/keyworkspace/survey/WebRoot/images/logo/snlogo.png");
//			gif15.setBorder(50);
			gif15.setBorder(Image.BOX);
			gif15.setBorderColor(BaseColor.RED);
//			gif15.setBorderColorBottom(borderColorBottom)
			gif15.setBorderWidth(1);
			gif15.scalePercent(50);
			document.add(gif15);
			//5.关闭文档
			document.close();
		}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:41,代码来源:ItextpdfTest.java

示例5: createPDF

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
public void createPDF(String outputFile, ArrayList<Question> qlist, boolean showCorrectAnswer,
        PageCounter pagecounter, int maximumPageNumber, String inputFolder) throws DocumentException, IOException
{
    _inputFolder = inputFolder;
    Document document = new Document(PageSize.A4, 50, 50, 70, 50);
    PdfWriter pdfwriter = PdfWriter.getInstance(document, new FileOutputStream(outputFile));

    pdfwriter.setBoxSize("art", new Rectangle(36, 54, 559, 788));

    pdfwriter.setPageEvent(new HeaderFooter(maximumPageNumber));

    if (pagecounter != null)
    {
        pdfwriter.setPageEvent(pagecounter);
    }

    document.open();

    Paragraph p = new Paragraph();
    // p.setSpacingBefore(SPACING);
    p.setSpacingAfter(SPACING);
    p.setIndentationLeft(INDENTATION);

    writeQuestions(p, document, showCorrectAnswer, qlist);

    document.close();

}
 
开发者ID:wolfposd,项目名称:IMSQTI2PDF,代码行数:29,代码来源:PDFCreator.java

示例6: addTitlePage

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
private static void addTitlePage(Document document,Resolucion res)
    throws DocumentException {
  Paragraph preface = new Paragraph();
  // We add one empty line
  addEmptyLine(preface, 1);
  // Lets write a big header
  preface.add(new Paragraph("Consejo Profesional de Informatica de Santiago del Estero", catFont));

  addEmptyLine(preface, 1);
  // Will create: Report generated by: _name, _date
  preface.add(new Paragraph( "Comision Directiva del Consejo, " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      smallBold));
  addEmptyLine(preface, 2);
  preface.add(new Paragraph("Resolucion N°"+res.getNumero_resolucion()+"",
      smallBold));

  addEmptyLine(preface, 3);

  preface.add(new Paragraph("Esta Resolucion de tipo "+res.getTipo()+" formulada para notificar al socio con legajo: "+res.getLegajo_socio()+" de su actual estado como socio del Consejo.\n"
          + res.getDescripcion_solicitud()+" "+res.getDescripcion_resolucion()+" en la fecha "+res.getFecha(),
      cuerpo));

  document.add(preface);
  // Start a new page
  document.newPage();
}
 
开发者ID:gonzapala,项目名称:CPI,代码行数:27,代码来源:generarPDF.java

示例7: createAccomodationTableHeaders

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
private void createAccomodationTableHeaders(PdfPTable accomodationsTable) {
	PdfPCell numberHeader = new PdfPCell(new Paragraph("Lp."));
	PdfPCell roomNumberHeader = new PdfPCell(new Paragraph("Nr pokoju"));
	PdfPCell dateFromHeader = new PdfPCell(new Paragraph("Od"));
	PdfPCell dateToHeader = new PdfPCell(new Paragraph("Do"));
	PdfPCell placesHeader = new PdfPCell(new Paragraph("Miejsca"));
	PdfPCell roomTypeHeader = new PdfPCell(new Paragraph("Typ"));
	PdfPCell roomPriceHeader = new PdfPCell(new Paragraph("Cena"));
	accomodationsTable.addCell(numberHeader);
	accomodationsTable.addCell(roomNumberHeader);
	accomodationsTable.addCell(dateFromHeader);
	accomodationsTable.addCell(dateToHeader);
	accomodationsTable.addCell(placesHeader);
	accomodationsTable.addCell(roomTypeHeader);
	accomodationsTable.addCell(roomPriceHeader);
}
 
开发者ID:marcin-pwr,项目名称:hotel,代码行数:17,代码来源:ResidenceService.java

示例8: createofferInstancesTableContent

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
private void createofferInstancesTableContent(List<OfferInstance> offerInstances, PdfPTable offerInstancesTable) {
	DecimalFormat decimalFormat = new DecimalFormat(PRICE_DECIMAL_FORMAT);

	int i = 1;
	for (OfferInstance offerInstance : offerInstances) {
		Offer offer = offerInstance.getOffer();

		PdfPCell numberCell = new PdfPCell(new Paragraph(String.valueOf(i++)));

		String offerName = offer.getName();
		PdfPCell roomNumberCell = new PdfPCell(new Paragraph(offerName));

		String offerPrice = decimalFormat.format(offer.getBaseValue()) + " PLN";
		PdfPCell roomPriceCell = new PdfPCell(new Paragraph(offerPrice));

		offerInstancesTable.addCell(numberCell);
		offerInstancesTable.addCell(roomNumberCell);
		offerInstancesTable.addCell(roomPriceCell);
	}

}
 
开发者ID:marcin-pwr,项目名称:hotel,代码行数:22,代码来源:ResidenceService.java

示例9: createTableContent

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
private void createTableContent(List<CleaningSchedule> cleaningSchedules, PdfPTable cleaningScheduleTable) {
	int i = 1;
	for (CleaningSchedule cleaningSchedule : cleaningSchedules) {
		PdfPCell numberCell = new PdfPCell(new Paragraph(String.valueOf(i++)));
		String roomNumber = cleaningSchedule.getAccomodation().getAllocationEntity().getNumber();
		PdfPCell roomNumberCell = new PdfPCell(new Paragraph(roomNumber));
		String preferredTime = cleaningSchedule.getDesiredTime() == null ? "-" : cleaningSchedule.getDesiredTime().toString("HH:mm");
		PdfPCell preferredTimeCell = new PdfPCell(new Paragraph(preferredTime));
		String note = cleaningSchedule.getNote() == null ? "-" : cleaningSchedule.getNote();
		PdfPCell noteCell = new PdfPCell(new Paragraph(note));
		cleaningScheduleTable.addCell(numberCell);
		cleaningScheduleTable.addCell(roomNumberCell);
		cleaningScheduleTable.addCell(preferredTimeCell);
		cleaningScheduleTable.addCell(noteCell);
	}
}
 
开发者ID:marcin-pwr,项目名称:hotel,代码行数:17,代码来源:EmployeeService.java

示例10: showBlank

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
/** Shows a blank document, in case of a problem in generating the PDF */
private byte[] showBlank() throws DocumentException {
    final Document document = new Document(PageSize.LETTER); // FIXME - get PageSize from label definition
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
    final PdfWriter writer = PdfWriter.getInstance(document, baos);
    document.open();
    document.add(new Paragraph("No data have been uploaded.  The time is: " + new Date()));
    
    final Barcode128 code128 = new Barcode128();
    code128.setGenerateChecksum(true);
    code128.setCode(new Date().toString());
    
    document.add(code128.createImageWithBarcode(writer.getDirectContent(), null, null));
    document.close();
    return baos.toByteArray();
}
 
开发者ID:chiralsoftware,项目名称:ExcelToBarcode,代码行数:18,代码来源:MainController.java

示例11: addFormRow

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
/**
 * Serialises a form row
 * @param pSerialisationContext
 * @param pSerialiser
 * @param pRowNode The form node
 */
private void addFormRow(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EvaluatedNodeInfo pRowNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, LIST_ROW_TAG, getRowClasses(pRowNode), getRowStyles(pRowNode));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
  pSerialiser.getWidgetBuilder(pRowNode.getWidgetBuilderType()).buildWidget(pSerialisationContext, pSerialiser, pRowNode);
  pSerialiser.endContainer();
  pSerialiser.add(lCell);

  pSerialiser.popElementAttributes();
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:22,代码来源:FormListWidgetBuilder.java

示例12: addColumnHeader

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
/**
 * Serialises a column header
 * @param pSerialiser
 * @param pHeaderNode The column header node
 */
private void addColumnHeader(PDFSerialiser pSerialiser, EvaluatedNodeInfo pHeaderNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, LIST_CELL_TAG, getHeaderClasses(pHeaderNode), getHeaderStyles(pHeaderNode));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lHeaderCell = pSerialiser.getElementFactory().getCell();

  // Add the header prompt to the cell if one exists
  Optional.ofNullable(pHeaderNode.getSummaryPrompt()).ifPresent(pEvaluatedPrompt -> {
    Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();
    pSerialiser.startContainer(ElementContainerFactory.getContainer(lHeaderCell, lCellParagraph));
    pSerialiser.addParagraphText(pSerialiser.getSafeStringAttribute(pEvaluatedPrompt));
    pSerialiser.endContainer();
  });

  pSerialiser.add(lHeaderCell);
  pSerialiser.popElementAttributes();
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:24,代码来源:ListWidgetBuilder.java

示例13: addBodyCell

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
/**
 * Serialises a list body cell
 * @param pSerialisationContext
 * @param pSerialiser
 * @param pItemNode The item node of the cell if the row and column of the cell has content
 * @param pIsNestedList Whether or not the list if nested, a different class is applied to nested list cells
 */
private void addBodyCell(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, Optional<EvaluatedNodeInfo> pItemNode, boolean pIsNestedList) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, LIST_CELL_TAG, getCellClasses(pItemNode, pIsNestedList), getCellStyles(pItemNode));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  if (pItemNode.isPresent() && pItemNode.get().getVisibility() != NodeVisibility.DENIED) {
    // Column was found for this row and it isn't denied visibility, add content
    pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
    pSerialiser.getWidgetBuilder(pItemNode.get().getWidgetBuilderType()).buildWidget(pSerialisationContext, pSerialiser, pItemNode.get());
    pSerialiser.endContainer();
  }

  pSerialiser.add(lCell);
  pSerialiser.popElementAttributes();
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:26,代码来源:ListWidgetBuilder.java

示例14: createPdf

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));

		// TODO: force iText to respect the order in which content is added
		writer.setStrictImageSequence(true);

		document.open();

		// step 4 - add content into document
		String[] imageNames = { "35_Cal_Crutchlow.jpg", "38_Bradley_Smith.jpg", "46_Valentino_Rossi.jpg",
				"99_Jorge_Lorenzo.jpg" };
		for (int i = 0; i < 4; i++) {

			Image image = Image.getInstance("resources/img/" + imageNames[i]);

			// TODO: scale image
			image.scaleToFit(500, 500); // scale size

			document.add(image);
			document.add(new Paragraph(imageNames[i]));
		}

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:27,代码来源:T05_Image.java

示例15: onEndPage

import com.itextpdf.text.Paragraph; //导入依赖的package包/类
/**
 * Adds a header to every page
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
 *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
	PdfPTable table = new PdfPTable(3);
	try {
		table.setWidths(new int[]{40,5,10});
		table.setTotalWidth(100);
		table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
		table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
		Font font=new Font(chineseFont,8);
		font.setColor(new BaseColor(55,55,55));
		Paragraph paragraph=new Paragraph("第   "+writer.getPageNumber()+" 页   共",font);
		paragraph.setAlignment(Element.ALIGN_RIGHT);
		table.addCell(paragraph);
		Image img=Image.getInstance(total);
		img.scaleAbsolute(28, 28);
		PdfPCell cell = new PdfPCell(img);
		cell.setBorder(Rectangle.NO_BORDER);
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
		table.addCell(cell);
		PdfPCell c = new PdfPCell(new Paragraph("页",font));
		c.setHorizontalAlignment(Element.ALIGN_LEFT);
		c.setBorder(Rectangle.NO_BORDER);
		table.addCell(c);
		float center=(document.getPageSize().getWidth())/2-120/2;
		table.writeSelectedRows(0, -1,center,30, writer.getDirectContent());
	}
	catch(DocumentException de) {
		throw new ExceptionConverter(de);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:35,代码来源:PdfReportPageNumber.java


注:本文中的com.itextpdf.text.Paragraph类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。