List of usage examples for com.lowagie.text PageSize LETTER
Rectangle LETTER
To view the source code for com.lowagie.text PageSize LETTER.
Click Source Link
From source file:org.oscarehr.casemgmt.service.CaseManagementPrintPdf.java
License:Open Source License
public void printDocHeaderFooter() throws IOException, DocumentException { //Create the document we are going to write to document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, os); writer.setPageEvent(new EndPage()); document.setPageSize(PageSize.LETTER); document.open();/* w w w . ja v a 2 s . c o m*/ //Create the font we are going to print to bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); font = new Font(bf, FONTSIZE, Font.NORMAL); String title = "", gender = "", dob = "", age = "", mrp = ""; if (this.demoDtl != null) { //set up document title and header ResourceBundle propResource = ResourceBundle.getBundle("oscarResources"); title = propResource.getString("oscarEncounter.pdfPrint.title") + " " + (String) demoDtl.get("demoName") + "\n"; gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " " + (String) demoDtl.get("demoSex") + "\n"; dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " " + (String) demoDtl.get("demoDOB") + "\n"; age = propResource.getString("oscarEncounter.pdfPrint.age") + " " + (String) demoDtl.get("demoAge") + "\n"; mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " " + (String) demoDtl.get("mrp") + "\n"; } else { //set up document title and header ResourceBundle propResource = ResourceBundle.getBundle("oscarResources"); title = propResource.getString("oscarEncounter.pdfPrint.title") + " " + (String) request.getAttribute("demoName") + "\n"; gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " " + (String) request.getAttribute("demoSex") + "\n"; dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " " + (String) request.getAttribute("demoDOB") + "\n"; age = propResource.getString("oscarEncounter.pdfPrint.age") + " " + (String) request.getAttribute("demoAge") + "\n"; mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " " + (String) request.getAttribute("mrp") + "\n"; } String[] info = new String[] { title, gender, dob, age, mrp }; ClinicData clinicData = new ClinicData(); clinicData.refreshClinicData(); String[] clinic = new String[] { clinicData.getClinicName(), clinicData.getClinicAddress(), clinicData.getClinicCity() + ", " + clinicData.getClinicProvince(), clinicData.getClinicPostal(), clinicData.getClinicPhone(), "Fax: " + clinicData.getClinicFax() }; //Header will be printed at top of every page beginning with p2 Phrase headerPhrase = new Phrase(LEADING, title, font); HeaderFooter header = new HeaderFooter(headerPhrase, false); header.setAlignment(HeaderFooter.ALIGN_CENTER); document.setHeader(header); //Write title with top and bottom borders on p1 cb = writer.getDirectContent(); cb.setColorStroke(new Color(0, 0, 0)); cb.setLineWidth(0.5f); cb.moveTo(document.left(), document.top()); cb.lineTo(document.right(), document.top()); cb.stroke(); //cb.setFontAndSize(bf, FONTSIZE); upperYcoord = document.top() - (font.getCalculatedLeading(LINESPACING) * 2f); ColumnText ct = new ColumnText(cb); Paragraph p = new Paragraph(); p.setAlignment(Paragraph.ALIGN_LEFT); Phrase phrase = new Phrase(); Phrase dummy = new Phrase(); for (int idx = 0; idx < clinic.length; ++idx) { phrase.add(clinic[idx] + "\n"); dummy.add("\n"); upperYcoord -= phrase.getLeading(); } dummy.add("\n"); ct.setSimpleColumn(document.left(), upperYcoord, document.right() / 2f, document.top()); ct.addElement(phrase); ct.go(); p.add(dummy); document.add(p); //add patient info phrase = new Phrase(); p = new Paragraph(); p.setAlignment(Paragraph.ALIGN_RIGHT); for (int idx = 0; idx < info.length; ++idx) { phrase.add(info[idx]); } ct.setSimpleColumn(document.right() / 2f, upperYcoord, document.right(), document.top()); p.add(phrase); ct.addElement(p); ct.go(); cb.moveTo(document.left(), upperYcoord); cb.lineTo(document.right(), upperYcoord); cb.stroke(); upperYcoord -= phrase.getLeading(); if (Boolean.parseBoolean(OscarProperties.getInstance().getProperty("ICFHT_CONVERT_TO_PDF", "false"))) { printPersonalInfo(); } }
From source file:org.oscarehr.common.printing.HtmlToPdfServlet.java
License:Open Source License
private static void appendFooter(byte[] pdf, ByteArrayOutputStream baos) { PdfReader reader = null;//from w w w .j a v a 2 s. co m PdfWriter writer = null; Document document = null; try { // do initialization reader = new PdfReader(pdf); document = new Document(PageSize.LETTER); writer = PdfWriterFactory.newInstance(document, baos, FontSettings.HELVETICA_6PT); document.open(); PdfContentByte cb = writer.getDirectContent(); // copy pages for (int i = 1; i <= reader.getNumberOfPages(); i++) { cb.addTemplate(writer.getImportedPage(reader, i), 0, 0); } } catch (Exception e) { throw new RuntimeException("Unable to append document footer", e); } finally { close(document); close(writer); close(reader); } }
From source file:org.oscarehr.common.service.PdfRecordPrinter.java
License:Open Source License
public PdfRecordPrinter(HttpServletRequest request, OutputStream os) throws DocumentException, IOException { this.request = request; this.os = os; formatter = new SimpleDateFormat("dd-MMM-yyyy"); //Create the font we are going to print to bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); font = new Font(bf, FONTSIZE, Font.NORMAL); boldFont = new Font(bf, FONTSIZE, Font.BOLD); //Create the document we are going to write to document = new Document(); writer = PdfWriter.getInstance(document, os); writer.setPageEvent(new EndPage()); writer.setStrictImageSequence(true); document.setPageSize(PageSize.LETTER); /*/*from ww w. ja va 2s . c o m*/ HeaderFooter footer = new HeaderFooter(new Phrase("-",font),new Phrase("-",font)); footer.setAlignment(HeaderFooter.ALIGN_CENTER); footer.setBorder(0); document.setFooter(footer); */ document.open(); }
From source file:org.oscarehr.phr.web.PHRUserManagementAction.java
License:Open Source License
public ByteArrayOutputStream generateUserRegistrationLetter(String demographicNo, String username, String password) throws Exception { log.debug("Demographic " + demographicNo + " username " + username + " password " + password); DemographicDao demographicDao = (DemographicDao) SpringUtils.getBean("demographicDao"); Demographic demographic = demographicDao.getDemographic(demographicNo); final String PAGESIZE = "printPageSize"; Document document = new Document(); ByteArrayOutputStream baosPDF = new ByteArrayOutputStream(); PdfWriter writer = null;/*from ww w . j a va 2 s . co m*/ try { writer = PdfWriter.getInstance(document, baosPDF); String title = "TITLE"; String template = "MyOscarLetterHead.pdf"; Properties printCfg = getCfgProp(); String[] cfgVal = null; StringBuilder tempName = null; // get the print prop values Properties props = new Properties(); props.setProperty("letterDate", UtilDateUtilities.getToday("yyyy-MM-dd")); props.setProperty("name", demographic.getFirstName() + " " + demographic.getLastName()); props.setProperty("dearname", demographic.getFirstName() + " " + demographic.getLastName()); props.setProperty("address", demographic.getAddress()); props.setProperty("city", demographic.getCity() + ", " + demographic.getProvince()); props.setProperty("postalCode", demographic.getPostal()); props.setProperty("credHeading", "MyOscar User Account Details"); props.setProperty("username", "Username: " + username); props.setProperty("password", "Password: " + password); //Temporary - the intro will change to be dynamic props.setProperty("intro", "We are pleased to provide you with a log in and password for your new MyOSCAR Personal Health Record. This account will allow you to connect electronically with our clinic. Please take a few minutes to review the accompanying literature for further information.We look forward to you benefiting from this service."); document.addTitle(title); document.addSubject(""); document.addKeywords("pdf, itext"); document.addCreator("OSCAR"); document.addAuthor(""); document.addHeader("Expires", "0"); Rectangle pageSize = PageSize.LETTER; document.setPageSize(pageSize); document.open(); // create a reader for a certain document String propFilename = oscar.OscarProperties.getInstance().getProperty("pdfFORMDIR", "") + "/" + template; PdfReader reader = null; try { reader = new PdfReader(propFilename); log.debug("Found template at " + propFilename); } catch (Exception dex) { log.debug("change path to inside oscar from :" + propFilename); reader = new PdfReader("/oscar/form/prop/" + template); log.debug("Found template at /oscar/form/prop/" + template); } // retrieve the total number of pages int n = reader.getNumberOfPages(); // retrieve the size of the first page Rectangle pSize = reader.getPageSize(1); float width = pSize.getWidth(); float height = pSize.getHeight(); log.debug("Width :" + width + " Height: " + height); PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); int fontFlags = 0; document.newPage(); PdfImportedPage page1 = writer.getImportedPage(reader, 1); cb.addTemplate(page1, 1, 0, 0, 1, 0, 0); BaseFont bf; // = normFont; String encoding; cb.setRGBColorStroke(0, 0, 255); String[] fontType; for (Enumeration e = printCfg.propertyNames(); e.hasMoreElements();) { tempName = new StringBuilder(e.nextElement().toString()); cfgVal = printCfg.getProperty(tempName.toString()).split(" *, *"); if (cfgVal[4].indexOf(";") > -1) { fontType = cfgVal[4].split(";"); if (fontType[1].trim().equals("italic")) fontFlags = Font.ITALIC; else if (fontType[1].trim().equals("bold")) fontFlags = Font.BOLD; else if (fontType[1].trim().equals("bolditalic")) fontFlags = Font.BOLDITALIC; else fontFlags = Font.NORMAL; } else { fontFlags = Font.NORMAL; fontType = new String[] { cfgVal[4].trim() }; } if (fontType[0].trim().equals("BaseFont.HELVETICA")) { fontType[0] = BaseFont.HELVETICA; encoding = BaseFont.CP1252; //latin1 encoding } else if (fontType[0].trim().equals("BaseFont.HELVETICA_OBLIQUE")) { fontType[0] = BaseFont.HELVETICA_OBLIQUE; encoding = BaseFont.CP1252; } else if (fontType[0].trim().equals("BaseFont.ZAPFDINGBATS")) { fontType[0] = BaseFont.ZAPFDINGBATS; encoding = BaseFont.ZAPFDINGBATS; } else { fontType[0] = BaseFont.COURIER; encoding = BaseFont.CP1252; } bf = BaseFont.createFont(fontType[0], encoding, BaseFont.NOT_EMBEDDED); // write in a rectangle area if (cfgVal.length >= 9) { Font font = new Font(bf, Integer.parseInt(cfgVal[5].trim()), fontFlags); ct.setSimpleColumn(Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), Integer.parseInt(cfgVal[7].trim()), (height - Integer.parseInt(cfgVal[8].trim())), Integer.parseInt(cfgVal[9].trim()), (cfgVal[0].trim().equals("left") ? Element.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? Element.ALIGN_RIGHT : Element.ALIGN_CENTER))); ct.setText(new Phrase(12, props.getProperty(tempName.toString(), ""), font)); ct.go(); continue; } // draw line directly if (tempName.toString().startsWith("__$line")) { cb.setRGBColorStrokeF(0f, 0f, 0f); cb.setLineWidth(Float.parseFloat(cfgVal[4].trim())); cb.moveTo(Float.parseFloat(cfgVal[0].trim()), Float.parseFloat(cfgVal[1].trim())); cb.lineTo(Float.parseFloat(cfgVal[2].trim()), Float.parseFloat(cfgVal[3].trim())); // stroke the lines cb.stroke(); // write text directly } else if (tempName.toString().startsWith("__")) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? (cfgVal[6].trim()) : props.getProperty(tempName.toString(), "")), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } else if (tempName.toString().equals("forms_promotext")) { if (OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT") != null) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT"), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } else { // write prop text cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? ((props.getProperty(tempName.toString(), "").equals("") ? "" : cfgVal[6].trim())) : props.getProperty(tempName.toString(), "")), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } } catch (DocumentException dex) { baosPDF.reset(); throw dex; } finally { if (document != null) document.close(); if (writer != null) writer.close(); } return baosPDF; }
From source file:org.sipfoundry.faxrx.FaxProcessor.java
License:Open Source License
private File tiff2Pdf(File tiffFile) { Pattern pattern = Pattern.compile("(.*).tiff"); Matcher matcher = pattern.matcher(tiffFile.getName()); boolean matchFound = matcher.find(); // check if tiffFile is actually a TIFF file, just in case if (matchFound) { // located at default tmp-file directory File pdfFile = new File(System.getProperty("java.io.tmpdir"), matcher.group(1) + ".pdf"); try {//from w w w . ja v a2 s. c o m // read TIFF file RandomAccessFileOrArray tiff = new RandomAccessFileOrArray(tiffFile.getAbsolutePath()); // get number of pages of TIFF file int pages = TiffImage.getNumberOfPages(tiff); // create PDF file Document pdf = new Document(PageSize.LETTER, 0, 0, 0, 0); PdfWriter writer = PdfWriter.getInstance(pdf, new FileOutputStream(pdfFile)); writer.setStrictImageSequence(true); // open PDF filex pdf.open(); PdfContentByte contentByte = writer.getDirectContent(); // write PDF file page by page for (int page = 1; page <= pages; page++) { Image temp = TiffImage.getTiffImage(tiff, page); temp.scalePercent(7200f / temp.getDpiX(), 7200f / temp.getDpiY()); pdf.setPageSize(new Rectangle(temp.getScaledWidth(), temp.getScaledHeight())); temp.setAbsolutePosition(0, 0); contentByte.addImage(temp); pdf.newPage(); } // close PDF file pdf.close(); } catch (Exception e) { LOG.error("faxrx::tiff2Pdf error " + e.getMessage()); e.printStackTrace(); return null; } return pdfFile; } else { return null; } }
From source file:org.sipfoundry.faxrx.FaxRx.java
License:Contributor Agreement License
private File tiff2Pdf(File tiffFile) { Pattern pattern = Pattern.compile("(.*).tiff"); Matcher matcher = pattern.matcher(tiffFile.getName()); boolean matchFound = matcher.find(); // check if tiffFile is actually a TIFF file, just in case if (matchFound) { // located at default tmp-file directory File pdfFile = new File(System.getProperty("java.io.tmpdir"), matcher.group(1) + ".pdf"); try {/*from www. j av a 2 s .co m*/ // read TIFF file RandomAccessFileOrArray tiff = new RandomAccessFileOrArray(tiffFile.getAbsolutePath()); // get number of pages of TIFF file int pages = TiffImage.getNumberOfPages(tiff); // create PDF file Document pdf = new Document(PageSize.LETTER); PdfWriter.getInstance(pdf, new FileOutputStream(pdfFile)); // open PDF filex pdf.open(); // write PDF file page by page for (int page = 1; page <= pages; page++) { Image temp = TiffImage.getTiffImage(tiff, page); pdf.add(temp); } // close PDF file pdf.close(); } catch (Exception e) { e.printStackTrace(); return null; } return pdfFile; } else { return null; } }
From source file:org.sonarqube.report.extendedpdf.ExtendedToc.java
License:Open Source License
public ExtendedToc() { toc = new Document(PageSize.LETTER, 50, 50, 80, 20); content = new PdfPTable(2); Rectangle page = toc.getPageSize(); content.setTotalWidth(page.getWidth() - toc.leftMargin() - toc.rightMargin()); content.getDefaultCell().setUseVariableBorders(true); content.getDefaultCell().setBorderColorBottom(Color.WHITE); content.getDefaultCell().setBorderColorRight(Color.WHITE); content.getDefaultCell().setBorderColorLeft(Color.WHITE); content.getDefaultCell().setBorderColorTop(Color.WHITE); content.getDefaultCell().setBorderWidthBottom(2f); }
From source file:org.sonarqube.report.extendedpdf.OverviewPDFReporter.java
License:Open Source License
@Override public ByteArrayOutputStream getReport() throws DocumentException, IOException, org.dom4j.DocumentException, ReportException { // Capture and save screenshots of the required widgets captureScreenshots();// ww w . jav a 2 s .c om // Creation of documents Document mainDocument = new Document(PageSize.LETTER, 50, 50, 75, 50); ExtendedToc tocDocument = new ExtendedToc(); Document frontPageDocument = new Document(PageSize.LETTER, 50, 50, 75, 50); ByteArrayOutputStream mainDocumentBaos = new ByteArrayOutputStream(); ByteArrayOutputStream frontPageDocumentBaos = new ByteArrayOutputStream(); PdfWriter mainDocumentWriter = PdfWriter.getInstance(mainDocument, mainDocumentBaos); PdfWriter frontPageDocumentWriter = PdfWriter.getInstance(frontPageDocument, frontPageDocumentBaos); mainDocumentWriter.setStrictImageSequence(true); frontPageDocumentWriter.setStrictImageSequence(true); // Events for TOC, header and page numbers ExtendedEvents events = new ExtendedEvents(tocDocument, new ExtendedHeader(this.getProject())); mainDocumentWriter.setPageEvent(events); mainDocument.open(); tocDocument.getTocDocument().open(); frontPageDocument.open(); Logger.info("Generating Overview PDF report..."); printFrontPage(frontPageDocument, frontPageDocumentWriter); printTocTitle(tocDocument); printPdfBody(mainDocument); mainDocument.close(); tocDocument.getTocDocument().close(); frontPageDocument.close(); // Get Readers PdfReader mainDocumentReader = new PdfReader(mainDocumentBaos.toByteArray()); PdfReader tocDocumentReader = new PdfReader(tocDocument.getTocOutputStream().toByteArray()); PdfReader frontPageDocumentReader = new PdfReader(frontPageDocumentBaos.toByteArray()); // New document Document documentWithToc = new Document(tocDocumentReader.getPageSizeWithRotation(1)); ByteArrayOutputStream finalBaos = new ByteArrayOutputStream(); PdfCopy copy = new PdfCopy(documentWithToc, finalBaos); documentWithToc.open(); copy.addPage(copy.getImportedPage(frontPageDocumentReader, 1)); for (int i = 1; i <= tocDocumentReader.getNumberOfPages(); i++) { copy.addPage(copy.getImportedPage(tocDocumentReader, i)); } for (int i = 1; i <= mainDocumentReader.getNumberOfPages(); i++) { copy.addPage(copy.getImportedPage(mainDocumentReader, i)); } documentWithToc.close(); // Return the final document (with TOC) return finalBaos; }
From source file:org.tellervo.desktop.print.BasicBoxLabel.java
License:Open Source License
public void generateBoxLabel(OutputStream output) { try {// ww w.jav a 2s .c o m PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); document.open(); cb = writer.getDirectContent(); // Set basic metadata document.addAuthor("Tellervo"); document.addSubject("Tellervo Box Labels"); PdfPTable table = new PdfPTable(2); table.setTotalWidth(495f); table.setLockedWidth(true); for (WSIBox b : boxlist) { Paragraph p = new Paragraph(); p.add(new Chunk(b.getTitle() + Chunk.NEWLINE, labelTitleFont)); p.add(new Chunk(Chunk.NEWLINE + b.getComments() + Chunk.NEWLINE, bodyFont)); p.add(new Chunk(App.getLabName() + Chunk.NEWLINE + Chunk.NEWLINE, bodyFont)); p.add(new Chunk(this.getBarCode(b), 0, 0, true)); PdfPCell cell = new PdfPCell(p); cell.setPaddingLeft(15f); cell.setPaddingRight(15f); cell.setBorderColor(Color.LIGHT_GRAY); table.addCell(cell); } PdfPCell cell = new PdfPCell(new Paragraph()); cell.setBorderColor(Color.LIGHT_GRAY); table.addCell(cell); document.add(table); document.close(); /*float top = document.top(15); int row = 1; for(int i = 0; i< boxlist.size(); i = i+2) { log.debug("Document left : "+document.left()); log.debug("Document right: "+document.right()); log.debug("Top : "+top); // Column 1 ColumnText ct1a = new ColumnText(cb); ct1a.setSimpleColumn(document.left(), top-210, 368, top, 20, Element.ALIGN_LEFT); ColumnText ct1b = new ColumnText(cb); ct1b.setSimpleColumn(document.left(), top-70, document.left()+206, top-150, 20, Element.ALIGN_LEFT); try{ WSIBox b1 = boxlist.get(i); ct1a.addText(getTitlePDF(b1)); ct1a.go(); ct1b.addElement(getBarCode(b1)); ct1b.go(); } catch (Exception e) { log.debug("Failed writing box label in left column where i="+i); } // Column 2 ColumnText ct2a = new ColumnText(cb); ct2a.setSimpleColumn(306, top-210, document.right(), top, 20, Element.ALIGN_LEFT); ColumnText ct2b = new ColumnText(cb); ct2b.setSimpleColumn(306, top-70, 512, top-80, 20, Element.ALIGN_LEFT); try{ WSIBox b2 = boxlist.get(i+1); ct2a.addText(getTitlePDF(b2)); ct2a.go(); ct2b.addElement(getBarCode(b2)); ct2b.go(); } catch (Exception e) { log.debug("Failed writing box label in right column where i="+i); //e.printStackTrace(); } // Column 2 /* ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(370, //llx top-100, //lly document.right(0), //urx top+15, //ury 20, //leading Element.ALIGN_RIGHT //alignment ); try{ WSIBox b2 = boxlist.get(i+1); ct2.addText(getTitlePDF(b2)); ct2.addElement(getBarCode(b2)); ct2.go(); } catch (Exception e) { log.debug("Failed writing box label where i="+i+1); } */ /* top = top-160; if(row==5) { top = document.top(15); document.newPage(); row=1; } else { row++; } }*/ } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.tellervo.desktop.print.CompleteBoxLabel.java
License:Open Source License
public void generateBoxLabel(OutputStream output) { try {//from w ww . j ava 2 s . c om PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); document.open(); cb = writer.getDirectContent(); // Set basic metadata document.addAuthor("Peter Brewer"); document.addSubject("Box Label"); for (WSIBox b : this.boxlist) { // Title Left ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(document.left(), document.top(15) - 210, 368, document.top(15), 20, Element.ALIGN_LEFT); ct.addText(getTitlePDF(b)); ct.go(); // Barcode ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20, Element.ALIGN_RIGHT); ct2.addElement(getBarCode(b)); ct2.go(); // Timestamp ColumnText ct3 = new ColumnText(cb); ct3.setSimpleColumn(document.left(), document.top(15) - 223, 350, document.top(15) - 60, 20, Element.ALIGN_LEFT); ct3.setLeading(0, 1.2f); ct3.addText(getTimestampPDF(b)); ct3.go(); // Pad text document.add(new Paragraph(" ")); Paragraph p2 = new Paragraph(); p2.setSpacingBefore(70); p2.setSpacingAfter(10); p2.add(new Chunk(" ", bodyFontLarge)); document.add(new Paragraph(p2)); // Ring samples table addTable(b); document.add(getParagraphSpace()); document.add(getComments(b)); document.newPage(); } } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }