當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。