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"); 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); } }
rect.setBackgroundColor(BaseColor.BLACK); outCB.rectangle(rect); cmpCB.rectangle(rect);
rect.setBackgroundColor(BaseColor.BLACK); outCB.rectangle(rect); cmpCB.rectangle(rect);
public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { int footer = widths.length - table.getFooterRows(); int header = table.getHeaderRows() - table.getFooterRows() + 1; for (int row = header; row < footer; row += 2) { int columns = widths[row].length - 1; Rectangle rect = new Rectangle(widths[row][0], heights[row], widths[row][columns], heights[row + 1]); rect.setBackgroundColor(styles.getColor(Styles.TABLE_ALTERNATE_BACKGROUND).or(Colors.VERY_LIGHT_GRAY)); rect.setBorder(Rectangle.NO_BORDER); canvases[PdfPTable.BASECANVAS].rectangle(rect); } } }
size.setBackgroundColor(new BaseColor(col.getRed(), col.getGreen(), col.getBlue()));
Rectangle background = new Rectangle(leftX, maxY - backgroundHeight, backgroundWidth+leftX, maxY); if (backgroundColor != null) { background.setBackgroundColor(backgroundColor); PdfArtifact artifact = new PdfArtifact(); canvas.openMCBlock(artifact);
newRect.setBackgroundColor(null);
Rectangle background = new Rectangle(leftX, maxY - backgroundHeight, backgroundWidth+leftX, maxY); if (backgroundColor != null) { background.setBackgroundColor(backgroundColor); PdfArtifact artifact = new PdfArtifact(); canvas.openMCBlock(artifact);
newRect.setBackgroundColor(null);