Java Code Examples for org.apache.pdfbox.pdmodel.edit.PDPageContentStream#drawLine()

The following examples show how to use org.apache.pdfbox.pdmodel.edit.PDPageContentStream#drawLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReportGenerator.java    From carbon-apimgt with Apache License 2.0 7 votes vote down vote up
private void drowTableGrid(PDPageContentStream contentStream, int numberOfRows) throws IOException {
    float nextY = TABLE_TOP_Y;
    // draw horizontal lines
    for (int i = 0; i <= numberOfRows + 1; i++) {
        contentStream.drawLine(CELL_MARGIN, nextY, CELL_MARGIN + TABLE_WIDTH, nextY);
        nextY -= ROW_HEIGHT;
    }

    // draw vertical lines
    final float tableYLength = ROW_HEIGHT + (ROW_HEIGHT * numberOfRows);
    final float tableBottomY = TABLE_TOP_Y - tableYLength;
    float nextX = CELL_MARGIN;
    for (int i = 0; i < COLUMN_WIDTH.length; i++) {
        contentStream.drawLine(nextX, TABLE_TOP_Y, nextX, tableBottomY);
        nextX += COLUMN_WIDTH[i];
    }
    contentStream.drawLine(CELL_MARGIN + TABLE_WIDTH, TABLE_TOP_Y, CELL_MARGIN + TABLE_WIDTH, tableBottomY);
}
 
Example 2
Source File: UnderlineAnnotationProcessor.java    From pdfbox-layout with MIT License 5 votes vote down vote up
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());
}