List of usage examples for com.lowagie.text Element ALIGN_LEFT
int ALIGN_LEFT
To view the source code for com.lowagie.text Element ALIGN_LEFT.
Click Source Link
From source file:gov.utah.health.uper.reports.Registration.java
private void buildPhysician(Document document, PatientBean pt) throws DocumentException { Paragraph preface = new Paragraph(PHYSICIAN, normalFontBold); preface.setAlignment(Element.ALIGN_LEFT); document.add(preface);/* www . j a v a 2 s . c o m*/ preface = new Paragraph("Name and Title: ", normalFontBold); preface.setAlignment(Element.ALIGN_LEFT); preface.add(pt.getPhysicianName()); document.add(preface); preface = new Paragraph("Utah License Number: ", normalFontBold); preface.add(pt.getDoplNumber()); preface.setAlignment(Element.ALIGN_LEFT); document.add(preface); preface = new Paragraph("Expiration Date: ", normalFontBold); preface.setAlignment(Element.ALIGN_LEFT); preface.add(pt.getLicenseExpireDate()); document.add(preface); addSpacing(document); }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Mthode principale qui gre l'export d'un tableau vers un fichier ODS. * * @param export paramtres du document exporter * @param out flux de sortie//from w w w .j a va 2s . co m * @throws DocumentException Exception */ public final void exportData(final Export export, final OutputStream out) throws DocumentException { // step 1: creation of a document-object final boolean landscape = export.getOrientation() == Export.Orientation.Landscape; final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4; final Document document = new Document(pageSize, 20, 20, 50, 50); // left, // right, // top, // bottom // step 2: we create a writer that listens to the document and directs a // PDF-stream to out createWriter(document, out); // we add some meta information to the document, and we open it final String title = export.getTitle(); if (title != null) { final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } final String author = export.getAuthor(); document.addAuthor(author); document.addCreator(CREATOR); document.open(); try { // pour ajouter l'ouverture automatique de la bote de dialogue // imprimer // (print(false) pour imprimer directement) // ((PdfWriter) writer).addJavaScript("this.print(true);", false); for (final ExportSheet exportSheet : export.getSheets()) { final Table datatable; if (exportSheet.hasDtObject()) { // table datatable = new Table(2); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // data rows renderObject(exportSheet, datatable); } else { // table datatable = new Table(exportSheet.getExportFields().size()); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // headers renderHeaders(exportSheet, datatable); // data rows renderList(exportSheet, datatable); } document.add(datatable); } } finally { // we close the document document.close(); } }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException { final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); for (final ExportField exportColumn : exportSheet.getExportFields()) { datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont)); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject()); final int horizontalAlignement; if (value instanceof Number || value instanceof Date) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else {//from w w w .j av a2s . c o m horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache, exportSheet.getDtObject(), exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, valueFont)); } }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu de la liste.//from w w w .ja v a 2s.c om * * @param parameters Paramtres * @param datatable Table */ private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException { // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); whiteFont.setColor(Color.WHITE); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // datatable.getDefaultCell().setGrayFill(0); // Parcours des DTO de la DTC for (final DtObject dto : parameters.getDtList()) { for (final ExportField exportColumn : parameters.getExportFields()) { final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(dto); final int horizontalAlignement; if (value instanceof Number || value instanceof Date) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else { horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache, dto, exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, font)); } } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Mthode principale qui gre l'export d'un tableau vers un fichier ODS. * * @param export paramtres du document exporter * @param out flux de sortie/*from w w w . j a v a 2s .c om*/ * @throws DocumentException Exception */ public final void exportData(final Export export, final OutputStream out) throws DocumentException { // step 1: creation of a document-object final boolean landscape = export.getOrientation() == Export.Orientation.Landscape; final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4; final Document document = new Document(pageSize, 20, 20, 50, 50); // left, right, top, bottom // step 2: we create a writer that listens to the document and directs a PDF-stream to out createWriter(document, out); // we add some meta information to the document, and we open it final String title = export.getTitle(); if (title != null) { final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } final String author = export.getAuthor(); document.addAuthor(author); document.addCreator(CREATOR); document.open(); try { // pour ajouter l'ouverture automatique de la bote de dialogue imprimer (print(false) pour imprimer directement) // ((PdfWriter) writer).addJavaScript("this.print(true);", false); for (final ExportSheet exportSheet : export.getSheets()) { final Table datatable; if (exportSheet.hasDtObject()) { // table datatable = new Table(2); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // data rows renderObject(exportSheet, datatable); } else { // table datatable = new Table(exportSheet.getExportFields().size()); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // headers renderHeaders(exportSheet, datatable); // data rows renderList(exportSheet, datatable); } document.add(datatable); } } finally { // we close the document document.close(); } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException { final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); for (final ExportField exportColumn : exportSheet.getExportFields()) { datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont)); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject()); final int horizontalAlignement; if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else {//from www. j ava 2s.c o m horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(storeManager, referenceCache, denormCache, exportSheet.getDtObject(), exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, valueFont)); } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu de la liste./*from w ww . j a v a 2 s .c om*/ * * @param parameters Paramtres * @param datatable Table */ private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException { // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); whiteFont.setColor(Color.WHITE); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // Parcours des DTO de la DTC for (final DtObject dto : parameters.getDtList()) { for (final ExportField exportColumn : parameters.getExportFields()) { final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(dto); final int horizontalAlignement; if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else { horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(storeManager, referenceCache, denormCache, dto, exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, font)); } } }
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
private int createPasswordLetterContent(DocumentPrintContext dpc) throws ContentCreationException { IWBundle iwb = getIWApplicationContext().getIWMainApplication() .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER); System.out.println("Default locale: " + getIWApplicationContext().getApplicationSettings().getDefaultLocale().toString()); String sAddrString = ""; PdfContentByte cb = dpc.getPdfWriter().getDirectContent(); Document document = dpc.getDocument(); Locale locale = dpc.getLocale(); PrintMessage msg = dpc.getMessage(); // String mail_zip = iwb.getProperty("commune.mail_zip"); // String mail_name = iwb.getProperty("commune.mail_name"); try {//from www. ja v a 2s .com sAddrString = getAddressString(dpc.getMessage().getOwner()); } catch (Exception nouser) { handleNoAddressUser(); System.err.println(nouser.getMessage()); // nouser.printStackTrace(); return ADDRESS_ERROR; } try { if (addTemplateHeader()) { ColumnText ct = new ColumnText(cb); float margin = getPointsFromMM(14); float lly = getPointsFromMM(297 - 22); float ury = lly + 60f; float urx = 595f - margin - 60f - 5f; float llx = 110f + margin; Phrase Ph0 = new Phrase(sAddrString, new Font(Font.HELVETICA, 12, Font.BOLD)); ct.setSimpleColumn(Ph0, llx, lly, urx, ury, 15, Element.ALIGN_LEFT); ct.go(); document.add(new Paragraph("\n\n\n\n\n\n\n")); } { User owner = msg.getOwner(); HashMap tagmap = new CommuneUserTagMap(getIWApplicationContext(), owner); tagmap.putAll(getMessageTagMap(msg, locale)); XmlPeer date = new XmlPeer(ElementTags.CHUNK, "date"); date.setContent(new IWTimestamp().getDateString("dd.MM.yyyy")); tagmap.put(date.getAlias(), date); System.out.println("Date tag: " + date.getTag()); String letterUrl = getXMLLetterUrl(iwb, locale, "password_letter.xml"); if (msg.getBody().indexOf("|") > 0) { StringTokenizer tokenizer = new StringTokenizer(msg.getBody(), "|"); XmlPeer peer = new XmlPeer(ElementTags.ITEXT, "letter"); tagmap.put(peer.getAlias(), peer); if (tokenizer.hasMoreTokens()) { peer = new XmlPeer(ElementTags.CHUNK, "username"); peer.setContent(tokenizer.nextToken()); tagmap.put(peer.getAlias(), peer); } if (tokenizer.hasMoreTokens()) { peer = new XmlPeer(ElementTags.CHUNK, "password"); peer.setContent(tokenizer.nextToken()); tagmap.put(peer.getAlias(), peer); } } javax.xml.parsers.SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); SAXmyHandler handler = new SAXmyHandler(document, tagmap); handler.setControlOpenClose(false); parser.parse(letterUrl, handler); } } catch (Exception e) { throw new ContentCreationException(e); } return 0; }
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
public void createAddressContent(String addressString, PdfWriter writer) throws DocumentException { IWBundle iwb = getIWApplicationContext().getIWMainApplication() .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER); checkBundleDimensions(iwb);// w w w. jav a 2 s . c o m Phrase Ph0 = new Phrase(addressString, getAddressFont()); ColumnText ct = new ColumnText(writer.getDirectContent()); /* * public void setSimpleColumn(Phrase phrase, float llx, float lly, float urx, float ury, float leading, int alignment) Parameters: phrase - a * Phrase llx - the lower left x corner lly - the lower left y corner urx - the upper right x corner ury - the upper right y corner leading - the * leading alignment - the column alignment * */ float llx = getPointsFromMM(addressLowerLeftX);// getPointsFromMM((20f+95f)); float lly = getPointsFromMM(addressLowerLeftY);// 655f; float urx = getPointsFromMM(addressUpperRightX);// getPointsFromMM((193f)); float ury = getPointsFromMM(addressUpperRightY);// getPointsFromMM(257f); // ct.setSimpleColumn(Ph0,getPointsFromMM((20f+95f)), 655f, // getPointsFromMM((193f)), getPointsFromMM(257f), 15, Element.ALIGN_LEFT); // ct.setSimpleColumn(Ph0,getPointsFromMM(new // Float(addressLowerLeftX).floatValue()), new // Float(addressLowerLeftY).floatValue(), new // Float(addressUpperRightX).floatValue(), new // Float(addressUpperRightY).floatValue(), 15, Element.ALIGN_LEFT); ct.setSimpleColumn(Ph0, llx, lly, urx, ury, 15, Element.ALIGN_LEFT); ct.go(); }
From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java
License:Open Source License
/** * @param experiment/*from ww w.j a v a2 s . c o m*/ * @return */ private Element getMeasurementTable(Experiment3VO experiment, List<Buffer3VO> buffers) { PdfPTable table = new PdfPTable(MEASUREMENT_COLUMNS.length); table.setWidthPercentage(100f); table.getDefaultCell().setPadding(3); table.getDefaultCell().setColspan(MEASUREMENT_COLUMNS.length); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setColspan(1); table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR); for (int i = 0; i < MEASUREMENT_COLUMNS.length; i++) { table.addCell(this.getCell(MEASUREMENT_COLUMNS[i], BaseFont.HELVETICA_BOLD)); } table.getDefaultCell().setBackgroundColor(null); List<List<String>> data = this.getExperimentMesurementData(experiment, buffers); for (List<String> list : data) { for (String string : list) { table.addCell(getCell(string)); } } return table; }