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


Java ColumnText类代码示例

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


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

示例1: onEndPage

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {

	Phrase[] headers = new Phrase[3];

	PdfContentByte cb = writer.getDirectContent();

	headers[0] = new Phrase("CuacFM");
	ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, headers[0], document.left() + 80, document.bottom() - 20, 0);

	Date day = new Date();
	headers[1] = new Phrase(DateUtils.format(day, DateUtils.FORMAT_LOCAL));
	ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, headers[1], (document.right() - document.left()) / 2 + document.leftMargin(),
			document.bottom() - 20, 0);

	headers[2] = new Phrase(String.format("Página %d", writer.getCurrentPageNumber()));
	ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, headers[2], document.right() - 80, document.bottom() - 20, 0);
}
 
开发者ID:pablogrela,项目名称:members_cuacfm,代码行数:19,代码来源:CreatePdf.java

示例2: writePageAnchor

import com.lowagie.text.pdf.ColumnText; //导入依赖的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

示例3: breakPage

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
private boolean breakPage(boolean pageBreak, float upperYcoord) {
    
    if( pageBreak ) {
        ColumnText.showTextAligned(cb, Phrase.ALIGN_CENTER, new Phrase("-" + curPage + "-"), document.right()/2f, document.bottom()-(document.bottomMargin()/2f), 0f);
        ++curPage;
        try{
            document.newPage();
            
            // add promo text to new page
            addPromoText();
            
        }catch(Exception e){}
        if( curPage == numPages ) {
            maxLines = (numLines - totalLinesWritten) / NUMCOLS;
        }
        ct.setSimpleColumn(document.left(), document.bottom(), document.right()/2f, upperYcoord);
        pageBreak = false;
        
    } else {
        ct.setSimpleColumn(document.right()/2f, document.bottom(), document.right(), upperYcoord);
        pageBreak = true;
    }
    
    return pageBreak;
}
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:26,代码来源:PreventionPrintPdf.java

示例4: checkColumnFill

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
private boolean checkColumnFill(ColumnText ct, String preventionHeader, Font font, boolean pageBreak) {
    if( linesWritten + linesToBeWritten > maxLines ) {
        
        //reset upperYcoord for pages 2 and above
        if( curPage == 1 && pageBreak) {
            upperYcoord = document.top() - font.getCalculatedLeading(LINESPACING);
            pageHeight = upperYcoord - document.bottom();
            maxLines = (int)Math.floor(pageHeight/(font.getCalculatedLeading(LINESPACING)+4d));
            numPages = (int)Math.ceil(((double)numLines-totalLinesWritten)/((double)maxLines*NUMCOLS)) + 1;
        }
        pageBreak = breakPage(pageBreak, upperYcoord);
        linesWritten = 0;
        if( preventionHeader.length() > 0 ) {
            Phrase procHeaderContd = new Phrase(LEADING, "Prevention " + preventionHeader + " cont'd\n", font);
            ct.addText(procHeaderContd);
            ++linesToBeWritten;
        }
        
    }
    
    return pageBreak;
}
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:23,代码来源:PreventionPrintPdf.java

示例5: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
 * Demonstrates the use of layers.
 * 
 * @param args
 *            no arguments needed
 */
