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


Java PdfContentByte.stroke方法代码示例

本文整理汇总了Java中com.itextpdf.text.pdf.PdfContentByte.stroke方法的典型用法代码示例。如果您正苦于以下问题:Java PdfContentByte.stroke方法的具体用法?Java PdfContentByte.stroke怎么用?Java PdfContentByte.stroke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.itextpdf.text.pdf.PdfContentByte的用法示例。


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

示例1: onRender

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
@Override
public void onRender(PdfContentByte cb) throws PdfRenderException {
	
	Integer[] pageSizes = getPage().getPdfDocument().getSize();
	float[] pos = getPosition();
	float[] moveTo = getMoveTo();
	cb.setLineWidth( getThickness() );
	cb.setColorStroke(  getBaseColor() );		
	float y1 = pageSizes[1] + SizeFactory.CUT_MARK - pos[1]; // seams strange but pdf starts bottom and up.
	float y2 = pageSizes[1] + SizeFactory.CUT_MARK - moveTo[1];
	// x , y. y is backward in pdf so start pos is the entire page height
	cb.moveTo( SizeFactory.millimetersToPostscriptPoints( pos[0] + SizeFactory.CUT_MARK ) , SizeFactory.millimetersToPostscriptPoints( y1 ) );
	cb.lineTo( SizeFactory.millimetersToPostscriptPoints(  moveTo[0] + SizeFactory.CUT_MARK ) , SizeFactory.millimetersToPostscriptPoints( y2 ) );
	cb.stroke();
	
}
 
开发者ID:Billes,项目名称:pdf-renderer,代码行数:17,代码来源:Line.java

