本文整理汇总了Java中com.lowagie.text.Document.getPageSize方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getPageSize方法的具体用法?Java Document.getPageSize怎么用?Java Document.getPageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.Document
的用法示例。
在下文中一共展示了Document.getPageSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEndPage
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter,
* com.lowagie.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable head = new PdfPTable(3);
for (int k = 1; k <= 6; ++k)
head.addCell("head " + k);
head.setTotalWidth(page.getWidth() - document.leftMargin()
- document.rightMargin());
head.writeSelectedRows(
0,
-1,
document.leftMargin(),
page.getHeight() - document.topMargin()
+ head.getTotalHeight(), writer.getDirectContent());
PdfPTable foot = new PdfPTable(3);
for (int k = 1; k <= 6; ++k)
foot.addCell("foot " + k);
foot.setTotalWidth(page.getWidth() - document.leftMargin()
- document.rightMargin());
foot.writeSelectedRows(0, -1, document.leftMargin(),
document.bottomMargin(), writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例2: onEndPage
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void onEndPage(PdfWriter writer, Document document) {
//Footer contains page numbers and date printed on all pages
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
String strFooter = promoTxt + " " + formatter.format(now);
float textBase = document.bottom();
cb.beginText();
cb.setFontAndSize(font.getBaseFont(), FONTSIZE);
Rectangle page = document.getPageSize();
float width = page.getWidth();
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, strFooter, (width / 2.0f), textBase - 20, 0);
strFooter = "-" + writer.getPageNumber() + "-";
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, strFooter, (width / 2.0f), textBase - 10, 0);
cb.endText();
cb.restoreState();
}
示例3: onEndPage
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void onEndPage( PdfWriter writer, Document document ) {
//Footer contains page numbers and date printed on all pages
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
String strFooter = promoTxt + " " + formatter.format(now);
float textBase = document.bottom();
cb.beginText();
cb.setFontAndSize(font.getBaseFont(),FONTSIZE);
Rectangle page = document.getPageSize();
float width = page.getWidth();
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, strFooter, (width/2.0f), textBase - 20, 0);
strFooter = "-" + writer.getPageNumber() + "-";
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, strFooter, (width/2.0f), textBase-10, 0);
cb.endText();
cb.restoreState();
}
示例4: onEndPage
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void onEndPage( PdfWriter writer, Document document ) {
//Footer contains page numbers and date printed on all pages
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
String strFooter = promoTxt + " " + formatter.format(now);
float textBase = document.bottom();
cb.beginText();
cb.setFontAndSize(font.getBaseFont(),FONTSIZE);
Rectangle page = document.getPageSize();
float width = page.getWidth();
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, strFooter, (width/2.0f), textBase - 20, 0);
strFooter = "-" + writer.getPageNumber() + "-";
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, strFooter, (width/2.0f), textBase-10, 0);
cb.endText();
cb.restoreState();
}
示例5: onEndPage
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
if (headerFooterPolicy.getHeader(writer.getPageNumber())!=null) {
Hdr hdr = headerFooterPolicy.getHeader(writer.getPageNumber()).getJaxbElement();
PdfPTable head = new PdfPTable(1); // num cols
// TODO - no cell borders
traverseBlockLevelContent( hdr.getEGBlockLevelElts(), head);
head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(),
writer.getDirectContent());
}
if (headerFooterPolicy.getFooter(writer.getPageNumber())!=null) {
Ftr ftr = headerFooterPolicy.getFooter(writer.getPageNumber()).getJaxbElement();
PdfPTable foot = new PdfPTable(1);
traverseBlockLevelContent( ftr.getEGBlockLevelElts(), foot);
foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
writer.getDirectContent());
}
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例6: onEndPage
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void onEndPage(PdfWriter writer, Document document){
try {
Rectangle page = document.getPageSize();
PdfContentByte cb = writer.getDirectContent();
BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
int pageNum = document.getPageNumber();
float width = page.getWidth();
float height = page.getHeight();
//add patient name header for every page but the first.
if (pageNum > 1){
cb.beginText();
cb.setFontAndSize(bf, 8);
cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, handler.getPatientName(), 575, height - 30, 0);
cb.endText();
}
//add footer for every page
cb.beginText();
cb.setFontAndSize(bf, 8);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "-"+pageNum+"-", width/2, 30, 0);
cb.endText();
// add promotext as footer if it is enabled
if ( OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT") != null){
cb.beginText();
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA,BaseFont.CP1252,BaseFont.NOT_EMBEDDED), 6);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT"), width/2, 19, 0);
cb.endText();
}
// throw any exceptions
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例7: onFinPagina2
import com.lowagie.text.Document; //导入方法依赖的package包/类
private void onFinPagina2(PdfWriter writer, Document document) {
Rectangle page = document.getPageSize();
PdfContentByte cb = writer.getDirectContent();
Font font = new Font(Font.HELVETICA, 7, Font.ITALIC, Color.GRAY);
if (cabecera != null){
PdfPTable head = new PdfPTable(1);
head.getDefaultCell().setBorder(Rectangle.NO_BORDER);
head.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
Paragraph bloque = new Paragraph(new Chunk(cabecera,font));
head.addCell(bloque);
head.addCell(new Phrase(new Chunk("",font)));
head.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());
head.writeSelectedRows(0, -1, document.leftMargin(), page.height() - document.topMargin() + head.getTotalHeight(),writer.getDirectContent());
}
// Texto de pie y c�digo de barras
if (pie == null) pie = "";
/** VRS: cambio para a�adir paginacion */
cb.saveState();
String text = pie + " - P�g. " + writer.getPageNumber() + " de ";
float textBase = document.bottom() - 20;
float textSize = bFont.getWidthPoint(text, 7);
cb.saveState();
cb.beginText();
cb.setFontAndSize(bFont, 7);
float adjust = bFont.getWidthPoint("0", 7);
cb.setTextMatrix(document.right() - textSize - adjust, textBase);
cb.setColorFill(Color.GRAY);
cb.showText(text);
cb.endText();
cb.addTemplate(tplTotal, document.right() - adjust, textBase);
cb.restoreState();
}