List of usage examples for com.lowagie.text.pdf PdfContentByte PdfContentByte
public PdfContentByte(PdfWriter wr)
PdfContentByte-object. From source file:classroom.filmfestival_c.Movies23.java
public static void fillForm(String filename, AccreditationData data, OutputStream out) throws IOException, DocumentException { PdfReader reader = new PdfReader(filename); PdfStamper stamper = new PdfStamper(reader, out); AcroFields form = stamper.getAcroFields(); form.setField("name", data.getName()); form.setFieldProperty("type", "textcolor", data.getTypeColor(), null); form.setField("type", data.getTypeName()); form.setField("number", data.getNumber(false)); form.setFieldProperty("filmfestival", "bgcolor", data.getTypeColor(), null); form.regenerateField("filmfestival"); if (data.getPhoto() != null) { PushbuttonField bt = form.getNewPushbuttonFromField("photo"); bt.setLayout(PushbuttonField.LAYOUT_ICON_ONLY); bt.setProportionalIcon(true);//from w w w. ja va 2 s . c o m bt.setImage(data.getPhoto()); form.replacePushbuttonField("photo", bt.getField()); } try { BarcodeInter25 code = new BarcodeInter25(); code.setGenerateChecksum(true); code.setBarHeight(mm2pt(3)); code.setCode(data.getNumber(true)); code.setFont(null); PdfContentByte cb = new PdfContentByte(stamper.getWriter()); PdfTemplate template = code.createTemplateWithBarcode(cb, null, null); PushbuttonField bt = form.getNewPushbuttonFromField("barcode"); bt.setLayout(PushbuttonField.LAYOUT_ICON_ONLY); bt.setProportionalIcon(false); bt.setTemplate(template); form.replacePushbuttonField("barcode", bt.getField()); } catch (Exception e) { // not a valid code, do nothing } stamper.setFormFlattening(data.isFlatten()); stamper.close(); }
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
public void createCommuneFooter(PdfWriter writer) throws Exception { PdfContentByte cb = writer.getDirectContent(); Font nameFont = getDefaultParagraphFont(); nameFont.setSize(9);/*w w w . j a v a 2s . com*/ Font textFont = getDefaultTextFont(); textFont.setSize(9); PdfPTable table = new PdfPTable(4); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.getDefaultCell().setNoWrap(true); IWBundle iwb = getIWApplicationContext().getIWMainApplication() .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER); table.addCell(new Phrase(iwb.getProperty("commune.name_mailaddr", "Mailaddress"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.name_visitaddr", "Visitaddress"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.name_contact", "Contact"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.name_org_nr", "Organizationsnr"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.mail_name", "Mail name"), getTextFont())); table.addCell(new Phrase(iwb.getProperty("commune.visit_name", "Visit name"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.website", "www.some-place.com"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.org_number", "XXXXXX-XXXX"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.mail_zip", "Zip code"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.visit_streetaddr", "Street and number,"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.support_email", "email@someplace.com"), textFont)); table.addCell(new Phrase(" ", textFont)); table.addCell(new Phrase(" ", textFont)); table.addCell(new Phrase(iwb.getProperty("commune.visit_zip", "Visit zip"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.office_phone", "office phone"), textFont)); table.addCell(new Phrase(" ", textFont)); int distFromBottomMM = 30; int[] widths = { 20, 20, 30, 20 }; table.setWidths(widths); table.setTotalWidth(getPointsFromMM(210 - 25 - 20)); table.writeSelectedRows(0, -1, getPointsFromMM(25), getPointsFromMM(distFromBottomMM), cb); PdfContentByte linebyte = new PdfContentByte(writer); // we add some crosses to visualize the destinations linebyte.moveTo(getPointsFromMM(25), getPointsFromMM(distFromBottomMM + 2)); linebyte.lineTo(getPointsFromMM(210 - 25), getPointsFromMM(distFromBottomMM + 2)); linebyte.stroke(); // we add the template on different positions cb.add(linebyte); }