當前位置: 首頁>>代碼示例>>Java>>正文


Java Chunk類代碼示例

本文整理匯總了Java中com.lowagie.text.Chunk的典型用法代碼示例。如果您正苦於以下問題:Java Chunk類的具體用法?Java Chunk怎麽用?Java Chunk使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Chunk類屬於com.lowagie.text包,在下文中一共展示了Chunk類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import com.lowagie.text.Chunk; //導入依賴的package包/類
public void write(PDFDocument document, PdfPTable tabla) throws DocumentException {
	com.lowagie.text.List list = new com.lowagie.text.List(false,10f);
	list.setListSymbol(new Chunk("\u2022"));

	PdfPCell cell = new PdfPCell();
	
	if(!titulo.equals(""))
	{
	   cell.addElement(new Phrase(titulo,document.getContext().getDefaultFont()));
	}

	for(int i=0; i<campos.size(); i++)
	{
		list.add(new ListItem((String)campos.get(i),document.getContext().getDefaultFont()));
	}
	
	cell.addElement(list);
	cell.setPaddingLeft(30f);
	cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
	cell.setColspan(2);
	tabla.addCell(cell);
	
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:24,代碼來源:Lista.java

示例2: PdfPCell

import com.lowagie.text.Chunk; //導入依賴的package包/類
/**
 * Constructs a <CODE>PdfPCell</CODE> with an <CODE>Image</CODE>.
 * The default padding is 0.25 for a border width of 0.5.
 * 
 * @param image the <CODE>Image</CODE>
 * @param fit <CODE>true</CODE> to fit the image to the cell
 */
public PdfPCell(Image image, boolean fit) {
    super(0, 0, 0, 0);
    borderWidth = 0.5f;
    border = BOX;
    if (fit) {
        this.image = image;
        column.setLeading(0, 1);
        setPadding(borderWidth / 2);
    }
    else {
        column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0)));
        column.setLeading(0, 1);
        setPadding(0);
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:23,代碼來源:PdfPCell.java

示例3: RtfChunk

import com.lowagie.text.Chunk; //導入依賴的package包/類
/**
 * Constructs a RtfChunk based on the content of a Chunk
 * 
 * @param doc The RtfDocument that this Chunk belongs to
 * @param chunk The Chunk that this RtfChunk is based on
 */