示例2: mark

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
void mark(InputStream input, OutputStream output, Pattern pattern) throws DocumentException, IOException
{
    PdfReader reader = new PdfReader(input);
    PdfStamper stamper = new PdfStamper(reader, output);
    try {
        PdfReaderContentParser parser = new PdfReaderContentParser(reader);
        for (int pageNr = 1; pageNr <= reader.getNumberOfPages(); pageNr++)
        {
            SearchTextLocationExtractionStrategy strategy = new SearchTextLocationExtractionStrategy(pattern);
            parser.processContent(pageNr, strategy, Collections.emptyMap()).getResultantText();
            Collection<TextRectangle> locations = strategy.getLocations(null);
            if (locations.isEmpty())
                continue;

            PdfContentByte canvas = stamper.getOverContent(pageNr);
            canvas.setRGBColorStroke(255, 255, 0);
            for (TextRectangle location : locations)
            {
                canvas.rectangle(location.getMinX(), location.getMinY(), location.getWidth(), location.getHeight());
            }
            canvas.stroke();
        }
        stamper.close();
    } finally {
        reader.close();
    }
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:28,代码来源:TextLocationExtraction.java

示例3: writeFillStroke

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Writes commands to stroke and / or fill the last geometry.
 */
private void writeFillStroke(VectorSymbol symbol, boolean close, PdfContentByte cb) {
    if (symbol == null) {
        return;
    }

    final boolean fill = symbol.isFilled();
    final boolean stroke = symbol.isStroked();

    if (fill && stroke) {
        cb.fillStroke();
    } else if (fill) {
        cb.fill();
    } else if (stroke) {
        cb.stroke();
    } else // nothing: invisible element
        ;
}
 
开发者ID:OSUCartography,项目名称:ScreePainter,代码行数:21,代码来源:PDFExporter.java

示例4: createCircleAndText

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
public static void createCircleAndText(PdfContentByte cb, String text, float xCoord, float yCoord, float radius, Font textFont, int circleColorRed, int circleColorGreen, int circleColorBlue)
        throws DocumentException, IOException {
    cb.saveState();
    cb.setRGBColorFill(circleColorRed, circleColorGreen, circleColorBlue);
    cb.circle(xCoord, yCoord, radius);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    PdfPTable table = new PdfPTable(1);
    float[] rows = { 595f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(radius * 2);
    table.addCell(new Phrase(new Chunk(text, textFont)));
    table.writeSelectedRows(0, 1, 0, yCoord + radius, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:20,代码来源:PdfHelper.java

示例5: drawFooter

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
public void drawFooter(PdfContentByte canvas, PageInfos pageInfos) {
    if (pageInfos.getRawPageNumber() == 1 && !footerOnFirstPage)
        return;

    if (drawLine) {
        BaseColor lineColor = styles.getColorOrDefault(HEADER_LINE_COLOR);
        canvas.saveState();
        canvas.setColorStroke(lineColor);
        canvas.setLineWidth(1.2f);
        canvas.moveTo(rect.getLeft(), rect.getBottom() - 6);
        canvas.lineTo(rect.getRight(), rect.getBottom() - 6);
        canvas.stroke();
        canvas.restoreState();
    }

    float bottom = rect.getBottom() - 20;
    Phrase footer = footerText(pageInfos);
    if (footer != null) {
        showTextAligned(canvas, Element.ALIGN_LEFT, footer, rect.getLeft(), bottom, 0);
    }

    Font footerFont = styles.getFontOrDefault(FOOTER_FONT);

    Phrase page = new Phrase(pageInfos.getFormattedPageNumber(), footerFont);
    showTextAligned(canvas, Element.ALIGN_RIGHT, page, rect.getRight(), bottom, 0);
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:27,代码来源:HeaderFooter.java

示例6: drawFooter

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
public void drawFooter(PdfContentByte canvas, PageInfos pageInfos) {
    if (lineColor != null) {
        canvas.saveState();
        canvas.setColorStroke(lineColor);
        canvas.setLineWidth(1.2f);
        canvas.moveTo(rect.getLeft(), rect.getBottom() - 6);
        canvas.lineTo(rect.getRight(), rect.getBottom() - 6);
        canvas.stroke();
        canvas.restoreState();
    }

    float bottom = rect.getBottom() - 20;
    Phrase footer = footerText();
    if (footer != null) {
        showTextAligned(canvas, Element.ALIGN_LEFT, footer, rect.getLeft(), bottom, 0);
    }

    Phrase page = new Phrase(pageInfos.getFormattedPageNumber(), footerFont);
    showTextAligned(canvas, Element.ALIGN_RIGHT, page, rect.getRight(), bottom, 0);
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:21,代码来源:HeaderFooter.java

示例7: testSimple

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
@Test
public void testSimple() throws FileNotFoundException, DocumentException
{
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "transparency.pdf")));
    writer.setCompressionLevel(0);
    document.open();
    PdfContentByte content = writer.getDirectContent();

    content.setRGBColorStroke(0, 255, 0);
    for (int y = 0; y <= 400; y+= 10)
    {
        content.moveTo(0, y);
        content.lineTo(500, y);
    }
    for (int x = 0; x <= 500; x+= 10)
    {
        content.moveTo(x, 0);
        content.lineTo(x, 400);
    }
    content.stroke();

    
    content.saveState();
    PdfGState state = new PdfGState();
    state.setFillOpacity(0.5f);
    content.setGState(state);
    content.setRGBColorFill(255, 0, 0);
    content.moveTo(162, 86);
    content.lineTo(162, 286);
    content.lineTo(362, 286);
    content.lineTo(362, 86);
    content.closePath();
    //content.fillStroke();
    content.fill();
    
    content.restoreState();

    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:41,代码来源:TestTransparency.java

示例8: enhance

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
void enhance(PdfContentByte page, Collection<Rectangle2D> rectangles)
{
    for (Rectangle2D rectangle : rectangles)
    {
        page.setColorStroke(pickColor());
        page.rectangle((float) rectangle.getMinX(), (float) rectangle.getMinY(), (float) rectangle.getWidth(), (float) rectangle.getHeight());
        page.stroke();
    }
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:10,代码来源:FindFreeSpace.java

示例9: createHeaderBlock

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
public static void createHeaderBlock(PdfContentByte cb, int pageNumber, int pageSize) throws DocumentException, IOException {
    cb.saveState();
    cb.setColorFill(BaseColor.BLACK);
    cb.rectangle(0.0f, 822.0f, 595.0f, 20.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    Font textFont = new Font(FontFamily.HELVETICA, 7, Font.NORMAL, BaseColor.WHITE);

    PdfPTable table = new PdfPTable(4);
    float[] rows = { 100f, 100f, 100f, 295f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(20);
    table.addCell(new Phrase(new Chunk("WALD 1.1 gGmbH", textFont)));
    table.addCell(new Phrase(new Chunk("[ Spendenkonto 222 888 ]", textFont)));
    table.addCell(new Phrase(new Chunk("www.iplantatree.org", textFont)));
    
    PdfPCell pageCell = new PdfPCell(new Phrase(new Chunk("Seite " + pageNumber + " von " + pageSize, textFont)));
    pageCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    pageCell.setBorder(PdfPCell.NO_BORDER);
    table.addCell(pageCell);
    table.writeSelectedRows(0, 1, 0, 842, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:28,代码来源:PdfHelper.java

示例10: render

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
public void render(PdfWriter writer, Document document){
	
	Cutmarks cutmarks = request.getCutmarks();
	if(  cutmarks != null && ! cutmarks.isIgnoreCutStroke()  ){
		
		float width = SizeFactory.CUT_MARK;
		float height = SizeFactory.CUT_MARK;
		float lineWidth = SizeFactory.CUT_MARK_LINE;
		float lineHeight = SizeFactory.CUT_MARK_LINE;
		Rectangle rect = document.getPageSize();
		PdfContentByte cb = writer.getDirectContent();
		cb.setLineWidth( 0.1f );


		cb.moveTo( SizeFactory.millimetersToPostscriptPoints(width), 0);
		cb.lineTo( SizeFactory.millimetersToPostscriptPoints(width),SizeFactory.millimetersToPostscriptPoints(lineHeight));
		cb.stroke();
		
		
		cb.moveTo( 0, SizeFactory.millimetersToPostscriptPoints(height));
		cb.lineTo( SizeFactory.millimetersToPostscriptPoints(lineWidth),SizeFactory.millimetersToPostscriptPoints(height));
		cb.stroke();
		
		// Upper left cut mark
		cb.moveTo( SizeFactory.millimetersToPostscriptPoints(width), rect.getHeight() );
		cb.lineTo( SizeFactory.millimetersToPostscriptPoints(width), rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(lineHeight));
		cb.stroke();
		
		cb.moveTo( 0, rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height));
		cb.lineTo( SizeFactory.millimetersToPostscriptPoints(lineWidth),rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height));
		cb.stroke();
		
		/**
		 * Upper right cut mark
		 */
		cb.moveTo( rect.getWidth(), rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height));
		cb.lineTo( rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(lineWidth),rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height));
		cb.stroke();
		cb.moveTo( rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width), rect.getHeight() );
		cb.lineTo( rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width),rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(lineHeight));
		cb.stroke();
		
		/**
		 * Lower right cut mark
		 */
		cb.moveTo( rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width), 0 );
		cb.lineTo( rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width),SizeFactory.millimetersToPostscriptPoints(lineHeight));
		cb.stroke();
		
		cb.moveTo( rect.getWidth() , SizeFactory.millimetersToPostscriptPoints(height) );
		cb.lineTo( rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(lineWidth),SizeFactory.millimetersToPostscriptPoints(height));
		cb.stroke();
	}
}
 
开发者ID:Billes,项目名称:pdf-renderer,代码行数:55,代码来源:CutmarksRenderer.java

示例11: testComplex

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
@Test
public void testComplex() throws FileNotFoundException, DocumentException
{
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "transparencyComplex.pdf")));
    writer.setCompressionLevel(0);
    document.open();
    PdfContentByte content = writer.getDirectContent();

    content.setRGBColorStroke(0, 255, 0);
    for (int y = 0; y <= 400; y+= 10)
    {
        content.moveTo(0, y);
        content.lineTo(500, y);
    }
    for (int x = 0; x <= 500; x+= 10)
    {
        content.moveTo(x, 0);
        content.lineTo(x, 400);
    }
    content.stroke();

    PdfTemplate template = content.createTemplate(500, 400);
    PdfTransparencyGroup group = new PdfTransparencyGroup();
    group.put(PdfName.CS, PdfName.DEVICEGRAY);
    group.setIsolated(false);
    group.setKnockout(false);
    template.setGroup(group);
    PdfShading radial = PdfShading.simpleRadial(writer, 262, 186, 10, 262, 186, 190, BaseColor.WHITE, BaseColor.BLACK, true, true);
    template.paintShading(radial);

    PdfDictionary mask = new PdfDictionary();
    mask.put(PdfName.TYPE, PdfName.MASK);
    mask.put(PdfName.S, new PdfName("Luminosity"));
    mask.put(new PdfName("G"), template.getIndirectReference());

    content.saveState();
    PdfGState state = new PdfGState();
    state.put(PdfName.SMASK, mask);
    content.setGState(state);
    content.setRGBColorFill(255, 0, 0);
    content.moveTo(162, 86);
    content.lineTo(162, 286);
    content.lineTo(362, 286);
    content.lineTo(362, 86);
    content.closePath();
    //content.fillStroke();
    content.fill();
    
    content.restoreState();

    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:54,代码来源:TestTransparency.java