@Test
public void main() throws Exception {
	// step 1: creation of a document-object
	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	// step 2: creation of the writer
	PdfWriter writer = PdfWriter.getInstance(document,
			PdfTestBase.getOutputStream("optionalcontent.pdf"));
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	writer.setViewerPreferences(PdfWriter.PageModeUseOC);
	// step 3: opening the document
	document.open();
	// step 4: content
	PdfContentByte cb = writer.getDirectContent();
	Phrase explanation = new Phrase(
			"Automatic layers, form fields, images, templates and actions",
			new Font(Font.HELVETICA, 18, Font.BOLD, Color.red));
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50,
			650, 0);
	PdfLayer l1 = new PdfLayer("Layer 1", writer);
	PdfLayer l2 = new PdfLayer("Layer 2", writer);
	PdfLayer l3 = new PdfLayer("Layer 3", writer);
	PdfLayer l4 = new PdfLayer("Form and XObject Layer", writer);
	PdfLayerMembership m1 = new PdfLayerMembership(writer);
	m1.addMember(l2);
	m1.addMember(l3);
	Phrase p1 = new Phrase("Text in layer 1");
	Phrase p2 = new Phrase("Text in layer 2 or layer 3");
	Phrase p3 = new Phrase("Text in layer 3");
	cb.beginLayer(l1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0f);
	cb.endLayer();
	cb.beginLayer(m1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
	cb.endLayer();
	cb.beginLayer(l3);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
	cb.endLayer();
	TextField ff = new TextField(writer, new Rectangle(200, 600, 300, 620),
			"field1");
	ff.setBorderColor(Color.blue);
	ff.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
	ff.setBorderWidth(TextField.BORDER_WIDTH_THIN);
	ff.setText("I'm a form field");
	PdfFormField form = ff.getTextField();
	form.setLayer(l4);
	writer.addAnnotation(form);
	Image img = Image.getInstance(PdfTestBase.RESOURCES_DIR
			+ "pngnow.png");
	img.setLayer(l4);
	img.setAbsolutePosition(200, 550);
	cb.addImage(img);
	PdfTemplate tp = cb.createTemplate(100, 20);
	Phrase pt = new Phrase("I'm a template", new Font(Font.HELVETICA, 12,
			Font.NORMAL, Color.magenta));
	ColumnText.showTextAligned(tp, Element.ALIGN_LEFT, pt, 0, 0, 0);
	tp.setLayer(l4);
	tp.setBoundingBox(new Rectangle(0, -10, 100, 20));
	cb.addTemplate(tp, 200, 500);
	ArrayList<Object> state = new ArrayList<Object>();
	state.add("toggle");
	state.add(l1);
	state.add(l2);
	state.add(l3);
	state.add(l4);
	PdfAction action = PdfAction.setOCGstate(state, true);
	Chunk ck = new Chunk("Click here to toggle the layers", new Font(
			Font.HELVETICA, 18, Font.NORMAL, Color.yellow)).setBackground(
			Color.blue).setAction(action);
	ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(ck),
			250, 400, 0);
	cb.sanityCheck();

	// step 5: closing the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:82,代码来源:OptionalContentTest.java

示例6: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
    * Layer radio group and zoom.
    */
@Test
public void main() throws Exception {
       	// step 1
           Document document = new Document(PageSize.A4, 50, 50, 50, 50);
           // step 2
           PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "layers.pdf"));
           writer.setPdfVersion(PdfWriter.VERSION_1_5);
           writer.setViewerPreferences(PdfWriter.PageModeUseOC);
           // step 3
           document.open();
           // step 4
           PdfContentByte cb = writer.getDirectContent();
           Phrase explanation = new Phrase("Layer radio group and zoom", new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
           ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50, 650, 0);
           PdfLayer title = PdfLayer.createTitle("Layer radio group", writer);
           PdfLayer l1 = new PdfLayer("Layer 1", writer);
           PdfLayer l2 = new PdfLayer("Layer 2", writer);
           PdfLayer l3 = new PdfLayer("Layer 3", writer);
           PdfLayer l4 = new PdfLayer("Layer 4", writer);
           title.addChild(l1);
           title.addChild(l2);
           title.addChild(l3);
           l4.setZoom(2, -1);
           l4.setOnPanel(false);
           l4.setPrint("Print", true);
           l2.setOn(false);
           l3.setOn(false);
           ArrayList<PdfLayer> radio = new ArrayList<PdfLayer>();
           radio.add(l1);
           radio.add(l2);
           radio.add(l3);
           writer.addOCGRadioGroup(radio);
           Phrase p1 = new Phrase("Text in layer 1");
           Phrase p2 = new Phrase("Text in layer 2");
           Phrase p3 = new Phrase("Text in layer 3");
           Phrase p4 = new Phrase("Text in layer 4");
           cb.beginLayer(l1);
           ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
           cb.endLayer();
           cb.beginLayer(l2);
           ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
           cb.endLayer();
           cb.beginLayer(l3);
           ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
           cb.endLayer();
           cb.beginLayer(l4);
           ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p4, 50, 450, 0);
           cb.endLayer();
           ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, new Phrase("<< Zoom here!", new Font(Font.COURIER, 12, Font.NORMAL, Color.blue)), 150, 450, 0);
           // step 5
           document.close();

   }
 
开发者ID:albfernandez,项目名称:itext2,代码行数:57,代码来源:LayersTest.java

示例7: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
 * Demonstrates some Layer functionality.
 * 
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();
	// step 2:
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Layers.pdf"));
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	// step 3:
	writer.setViewerPreferences(PdfWriter.PageModeUseOC);
	document.open();
	// step 4:
	PdfContentByte cb = writer.getDirectContent();
	Phrase explanation = new Phrase("Layer grouping", new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50, 650, 0);
	PdfLayer l1 = new PdfLayer("Layer 1", writer);
	PdfLayer l2 = new PdfLayer("Layer 2", writer);
	PdfLayer l3 = new PdfLayer("Layer 3", writer);
	PdfLayerMembership m1 = new PdfLayerMembership(writer);
	m1.addMember(l2);
	m1.addMember(l3);
	Phrase p1 = new Phrase("Text in layer 1");
	Phrase p2 = new Phrase("Text in layer 2 or layer 3");
	Phrase p3 = new Phrase("Text in layer 3");
	cb.beginLayer(l1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
	cb.endLayer();
	cb.beginLayer(m1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
	cb.endLayer();
	cb.beginLayer(l3);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
	cb.endLayer();
	PdfOCProperties p = writer.getOCProperties();
	PdfArray order = new PdfArray();
	order.add(l1.getRef());
	PdfArray group = new PdfArray();
	group.add(new PdfString("A group of two", PdfObject.TEXT_UNICODE));
	group.add(l2.getRef());
	group.add(l3.getRef());
	order.add(group);
	PdfDictionary d = new PdfDictionary();
	d.put(PdfName.ORDER, order);
	p.put(PdfName.D, d);

	// step 5: we close the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:53,代码来源:LayersTest.java

示例8: render

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
@Override
public void render()
{
	ColumnText colText = new ColumnText(pdfContentByte);
	colText.setSimpleColumn(
		getPhrase(styledText, text),
		x + leftPadding,
		pdfExporter.getCurrentPageFormat().getPageHeight()
			- y
			- topPadding
			- verticalAlignOffset
			- text.getLeadingOffset(),
			//+ text.getLineSpacingFactor() * text.getFont().getSize(),
		x + width - rightPadding,
		pdfExporter.getCurrentPageFormat().getPageHeight()
			- y
			- height
			+ bottomPadding,
		0,//text.getLineSpacingFactor(),// * text.getFont().getSize(),
		horizontalAlignment == Element.ALIGN_JUSTIFIED_ALL ? Element.ALIGN_JUSTIFIED : horizontalAlignment
		);

	colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize());
	colText.setRunDirection(
		text.getRunDirectionValue() == RunDirectionEnum.LTR
		? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_RTL
		);

	try
	{
		colText.go();
	}
	catch (DocumentException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:38,代码来源:SimplePdfTextRenderer.java

示例9: addLittleElementWithJump

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
public void addLittleElementWithJump(Element littleElement)
  {
  	//20140226 - [email protected] - https://jira.sakaiproject.org/browse/EVALSYS-1100
  	//Adds a little element testing if it fits in current column.
  	try
  	{
   	responseArea.addElement(littleElement);
   	
   	status=responseArea.go();
	if (status==ColumnText.NO_MORE_COLUMN)
	{
		column = Math.abs(column - 1);
	
		if (column==0)
		{
			document.newPage();
			responseArea.setSimpleColumn(document.left(),document.top(),document.right()/2, document.bottom()+pagefooter);
		}
		else
		{
			responseArea.setSimpleColumn(document.right()/2,document.top(),document.right(), document.bottom()+pagefooter);
		}
	}
}
catch (DocumentException e) {
	// TODO Auto-generated catch block
	throw UniversalRuntimeException.accumulate(e, "Unable to add elements to PDF Report");
}
  }
 
开发者ID:sakaicontrib,项目名称:evaluation,代码行数:30,代码来源:EvalPDFReportBuilder.java

示例10: addHeaderAndFooter

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
private void addHeaderAndFooter(PdfWriter writer, Document document) {
	if (document.getPageNumber() == 1) {
		return;
	}
       String header = docInstallArgs.getDocName() + " version" + docInstallArgs.getVersion(); 
       PdfContentByte directContent = writer.getDirectContent();
	Phrase headerPhare = ItextUtil.getFontSelector(9, Font.NORMAL, Color.LIGHT_GRAY).process(header);
	headerPhare.add(new LineSeparator(0.5f, 2.5f, Color.LIGHT_GRAY, Element.ALIGN_LEFT, -5f));
	ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, 
       			headerPhare, document.left(), document.top() + 20, 0);
       
       String footer = Integer.valueOf(document.getPageNumber()).toString();
	ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, 
			textbFont.process(footer), document.getPageSize().getWidth() / 2.0f - 20, document.bottom() - 20, 0);
}
 
开发者ID:linkeer8802,项目名称:api-resolver,代码行数:16,代码来源:SimplePdfDocInstaller.java

示例11: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
 * Demonstrates how to group optional content.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {
	System.out.println("Grouping optional content");
	try {
		// step 1
		Document document = new Document(PageSize.A4, 50, 50, 50, 50);
		// step 2
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "contentgroups.pdf"));
		writer.setPdfVersion(PdfWriter.VERSION_1_5);
		writer.setViewerPreferences(PdfWriter.PageModeUseOC);
		// step 3
		document.open();
		// step 4
		PdfContentByte cb = writer.getDirectContent();
		Phrase explanation = new Phrase("Layer grouping", new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50, 650, 0);
		PdfLayer l1 = new PdfLayer("Layer 1", writer);
		PdfLayer l2 = new PdfLayer("Layer 2", writer);
		PdfLayer l3 = new PdfLayer("Layer 3", writer);
		PdfLayerMembership m1 = new PdfLayerMembership(writer);
		m1.addMember(l2);
		m1.addMember(l3);
		Phrase p1 = new Phrase("Text in layer 1");
		Phrase p2 = new Phrase("Text in layer 2 or layer 3");
		Phrase p3 = new Phrase("Text in layer 3");
		cb.beginLayer(l1);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
		cb.endLayer();
		cb.beginLayer(m1);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
		cb.endLayer();
		cb.beginLayer(l3);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
		cb.endLayer();
		cb.sanityCheck();

		PdfOCProperties p = writer.getOCProperties();
		PdfArray order = new PdfArray();
		order.add(l1.getRef());
		PdfArray group = new PdfArray();
		group.add(new PdfString("A group of two", PdfObject.TEXT_UNICODE));
		group.add(l2.getRef());
		group.add(l3.getRef());
		order.add(group);
		PdfDictionary d = new PdfDictionary();
		d.put(PdfName.ORDER, order);
		p.put(PdfName.D, d);
		// step 5
		document.close();
	} catch (Exception de) {
		de.printStackTrace();
	}
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:59,代码来源:ContentGroups.java

示例12: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
 * Demonstrates how to order optional content groups.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {
	System.out.println("Ordering optional content groups");
	try {
		// step 1
		Document document = new Document(PageSize.A4, 50, 50, 50, 50);
		// step 2
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "orderedlayers.pdf"));
		writer.setPdfVersion(PdfWriter.VERSION_1_5);
		writer.setViewerPreferences(PdfWriter.PageModeUseOC);
		// step 3
		document.open();
		// step 4
		PdfContentByte cb = writer.getDirectContent();
		Phrase explanation = new Phrase("Ordered layers", new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50, 650, 0);
		PdfLayer l1 = new PdfLayer("Layer 1", writer);
		PdfLayer l2 = new PdfLayer("Layer 2", writer);
		PdfLayer l3 = new PdfLayer("Layer 3", writer);
		PdfLayerMembership m1 = new PdfLayerMembership(writer);
		m1.addMember(l2);
		m1.addMember(l3);
		Phrase p1 = new Phrase("Text in layer 1");
		Phrase p2 = new Phrase("Text in layer 2 or layer 3");
		Phrase p3 = new Phrase("Text in layer 3");
		cb.beginLayer(l1);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
		cb.endLayer();
		cb.beginLayer(m1);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
		cb.endLayer();
		cb.beginLayer(l3);
		ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
		cb.endLayer();
		cb.sanityCheck();

		PdfOCProperties p = writer.getOCProperties();
		PdfArray order = new PdfArray();
		order.add(l1.getRef());
		order.add(l2.getRef());
		order.add(l3.getRef());
		PdfDictionary d = new PdfDictionary();
		d.put(PdfName.ORDER, order);
		p.put(PdfName.D, d);
		// step 5
		document.close();
	} catch (Exception de) {
		de.printStackTrace();
	}
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:56,代码来源:OrderedLayers.java

示例13: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
 * Demonstrates how to order optional content groups.
 * 
 * @param args
 *            no arguments needed
 */
