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


Java PDPageContentStream.drawLine方法代码示例

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


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

示例1: create

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
public void create(PDDocument document, PDFPage page) throws IOException {

	PDPageContentStream cs = new PDPageContentStream(document, page, true, false);
       
	PDRectangle pageSize = page.getBleedBox();
       float pageWidth = pageSize.getWidth();
       page.translateAndRotateIfNecessary(cs, pageWidth, 0);
       
	cs.beginText();
	PDFont font = PDType1Font.HELVETICA_BOLD;
	cs.setFont(font, 20);
	cs.moveTextPositionByAmount(page.getLeftX(), page.getTopY());
	cs.drawString(title);
	cs.endText();
	cs.drawLine(page.getLeftX(), page.getTopY()-height, page.getRightX(), page.getTopY()-height);
		cs.close();
}
 
开发者ID:purbon,项目名称:pdfwriter,代码行数:18,代码来源:PageHeader.java

示例2: addTitleRow

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
public void addTitleRow(String[] titles) throws IOException {
	if (hideTable)
		return;
	int size = 16;
	float cellSize = (getWidth()/titles.length);
	PDFont font = PDType1Font.HELVETICA_BOLD;
	PDPageContentStream cs = new PDPageContentStream(document, page, true, 	false);
	cs.setFont(font, size);
	float leftX = getLeftX()+30;

	for (String title : titles) {
		cs.beginText();
		cs.moveTextPositionByAmount(leftX, page.getYCursor());
		cs.drawString(title);
		cs.endText();
		if (cellSize != -1)
			leftX += cellSize;
		else
			leftX += (font.getStringWidth(title) / 1000 * size)+5;
	}
	cs.drawLine(getLeftX(), page.getYCursor() - 5, getRightX(), page.getYCursor() - 5);
	cs.close();
	
	scrolldown();
}
 
开发者ID:purbon,项目名称:pdfwriter,代码行数:26,代码来源:PDFTable.java

示例3: newPage

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
void newPage() throws IOException
{
    close();

    PDPage page = new PDPage(PDPage.PAGE_SIZE_LETTER);
    doc.addPage(page);
    content = new PDPageContentStream(doc, page);
    content.drawImage(logoImg, 50, 720);
    content.setLineWidth(.5f);
    content.setNonStrokingColor(Color.GRAY);
    content.drawLine(50, 710, 562, 710);

    previousBandBase = 770;
    render(new BandColumn(BandColumn.Layout.headerText, "ENDOSO", null));
    for (String head: header)
        render(new BandColumn(BandColumn.Layout.headerText, head, null));

    content.setNonStrokingColor(Color.BLACK);
    previousBandBase = 680;
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:21,代码来源:PdfRenderingEndorsementAlternative.java

示例4: flushTableRow

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
protected void flushTableRow(String[] elements, PDFont font, int size, float cellSize) throws IOException {
	PDPageContentStream cs = new PDPageContentStream(document, page, true, 	false);
	cs.setFont(font, size);
	float leftX = getLeftX();
	for (String element : elements) {
		cs.beginText();
		cs.moveTextPositionByAmount(leftX, page.getYCursor());
		cs.drawString(element);
		cs.endText();
		if (cellSize != -1)
			leftX += cellSize;
		else
			leftX += (font.getStringWidth(element) / 1000 * size)+5;
	}
	cs.drawLine(getLeftX(), page.getYCursor() - 5, getRightX(), page.getYCursor() - 5);
	cs.close();
}
 
开发者ID:purbon,项目名称:pdfwriter,代码行数:18,代码来源:PDFTable.java

示例5: draw

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
public void draw(PDPageContentStream contentStream) throws IOException {
    if (color != null) {
	contentStream.setStrokingColor(color);
    }
    if (stroke != null) {
	stroke.applyTo(contentStream);
    }
    contentStream.drawLine(start.getX(), start.getY(), end.getX(),
	    end.getY());
}
 
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:11,代码来源:UnderlineAnnotationProcessor.java

示例6: drawTable

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
public static void drawTable(PDPage page,
		PDPageContentStream contentStream, float y, float margin,
		String[][] content) throws IOException {
	final int rows = content.length;
	final int cols = content[0].length;
	final float rowHeight = 20f;
	final float tableWidth = page.findMediaBox().getWidth() - (2 * margin);
	final float tableHeight = rowHeight * rows;
	final float colWidth = tableWidth / (float) cols;
	final float cellMargin = 5f;

	float nexty = y;
	for (int i = 0; i <= rows; i++) {
		contentStream.drawLine(margin, nexty, margin + tableWidth, nexty);
		nexty -= rowHeight;
	}

	// draw the columns
	float nextx = margin;
	for (int i = 0; i <= cols; i++) {
		contentStream.drawLine(nextx, y, nextx, y - tableHeight);
		nextx += colWidth;
	}

	// now add the text
	contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12);

	float textx = margin + cellMargin;
	float texty = y - 15;
	for (int i = 0; i < content.length; i++) {
		for (int j = 0; j < content[i].length; j++) {
			String text = content[i][j];
			contentStream.beginText();
				if(i == 0) {
					contentStream.setNonStrokingColor(Color.BLUE); 
				} else {
					contentStream.setNonStrokingColor(Color.BLACK);
				}
				contentStream.moveTextPositionByAmount(textx, texty);
				contentStream.drawString(text);
			contentStream.endText();
			textx += colWidth;
		}
		texty -= rowHeight;
		textx = margin + cellMargin;
	}
}
 
开发者ID:rmohta,项目名称:pdfboxExamples,代码行数:48,代码来源:PdfTable.java

示例7: drawTable

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
public static void drawTable(PDPage page, PDPageContentStream contentStream,
                             float y, float margin,
                             List<List<String>> content) throws IOException {

    final int rows = content.size();
    final int cols = content.get(0).size();

    final float rowHeight = 20f;
    final float tableWidth = page.findMediaBox().getWidth() - (2 * margin);
    final float tableHeight = rowHeight * rows;
    final float colWidth = tableWidth / (float) cols;
    final float cellMargin = 5f;

    //draw the rows
    float nexty = y;
    for (int i = 0; i <= rows; i++) {
        contentStream.drawLine(margin, nexty, margin + tableWidth, nexty);
        nexty -= rowHeight;
    }

    //draw the columns
    float nextx = margin;
    for (int i = 0; i <= cols; i++) {
        contentStream.drawLine(nextx, y, nextx, y - tableHeight);
        nextx += colWidth;
    }

    //now add the text
    contentStream.setFont(PDType1Font.HELVETICA_BOLD, 12);

    float textx = margin + cellMargin;
    float texty = y - 15;
    for (List<String> content1 : content) {
        for (String text : content1) {
            contentStream.beginText();
            contentStream.moveTextPositionByAmount(textx, texty);
            contentStream.drawString(text);
            contentStream.endText();
            textx += colWidth;
        }
        texty -= rowHeight;
        textx = margin + cellMargin;
    }

}
 
开发者ID:bcdy23,项目名称:CZ3003_Backend,代码行数:46,代码来源:CReport.java


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