public RtfChunk(RtfDocument doc, Chunk chunk) {
    super(doc);
    
    if(chunk == null) {
        return;
    }
    
    if(chunk.getAttributes() != null && chunk.getAttributes().get(Chunk.SUBSUPSCRIPT) != null) {
        this.superSubScript = ((Float)chunk.getAttributes().get(Chunk.SUBSUPSCRIPT)).floatValue();
    }
    if(chunk.getAttributes() != null && chunk.getAttributes().get(Chunk.BACKGROUND) != null) {
        this.background = new RtfColor(this.document, (Color) ((Object[]) chunk.getAttributes().get(Chunk.BACKGROUND))[0]);
    }
    font = new RtfFont(doc, chunk.getFont());
    content = chunk.getContent();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:23,代碼來源:RtfChunk.java

示例4: getPhrase

import com.lowagie.text.Chunk; //導入依賴的package包/類
/**
 * Creates a Phrase object based on a list of properties.
 * @param attributes
 * @return a Phrase
 */
public static Phrase getPhrase(Properties attributes) {
	Phrase phrase = new Phrase();
	phrase.setFont(FontFactory.getFont(attributes));
	String value;
	value = attributes.getProperty(ElementTags.LEADING);
	if (value != null) {
		phrase.setLeading(Float.parseFloat(value + "f"));
	}
	value = attributes.getProperty(Markup.CSS_KEY_LINEHEIGHT);
	if (value != null) {
		phrase.setLeading(Markup.parseLength(value,
				Markup.DEFAULT_FONT_SIZE));
	}
	value = attributes.getProperty(ElementTags.ITEXT);
	if (value != null) {
		Chunk chunk = new Chunk(value);
		if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) {
			chunk.setGenericTag(value);
		}
		phrase.add(chunk);
	}
	return phrase;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:29,代碼來源:ElementFactory.java

示例5: createChunk

import com.lowagie.text.Chunk; //導入依賴的package包/類
public Chunk createChunk(String text, ChainedProperties props) {
	Font font = getFont(props);
	float size = font.getSize();
	size /= 2;
	Chunk ck = new Chunk(text, font);
	if (props.hasProperty("sub"))
		ck.setTextRise(-size);
	else if (props.hasProperty("sup"))
		ck.setTextRise(size);
	ck.setHyphenation(getHyphenation(props));
	return ck;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:13,代碼來源:FactoryProperties.java

示例6: main

import com.lowagie.text.Chunk; //導入依賴的package包/類
/**
    * Specifying an encoding.
    */
@Test
   public void main() throws Exception {
       
       
       // step 1: creation of a document-object
       Document document = new Document();
       
           
           // step 2: creation of the writer
           PdfWriter.getInstance(document, PdfTestBase.getOutputStream("fontencoding.pdf"));
           
           // step 3: we open the document
           document.open();
           
           // step 4: we add content to the document
           BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
           Font font = new Font(helvetica, 12, Font.NORMAL);
           Chunk chunk = new Chunk("Sponsor this example and send me 1\u20ac. These are some special characters: \u0152\u0153\u0160\u0161\u0178\u017D\u0192\u02DC\u2020\u2021\u2030", font);
           document.add(chunk);
       
       // step 5: we close the document
       document.close();
   }
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:27,代碼來源:FontEncodingTest.java

示例7: createTempFile

import com.lowagie.text.Chunk; //導入依賴的package包/類
private void createTempFile(String filename, String[] pageContents) throws Exception{
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    document.open();
    
    for (int i = 0; i < pageContents.length; i++) {
        if (i != 0)
            document.newPage();

        String content = pageContents[i];
        Chunk contentChunk = new Chunk(content);
        document.add(contentChunk);
    }
    
    
    document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:18,代碼來源:TestPdfCopyAndStamp.java

示例8: writePageAnchor

import com.lowagie.text.Chunk; //導入依賴的package包/類
protected void writePageAnchor(int pageIndex) throws DocumentException 
{
	Map<Attribute,Object> attributes = new HashMap<Attribute,Object>();
	fontUtil.getAttributesWithoutAwtFont(attributes, new JRBasePrintText(jasperPrint.getDefaultStyleProvider()));
	Font pdfFont = getFont(attributes, getLocale(), false);
	Chunk chunk = new Chunk(" ", pdfFont);
	
	chunk.setLocalDestination(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1));

	tagHelper.startPageAnchor();
	
	ColumnText colText = new ColumnText(pdfContentByte);
	colText.setSimpleColumn(
		new Phrase(chunk),
		0,
		pageFormat.getPageHeight(),
		1,
		1,
		0,
		Element.ALIGN_LEFT
		);

	colText.go();

	tagHelper.endPageAnchor();
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:27,代碼來源:JRPdfExporter.java

示例9: setAnchor

import com.lowagie.text.Chunk; //導入依賴的package包/類
protected void setAnchor(Chunk chunk, JRPrintAnchor anchor, JRPrintElement element)
{
	String anchorName = anchor.getAnchorName();
	if (anchorName != null)
	{
		chunk.setLocalDestination(anchorName);

		if (anchor.getBookmarkLevel() != JRAnchor.NO_BOOKMARK)
		{
			int x = OrientationEnum.PORTRAIT.equals(pageFormat.getOrientation()) 
					? getOffsetX() + element.getX() 
					: getOffsetY() + element.getY();
			int y = OrientationEnum.PORTRAIT.equals(pageFormat.getOrientation()) 
					? getOffsetY() + element.getY() 
					: getOffsetX() + element.getX();
			addBookmark(anchor.getBookmarkLevel(), anchor.getAnchorName(), x, y);
		}
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:20,代碼來源:JRPdfExporter.java

示例10: writeJndiBinding

import com.lowagie.text.Chunk; //導入依賴的package包/類
private void writeJndiBinding(JndiBinding jndiBinding) throws BadElementException, IOException {
	final PdfPCell defaultCell = getDefaultCell();
	defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
	final String name = jndiBinding.getName();
	final String className = jndiBinding.getClassName();
	final String contextPath = jndiBinding.getContextPath();
	final String value = jndiBinding.getValue();
	if (contextPath != null) {
		final Image image = getFolderImage();
		final Phrase phrase = new Phrase("", cellFont);
		phrase.add(new Chunk(image, 0, 0));
		phrase.add(" ");
		phrase.add(name);
		addCell(phrase);
	} else {
		addCell(name);
	}
	addCell(className != null ? className : "");
	addCell(value != null ? value : "");
}
 
開發者ID:javamelody,項目名稱:javamelody,代碼行數:21,代碼來源:PdfJndiReport.java

示例11: writeMemoryInformations

import com.lowagie.text.Chunk; //導入依賴的package包/類
private void writeMemoryInformations(MemoryInformations memoryInformations)
		throws BadElementException, IOException {
	addCell(memoryInformations.getMemoryDetails().replace(" Mo", ' ' + getString("Mo")));
	final long usedPermGen = memoryInformations.getUsedPermGen();
	if (usedPermGen > 0) {
		// perm gen est à 0 sous jrockit
		final long maxPermGen = memoryInformations.getMaxPermGen();
		addCell(getString("Memoire_Perm_Gen") + ':');
		if (maxPermGen > 0) {
			final Phrase permGenPhrase = new Phrase(
					integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo")
							+ DIVIDE + integerFormat.format(maxPermGen / 1024 / 1024) + ' '
							+ getString("Mo") + BAR_SEPARATOR,
					cellFont);
			final Image permGenImage = Image.getInstance(
					Bar.toBarWithAlert(memoryInformations.getUsedPermGenPercentage()), null);
			permGenImage.scalePercent(50);
			permGenPhrase.add(new Chunk(permGenImage, 0, 0));
			currentTable.addCell(permGenPhrase);
		} else {
			addCell(integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo"));
		}
	}
}
 
開發者ID:javamelody,項目名稱:javamelody,代碼行數:25,代碼來源:PdfJavaInformationsReport.java

示例12: writeTree

import com.lowagie.text.Chunk; //導入依賴的package包/類
/**
 * Affiche l'arbre des MBeans.
 * @throws DocumentException e
 */
void writeTree() throws DocumentException {
	// MBeans pour la plateforme
	margin = 0;
	final MBeanNode platformNode = mbeans.get(0);
	writeTree(platformNode.getChildren());

	for (final MBeanNode node : mbeans) {
		if (node != platformNode) {
			newPage();
			addToDocument(new Chunk(node.getName(), boldFont));
			margin = 0;
			writeTree(node.getChildren());
		}
	}
}
 
開發者ID:javamelody,項目名稱:javamelody,代碼行數:20,代碼來源:PdfMBeansReport.java

示例13: createParagraphElement

import com.lowagie.text.Chunk; //導入依賴的package包/類
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;
}
 
開發者ID:javamelody,項目名稱:javamelody,代碼行數:20,代碼來源:PdfDocumentFactory.java

示例14: addImage

import com.lowagie.text.Chunk; //導入依賴的package包/類
private float addImage(PdfPCell cell, String name) {
	try {
		java.awt.Image awtImage = (java.awt.Image)iImages.get(name);
		if (awtImage==null) return 0;
		Image img = Image.getInstance(awtImage, Color.WHITE);
		Chunk ck = new Chunk(img, 0, 0);
		if (cell.getPhrase()==null) {
			cell.setPhrase(new Paragraph(ck));
			cell.setVerticalAlignment(Element.ALIGN_TOP);
			cell.setHorizontalAlignment(Element.ALIGN_CENTER);
		} else {
			cell.getPhrase().add(ck);
		}
		return awtImage.getWidth(null);
	} catch (Exception e) {
		return 0;
	}
}
 
開發者ID:UniTime,項目名稱:unitime,代碼行數:19,代碼來源:PdfWebTable.java

示例15: addText

import com.lowagie.text.Chunk; //導入依賴的package包/類
private float addText(PdfPCell cell, String text, boolean bold, boolean italic, boolean underline, Color color, Color bgColor) {
	Font font = PdfFont.getFont(bold, italic, underline, color);
	Chunk chunk = new Chunk(text, font);
	if (bgColor!=null) chunk.setBackground(bgColor);
	if (cell.getPhrase()==null) {
	    cell.setPhrase(new Paragraph(chunk));
		cell.setVerticalAlignment(Element.ALIGN_TOP);
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
	} else {
		cell.getPhrase().add(chunk);
	}
	float width = 0; 
	if (text.indexOf('\n')>=0) {
		for (StringTokenizer s = new StringTokenizer(text,"\n"); s.hasMoreTokens();)
			width = Math.max(width,font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize()));
	} else 
		width = Math.max(width,font.getBaseFont().getWidthPoint(text, font.getSize()));
	return width;
}
 
開發者ID:UniTime,項目名稱:unitime,代碼行數:20,代碼來源:PdfWebTable.java


注:本文中的com.lowagie.text.Chunk類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。