@Test
public void main() throws Exception {
	// step 1
	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	// step 2
	PdfWriter writer = PdfWriter.getInstance(document,
			PdfTestBase.getOutputStream("orderedlayers.pdf"));
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	writer.setViewerPreferences(PdfWriter.PageModeUseOC);
	// step 3
	document.open();
	// step 4
	PdfContentByte cb = writer.getDirectContent();
	Phrase explanation = new Phrase("Ordered layers", new Font(
			Font.HELVETICA, 20, Font.BOLD, Color.red));
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50,
			650, 0);
	PdfLayer l1 = new PdfLayer("Layer 1", writer);
	PdfLayer l2 = new PdfLayer("Layer 2", writer);
	PdfLayer l3 = new PdfLayer("Layer 3", writer);
	PdfLayerMembership m1 = new PdfLayerMembership(writer);
	m1.addMember(l2);
	m1.addMember(l3);
	Phrase p1 = new Phrase("Text in layer 1");
	Phrase p2 = new Phrase("Text in layer 2 or layer 3");
	Phrase p3 = new Phrase("Text in layer 3");
	cb.beginLayer(l1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
	cb.endLayer();
	cb.beginLayer(m1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
	cb.endLayer();
	cb.beginLayer(l3);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
	cb.endLayer();
	cb.sanityCheck();

	PdfOCProperties p = writer.getOCProperties();
	PdfArray order = new PdfArray();
	order.add(l1.getRef());
	order.add(l2.getRef());
	order.add(l3.getRef());
	PdfDictionary d = new PdfDictionary();
	d.put(PdfName.ORDER, order);
	p.put(PdfName.D, d);
	// step 5
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:55,代码来源:OrderedLayersTest.java

示例14: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
 * Automatic grouping and nesting.
 */
@Test
public void main() throws Exception {
	// step 1
	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	// step 2
	PdfWriter writer = PdfWriter.getInstance(document,
			PdfTestBase.getOutputStream("automatic.pdf"));
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	writer.setViewerPreferences(PdfWriter.PageModeUseOC);
	// step 3
	document.open();
	// step 4
	PdfContentByte cb = writer.getDirectContent();
	Phrase explanation = new Phrase("Automatic layer grouping and nesting",
			new Font(Font.HELVETICA, 20, Font.BOLD, Color.red));
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50,
			650, 0);
	PdfLayer l12 = new PdfLayer("Layer nesting", writer);
	PdfLayer l1 = new PdfLayer("Layer 1", writer);
	PdfLayer l2 = new PdfLayer("Layer 2", writer);
	PdfLayer title = PdfLayer.createTitle("Layer grouping", writer);
	PdfLayer l3 = new PdfLayer("Layer 3", writer);
	PdfLayer l4 = new PdfLayer("Layer 4", writer);
	l12.addChild(l1);
	l12.addChild(l2);
	title.addChild(l3);
	title.addChild(l4);
	Phrase p1 = new Phrase("Text in layer 1");
	Phrase p2 = new Phrase("Text in layer 2");
	Phrase p3 = new Phrase("Text in layer 3");
	Phrase p4 = new Phrase("Text in layer 4");
	cb.beginLayer(l1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
	cb.endLayer();
	cb.beginLayer(l2);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
	cb.endLayer();
	cb.beginLayer(l3);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
	cb.endLayer();
	cb.beginLayer(l4);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p4, 50, 450, 0);
	cb.endLayer();
	cb.sanityCheck();

	// step 5
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:52,代码来源:AutomaticTest.java

示例15: main

import com.lowagie.text.pdf.ColumnText; //导入依赖的package包/类
/**
 * Demonstrates the use of nested layers
 * 
 * @param args
 *            no arguments needed
 */
@Test
public void main() throws Exception {
	// step 1
	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	// step 2
	PdfWriter writer = PdfWriter.getInstance(document,
			PdfTestBase.getOutputStream("nestedlayers.pdf"));
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	writer.setViewerPreferences(PdfWriter.PageModeUseOC);
	// step 3
	document.open();
	// step 4
	PdfContentByte cb = writer.getDirectContent();
	Phrase explanation = new Phrase("Layer nesting", new Font(
			Font.HELVETICA, 20, Font.BOLD, Color.red));
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50,
			650, 0);
	PdfLayer l1 = new PdfLayer("Layer 1", writer);
	PdfLayer l23 = new PdfLayer("Top Layer 2 3", writer);
	PdfLayer l2 = new PdfLayer("Layer 2", writer);
	PdfLayer l3 = new PdfLayer("Layer 3", writer);
	Phrase p1 = new Phrase("Text in layer 1");
	Phrase p2 = new Phrase("Text in layer 2");
	Phrase p3 = new Phrase("Text in layer 3");
	cb.beginLayer(l1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0);
	cb.endLayer();
	cb.beginLayer(l23);
	cb.beginLayer(l2);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
	cb.endLayer();
	cb.beginLayer(l3);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
	cb.endLayer();
	cb.endLayer();
	cb.sanityCheck();

	PdfOCProperties p = writer.getOCProperties();
	PdfArray order = new PdfArray();
	order.add(l1.getRef());
	order.add(l23.getRef());
	PdfArray group = new PdfArray();
	group.add(l2.getRef());
	group.add(l3.getRef());
	order.add(group);
	PdfDictionary d = new PdfDictionary();
	d.put(PdfName.ORDER, order);
	p.put(PdfName.D, d);
	// step 5
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:58,代码来源:NestedLayersTest.java


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