示例12: markLineBoundaries

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
void markLineBoundaries(String resource, int startPage, int endPage) throws IOException, DocumentException
{
    String name = new File(resource).getName();
    String target = String.format("%s-lines-%s-%s.pdf", name, startPage, endPage);
    InputStream resourceStream = getClass().getResourceAsStream(resource);
    try
    {
        PdfReader reader = new PdfReader(resourceStream);
        PdfReaderContentParser parser = new PdfReaderContentParser(reader);
        System.out.printf("\nLine boundaries in %s\n", name);

        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(new File(RESULT_FOLDER, target)));
        
        for (int page = startPage; page < endPage; page++)
        {
            System.out.printf("\n   Page %s\n   ", page);
            
            TextLineFinder finder = new TextLineFinder();
            parser.processContent(page, finder);

            PdfContentByte over = stamper.getOverContent(page);
            Rectangle mediaBox = reader.getPageSize(page);
            
            for (float flip: finder.verticalFlips)
            {
                System.out.printf(" %s", flip);
                over.moveTo(mediaBox.getLeft(), flip);
                over.lineTo(mediaBox.getRight(), flip);
            }

            System.out.println();
            over.stroke();
        }

        stamper.close();
    }
    finally
    {
        if (resourceStream != null)
            resourceStream.close();
    }
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:43,代码来源:ExtractSuperAndSubInLine.java

