本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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();
}
示例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());
}
示例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;
}
}
示例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;
}
}