當前位置: 首頁>>代碼示例>>Java>>正文


Java Rectangle.setBackgroundColor方法代碼示例

本文整理匯總了Java中com.itextpdf.text.Rectangle.setBackgroundColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle.setBackgroundColor方法的具體用法?Java Rectangle.setBackgroundColor怎麽用?Java Rectangle.setBackgroundColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.itextpdf.text.Rectangle的用法示例。


在下文中一共展示了Rectangle.setBackgroundColor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convert

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
public void convert(File pdfOut, float fontSize, boolean append) throws IOException, DocumentException, InvalidColourException {

		// First we write to tmp file then we copy to given destination, possibly appending
		File tmpPdf= Utils.createTempFile(pdfOut.getName(), ".pdf");
		tmpPdf.deleteOnExit();
		
		List<Paragraph> pdfLines= this.ansiFileToPdfParagraphs(fontSize);
        
		Rectangle pageSize = new Rectangle((float) (this.getMaxWidth() * 1.01), (float) (this.getMaxHeight()));

		int background256= Config.get256Color(ConfigKey.background);
		Color pageColor= Xterm256.xterm256ToColor(background256);
		
		pageSize.setBackgroundColor(new BaseColor(pageColor.getRed(), pageColor.getGreen(), pageColor.getBlue()));
		Document document = new Document(pageSize, 5f, 0f, 0f, 0f);
		//Document document = new Document(new Rectangle((float) (this.getMaxWidth() * 1.01), (float) (this.getMaxHeight())), 5f, 0f, 0f, 0f);
        PdfWriter.getInstance(document, new FileOutputStream(tmpPdf));
        document.open();

		for(Paragraph line : pdfLines){
	        document.add(line);
        }
        document.close();
        
        if(append){
        	this.appendPdf(tmpPdf, pdfOut);
        } else {
        	Files.move(Paths.get(tmpPdf.getAbsolutePath()), Paths.get(pdfOut.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING);
        }
	}
 
開發者ID:dariober,項目名稱:ASCIIGenome,代碼行數:31,代碼來源:Pdf.java

示例2: printPage3

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
private void printPage3(Document document, PdfContentByte canvas) throws DocumentException {
    int cols = 3;
    int rows = 15;

    PdfPTable table = new PdfPTable(cols);
    for (int row = 0; row < rows; row++) {
        for (int col = 0; col < cols; col++) {
            table.addCell(new Phrase("Cell " + row + ", " + col));
        }
    }
    table.setSpacingBefore(5);

    Rectangle docBounds = document.getPageSize();
    Rectangle upper = new Rectangle(docBounds.getLeft(20), docBounds.getTop(20) - 200, docBounds.getRight(20), docBounds.getTop(20));
    upper.setBackgroundColor(new BaseColor(23, 142, 255, 20));
    Rectangle lower = new Rectangle(docBounds.getLeft(20), docBounds.getBottom(20), docBounds.getRight(20), docBounds.getBottom(20) + 600);
    lower.setBackgroundColor(new BaseColor(255, 142, 23, 20));
    Rectangle[] rectangles = new Rectangle[] { upper, lower };

    for (Rectangle bounds : rectangles)
    {
        bounds.setBorder(Rectangle.BOX);
        bounds.setBorderColor(BaseColor.BLACK);
        bounds.setBorderWidth(1);

        canvas.rectangle(bounds);
    }

    rectangles = drawKeepTogether(new Paragraph("This table should keep together!"), canvas, rectangles);
    rectangles = drawKeepTogether(table, canvas, rectangles);
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:32,代碼來源:TableKeepTogether.java


注:本文中的com.itextpdf.text.Rectangle.setBackgroundColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。