示例13: onEndPage

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    PdfContentByte cb = writer.getDirectContent();
    cb.saveState();
    // write the headertable
    table.setTotalWidth(document.right() - document.left());
    table.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 50, cb);
    // compose the footer
    String text = "Page " + writer.getPageNumber() + " of ";
    float textSize = helv.getWidthPoint(text, 12);
    float textBase = document.bottom() - 20;
    cb.beginText();
    cb.setFontAndSize(helv, 12);
    // for odd pagenumbers, show the footer at the left
    if ((writer.getPageNumber() & 1) == 1) {
        cb.setTextMatrix(document.left(), textBase);
        cb.showText(text);
        cb.endText();
        cb.addTemplate(tpl, document.left() + textSize, textBase);
    }
    // for even numbers, show the footer at the right
    else {
        float adjust = helv.getWidthPoint("0", 12);
        cb.setTextMatrix(document.right() - textSize - adjust, textBase);
        cb.showText(text);
        cb.endText();
        cb.addTemplate(tpl, document.right() - adjust, textBase);
    }
    cb.saveState();
    // draw a Rectangle around the page
    cb.setColorStroke(BaseColor.ORANGE);
    cb.setLineWidth(2);
    cb.rectangle(20, 20, document.getPageSize().getWidth() - 40, document.getPageSize().getHeight() - 40);
    cb.stroke();
    cb.restoreState();
    // starting on page 3, a watermark with an Image that is made transparent
    if (writer.getPageNumber() >= 3) {
        cb.setGState(gstate);
        cb.setColorFill(BaseColor.RED);
        cb.beginText();
        cb.setFontAndSize(helv, 48);
        cb.showTextAligned(Element.ALIGN_CENTER, "Watermark Opacity " + writer.getPageNumber(), document.getPageSize().getWidth() / 2, document.getPageSize().getHeight() / 2, 45);
        cb.endText();
        try {
            cb.addImage(headerImage, headerImage.getWidth(), 0, 0, headerImage.getHeight(), 440, 80);
        }
        catch(Exception e) {
            throw new ExceptionConverter(e);
        }
        cb.restoreState();
    }
    cb.sanityCheck();
}
 
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:56,代码来源:PageNumbersWatermark.java

