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


Java PdfContentByte.lineTo方法代码示例

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


在下文中一共展示了PdfContentByte.lineTo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: drawSexyTriangle

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private static void drawSexyTriangle(PdfWriter writer, boolean rotated)
{
    PdfContentByte canvas = writer.getDirectContent();
    float x = 36;
    float y = 400;
    float side = 70;
    PdfShading axial = rotated ?
            PdfShading.simpleAxial(writer, PageSize.A4.getRight() - y, x, PageSize.A4.getRight() - y, x + side, BaseColor.PINK, BaseColor.BLUE)
            : PdfShading.simpleAxial(writer, x, y, x + side, y, BaseColor.PINK, BaseColor.BLUE);
    PdfShadingPattern shading = new PdfShadingPattern(axial);
    canvas.setShadingFill(shading);
    canvas.moveTo(x,y);
    canvas.lineTo(x + side, y);
    canvas.lineTo(x + (side / 2), (float)(y + (side * Math.sin(Math.PI / 3))));
    canvas.closePathFillStroke();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:17,代码来源:DrawGradient.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: writePathIterator

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Write a path describing a graphic objects of straight lines, Bezier
 * curves, potentially with holes and islands.
 *
 * @param iterator The path iterator to write.
 * @param vectorSymbol The VectorSymbol specifying the appearance of pi.
 */
private void writePathIterator(GeoPathIterator iterator,
        VectorSymbol vectorSymbol, PdfContentByte cb) {

    // write colors and stroke width if necessary.
    this.writePaintingAttributes(vectorSymbol, cb);

    // write the path
    // remember the last written segment type and the point position.
    int lastSegmentType = GeoPathModel.NONE;
    do {
        final int type = iterator.getInstruction();
        switch (type) {
            case GeoPathModel.CLOSE:
                cb.closePath();
                writeFillStroke(vectorSymbol, true, cb); // !!! ??? needed?
                break;

            case GeoPathModel.MOVETO:
                writeFillStroke(vectorSymbol, false, cb);// !!! ??? needed?
                // start defintion of new path
                cb.moveTo((float)xToPagePx(iterator.getX()),
                        (float)yToPagePx(iterator.getY()));
                break;

            case GeoPathModel.LINETO:
                cb.lineTo((float)xToPagePx(iterator.getX()),
                        (float)yToPagePx(iterator.getY()));
                break;

            case GeoPathModel.QUADCURVETO:
                cb.curveTo((float)xToPagePx(iterator.getX()),
                        (float)yToPagePx(iterator.getY()),
                        (float)xToPagePx(iterator.getX2()),
                        (float)yToPagePx(iterator.getY2()));
                break;

            case GeoPathModel.CURVETO:
                cb.curveTo((float)xToPagePx(iterator.getX()),
                        (float)yToPagePx(iterator.getY()),
                        (float)xToPagePx(iterator.getX2()),
                        (float)yToPagePx(iterator.getY2()),
                        (float)xToPagePx(iterator.getX3()),
                        (float)yToPagePx(iterator.getY3()));
                break;
        }
        lastSegmentType = type;
    } while (iterator.next());

    if (lastSegmentType != PathIterator.SEG_CLOSE
            && lastSegmentType != PathIterator.SEG_MOVETO) {
        this.writeFillStroke(vectorSymbol, false, cb);
    }
}
 
开发者ID:OSUCartography,项目名称:ScreePainter,代码行数:61,代码来源:PDFExporter.java

示例10: createGeometricObjects

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private void createGeometricObjects(PdfContentByte cb, long amountOfCarts, Document doc) {
    // first big grey block
    // float y 310 h 325
    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.rectangle(0.0f, 325f - (amountOfCarts + 1) * 16f, 595.0f, 310 + (amountOfCarts + 1) * 16f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // name and address block
    cb.saveState();
    cb.setRGBColorFill(0xFC, 0xFC, 0xFC);
    cb.rectangle(75.0f, 410.0f, 445.0f, 120.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // price block
    cb.saveState();
    cb.setRGBColorFill(0xFC, 0xFC, 0xFC);
    cb.rectangle(75.0f, 350f - (amountOfCarts + 1) * 16f, 295f, 45f + (amountOfCarts + 1) * 16f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // date block
    cb.saveState();
    cb.setRGBColorFill(0xFC, 0xFC, 0xFC);
    cb.rectangle(385.0f, 350f - (amountOfCarts + 1) * 16f, 135f, 45f + (amountOfCarts + 1) * 16f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // small triangle in address block
    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.moveTo(74f, 455f);
    cb.lineTo(74f, 485f);
    cb.lineTo(82f, 470f);
    cb.lineTo(74f, 455f);
    cb.fill();
    cb.closePathStroke();
    cb.restoreState();

    // small triangle in price block
    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.moveTo(74f, 350f);
    cb.lineTo(74f, 380f);
    cb.lineTo(82f, 365f);
    cb.lineTo(74f, 350f);
    cb.fill();
    cb.closePathStroke();
    cb.restoreState();

}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:58,代码来源:PdfReceiptView.java


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