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


Java Rectangle.getWidth方法代码示例

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


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

示例1: footer

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
public void footer() {
	PdfContentByte cb = writer.getDirectContent();
	cb.saveState();

	Date now = new Date();
	String promoTxt = OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT");
	if (promoTxt == null) {
		promoTxt = new String();
	}

	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();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:27,代码来源:TicklerPrinter.java

示例2: onEndPage

import com.lowagie.text.Rectangle; //导入方法依赖的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();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:TicklerPrinter.java

示例3: onEndPage

import com.lowagie.text.Rectangle; //导入方法依赖的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();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:22,代码来源:OscarChartPrinter.java

示例4: footer

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
public void footer() {
       PdfContentByte cb = writer.getDirectContent();
       cb.saveState();

       Date now = new Date();
       String promoTxt = OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT");
       if( promoTxt == null ) {
           promoTxt = new String();
       }

       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();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:27,代码来源:PdfRecordPrinter.java

示例5: onEndPage

import com.lowagie.text.Rectangle; //导入方法依赖的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();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:PdfRecordPrinter.java

示例6: setPageSize

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
 * Set the page size to use. This method will use guessFormat to try to guess the correct
 * page format. If no format could be guessed, the sizes from the pageSize are used and
 * the landscape setting is determined by comparing width and height;
 * 
 * @param pageSize The pageSize to use
 */
public void setPageSize(Rectangle pageSize) {
    if(!guessFormat(pageSize, false)) {
        this.pageWidth = (int) (pageSize.getWidth() * RtfElement.TWIPS_FACTOR);
        this.pageHeight = (int) (pageSize.getHeight() * RtfElement.TWIPS_FACTOR);
        this.landscape = pageWidth > pageHeight;
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:15,代码来源:RtfPageSetting.java

示例7: onEndPage

import com.lowagie.text.Rectangle; //导入方法依赖的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);
    }
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:40,代码来源:LabPDFCreator.java

示例8: main

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
 * Reads the pages of an existing PDF file and puts 2 pages from the
 * existing doc into one of the new doc.
 */
@Test
public void main() throws Exception {
	// we create a reader for a certain document
	PdfReader reader = new PdfReader(PdfTestBase.RESOURCES_DIR + "ChapterSection.pdf");
	// we retrieve the total number of pages
	int n = reader.getNumberOfPages();
	// we retrieve the size of the first page
	Rectangle psize = reader.getPageSize(1);
	float width = psize.getHeight();
	float height = psize.getWidth();

	// step 1: creation of a document-object
	Document document = new Document(new Rectangle(width, height));
	// step 2: we create a writer that listens to the document
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("2on1.pdf"));
	// step 3: we open the document
	document.open();
	// step 4: we add content
	PdfContentByte cb = writer.getDirectContent();
	int i = 0;
	int p = 0;
	while (i < n) {
		document.newPage();
		p++;
		i++;
		PdfImportedPage page1 = writer.getImportedPage(reader, i);
		cb.addTemplate(page1, .5f, 0, 0, .5f, 60, 120);
		if (i < n) {
			i++;
			PdfImportedPage page2 = writer.getImportedPage(reader, i);
			cb.addTemplate(page2, .5f, 0, 0, .5f, width / 2 + 60, 120);
		}
		BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
		cb.beginText();
		cb.setFontAndSize(bf, 14);
		cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "page " + p + " of " + ((n / 2) + (n % 2 > 0 ? 1 : 0)),
				width / 2, 40, 0);
		cb.endText();
	}
	// step 5: we close the document
	document.close();

}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:48,代码来源:TwoOnOneTest.java

示例9: rectEquals

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
 * This method compares to Rectangles. They are considered equal if width and height are the same
 * 
 * @param rect1 The first Rectangle to compare
 * @param rect2 The second Rectangle to compare
 * @return <code>True</code> if the Rectangles equal, <code>false</code> otherwise
 */
private boolean rectEquals(Rectangle rect1, Rectangle rect2) {
    return (rect1.getWidth() == rect2.getWidth()) && (rect1.getHeight() == rect2.getHeight());
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:11,代码来源:RtfPageSetting.java


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