示例14: createBlueBlock

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private void createBlueBlock(PdfContentByte cb, int treeCount) throws DocumentException {
    cb.saveState();
    cb.setRGBColorFill(0x64, 0xA7, 0xBD);
    cb.rectangle(0.0f, 375.0f, 595.0f, 200.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    Font textFont = new Font(FontFamily.TIMES_ROMAN, 14, Font.ITALIC, BaseColor.WHITE);
    Font textBlack = new Font(FontFamily.TIMES_ROMAN, 14, Font.ITALIC, BaseColor.BLACK);
    Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
    PdfPTable tableForTreeCount = new PdfPTable(1);
    float[] rows = { 495f };
    tableForTreeCount.setTotalWidth(rows);
    tableForTreeCount.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    tableForTreeCount.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    tableForTreeCount.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tableForTreeCount.getDefaultCell().setFixedHeight(40);

    Integer treeCountAsObject = treeCount;
    tableForTreeCount.addCell(new Phrase(new Chunk(treeCountAsObject.toString(), textFontTreeCount)));

    tableForTreeCount.writeSelectedRows(0, 1, 50f, 575f, cb);

    PdfPTable tableForWhiteText = new PdfPTable(1);
    tableForWhiteText.setTotalWidth(rows);
    tableForWhiteText.getDefaultCell().setBorder(Rectangle.BOTTOM);
    tableForWhiteText.getDefaultCell().setBorderWidth(1f);
    tableForWhiteText.getDefaultCell().setBorderColor(BaseColor.WHITE);
    tableForWhiteText.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    tableForWhiteText.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tableForWhiteText.getDefaultCell().setFixedHeight(40);

    Phrase phraseForTreesPlantForYou = new Phrase();
    if (treeCount == 1) {
        phraseForTreesPlantForYou.add(new Chunk("Baum wurde für Sie gepflanzt!", textFont));
    } else {
        phraseForTreesPlantForYou.add(new Chunk("Bäume wurden für Sie gepflanzt!", textFont));
    }

    PdfPCell longTextCell = new PdfPCell();
    longTextCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    longTextCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    longTextCell.setBorder(Rectangle.BOTTOM);
    longTextCell.setBorderWidth(1f);
    longTextCell.setBorderColor(BaseColor.WHITE);
    longTextCell.setFixedHeight(65);

    Paragraph longText = new Paragraph(new Chunk(
            "Mit diesem Gutschein können sie Ihre Pflanzung in Augenschein nehmen und mehr über die naturnahen Aufforstungsprojekte bei \"I Plant A Tree\" erfahren. Ihre Bäume wachsen auf ehemals brachliegenden Flächen und sind Teil neu entstehender Wälder.",
            textFont));
    longText.setLeading(15f);

    longTextCell.addElement(longText);

    tableForWhiteText.addCell(phraseForTreesPlantForYou);
    tableForWhiteText.addCell(longTextCell);
    tableForWhiteText.writeSelectedRows(0, 2, 50f, 535f, cb);

    PdfPTable tableForHowItWorks = new PdfPTable(1);
    tableForHowItWorks.setTotalWidth(rows);
    tableForHowItWorks.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    tableForHowItWorks.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    tableForHowItWorks.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tableForHowItWorks.getDefaultCell().setFixedHeight(40);

    tableForHowItWorks.addCell(new Phrase(new Chunk("Und so einfach funktioniert's:", textBlack)));

    tableForHowItWorks.writeSelectedRows(0, 2, 50f, 425f, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:71,代码来源:PdfGiftView.java

示例15: createTreeCountAndCustomTextBlock

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private void createTreeCountAndCustomTextBlock(PdfContentByte cb, String customText, int treeCount) throws DocumentException {
    Font textFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.ITALIC, BaseColor.BLACK);
    Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
    Font customTextFont = new Font(FontFamily.HELVETICA, 12, Font.NORMAL, BaseColor.BLACK);

    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.rectangle(0.0f, 325.0f, 595.0f, 205.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    Integer treeCountAsObj = treeCount;

    PdfPTable table = new PdfPTable(1);
    float[] rows = { 595f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(35);
    table.addCell(new Phrase(new Chunk("über die Pflanzung von", textFont)));
    table.addCell(new Phrase(new Chunk(treeCountAsObj.toString(), textFontTreeCount)));
    table.addCell(new Phrase(new Chunk("Bäumen", textFont)));
    table.writeSelectedRows(0, 3, 0, 520, cb);

    cb.saveState();
    cb.setRGBColorFill(0xF7, 0xF2, 0xF4);
    cb.rectangle(50.0f, 345.0f, 495.0f, 60.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    PdfPTable textTable = new PdfPTable(1);
    float[] textRows = { 475f };
    textTable.setTotalWidth(textRows);
    textTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    textTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    textTable.getDefaultCell().setFixedHeight(40);
    textTable.addCell(new Phrase(new Chunk(customText, customTextFont)));
    textTable.writeSelectedRows(0, 1, 60, 395, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:43,代码来源:PdfCertificateView.java


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