本文整理匯總了Java中com.itextpdf.kernel.pdf.canvas.PdfCanvas類的典型用法代碼示例。如果您正苦於以下問題:Java PdfCanvas類的具體用法?Java PdfCanvas怎麽用?Java PdfCanvas使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PdfCanvas類屬於com.itextpdf.kernel.pdf.canvas包,在下文中一共展示了PdfCanvas類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleEvent
import com.itextpdf.kernel.pdf.canvas.PdfCanvas; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
PdfDocumentEvent docEvent = (PdfDocumentEvent) event;
PdfCanvas canvas = new PdfCanvas(docEvent.getPage());
Rectangle pageSize = docEvent.getPage().getPageSize();
canvas.beginText();
try {
canvas.setFontAndSize(PdfFontFactory.createFont(FontConstants.HELVETICA_OBLIQUE), 20);
} catch (IOException e) {
e.printStackTrace();
}
// x = (pageSize.getLeft() + pageSize.getRight()) / 2;
// y = (pageSize.getTop() + pageSize.getBottom()) / 2;
canvas.moveText((pageSize.getRight() - doc.getRightMargin() - (pageSize.getLeft() + doc.getLeftMargin())) / 2 + doc.getLeftMargin(), pageSize.getTop() - doc.getTopMargin() + 10)
.showText("this is a header")
.moveText(0, (pageSize.getBottom() + doc.getBottomMargin()) - (pageSize.getTop() + doc.getTopMargin()) - 20)
.showText("this is a footer")
.endText()
.release();
}
示例2: handleEvent
import com.itextpdf.kernel.pdf.canvas.PdfCanvas; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
PdfDocumentEvent docEvent = (PdfDocumentEvent) event;
PdfDocument pdfDoc = docEvent.getDocument();
PdfPage page = docEvent.getPage();
PdfCanvas canvas = new PdfCanvas(page.newContentStreamBefore(),
page.getResources(), pdfDoc);
Rectangle area = page.getPageSize();
new Canvas(canvas, pdfDoc, area)
.add(images.get(offset));
offset++;
}
示例3: newPage
import com.itextpdf.kernel.pdf.canvas.PdfCanvas; //導入依賴的package包/類
private void newPage(){
this.currentPage = this.pdfDocument.addNewPage();
this.currentPageCanvas = new PdfCanvas(this.currentPage);
}