List of usage examples for org.apache.pdfbox.pdmodel PDPageContentStream fillRect
@Deprecated public void fillRect(float x, float y, float width, float height) throws IOException
From source file:at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.TableDrawUtils.java
License:EUPL
public static void drawTableBackground(PDPage page, PDPageContentStream contentStream, float x, float y, float width, float height, PDFBoxTable abstractTable, ISettings settings) throws PdfAsException { try {/* ww w.j a va 2s.c o m*/ if (abstractTable.getBGColor() != null) { contentStream.setNonStrokingColor(abstractTable.getBGColor()); contentStream.fillRect(x, y, abstractTable.getWidth(), abstractTable.getHeight()); contentStream.setNonStrokingColor(Color.BLACK); } } catch (Throwable e) { logger.warn("drawing table borders", e); throw new PdfAsException("drawing table borders", e); } }
From source file:Bulletin.Bulletin2.java
private float BoxCenteredFilled(PDPageContentStream cos, String text, PDFont font, int size, float x, float y, float w, float h, Color col) { try {// w ww. j a v a 2s.c o m cos.setNonStrokingColor(col); cos.fillRect(x, y - h, w, h); cos.stroke(); cos.setNonStrokingColor(Color.BLACK); this.BoxCentered(cos, text, font, size, x, y, w, h); } catch (IOException ex) { Logger.getLogger(Bulletin2.class.getName()).log(Level.SEVERE, null, ex); } return h; }
From source file:org.dspace.disseminate.CitationDocumentServiceImpl.java
License:BSD License
protected void generateCoverPage(Context context, PDDocument document, PDPage coverPage, Item item) throws IOException { PDPageContentStream contentStream = new PDPageContentStream(document, coverPage); try {/*from www . ja v a2 s. com*/ int ypos = 760; int xpos = 30; int xwidth = 550; int ygap = 20; PDFont fontHelvetica = PDType1Font.HELVETICA; PDFont fontHelveticaBold = PDType1Font.HELVETICA_BOLD; PDFont fontHelveticaOblique = PDType1Font.HELVETICA_OBLIQUE; contentStream.setNonStrokingColor(Color.BLACK); String[][] content = { header1 }; drawTable(coverPage, contentStream, ypos, xpos, content, fontHelveticaBold, 11, false); ypos -= (ygap); String[][] content2 = { header2 }; drawTable(coverPage, contentStream, ypos, xpos, content2, fontHelveticaBold, 11, false); ypos -= ygap; contentStream.fillRect(xpos, ypos, xwidth, 1); contentStream.closeAndStroke(); String[][] content3 = { { getOwningCommunity(context, item), getOwningCollection(item) } }; drawTable(coverPage, contentStream, ypos, xpos, content3, fontHelvetica, 9, false); ypos -= ygap; contentStream.fillRect(xpos, ypos, xwidth, 1); contentStream.closeAndStroke(); ypos -= (ygap * 2); for (String field : fields) { field = field.trim(); PDFont font = fontHelvetica; int fontSize = 11; if (field.contains("title")) { fontSize = 26; ypos -= ygap; } else if (field.contains("creator") || field.contains("contributor")) { fontSize = 16; } if (field.equals("_line_")) { contentStream.fillRect(xpos, ypos, xwidth, 1); contentStream.closeAndStroke(); ypos -= (ygap); } else if (StringUtils.isNotEmpty(itemService.getMetadata(item, field))) { ypos = drawStringWordWrap(coverPage, contentStream, itemService.getMetadata(item, field), xpos, ypos, font, fontSize); } if (field.contains("title")) { ypos -= ygap; } } contentStream.beginText(); contentStream.setFont(fontHelveticaOblique, 11); contentStream.moveTextPositionByAmount(xpos, ypos); contentStream.drawString(footer); contentStream.endText(); } finally { contentStream.close(); } }