List of usage examples for com.lowagie.text PageSize A4
Rectangle A4
To view the source code for com.lowagie.text PageSize A4.
Click Source Link
From source file:edu.eci.pdsw.g4.bean.control.web.SystemManageBean.java
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.open();//from ww w . ja va 2s . c o m pdf.setPageSize(PageSize.A4); pdf.addTitle("Ficha del Equipo : " + loadTipoEquipo.getNombre_equipo()); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); String logo = externalContext.getRealPath("") + File.separator + "resource" + File.separator + "ecijulio.png"; pdf.add(Image.getInstance(logo)); pdf.bottom(30); pdf.add(new Chunk( "Datos del Equipo : " + loadTipoEquipo.getNombre_equipo() + " con Placa No : " + getPlacaficha())); }
From source file:fr.aliasource.webmail.server.export.ConversationExporter.java
License:GNU General Public License
public void exportToPdf(IAccount account, ConversationReference cr, ClientMessage[] cm, OutputStream out) throws ConversationExporterException { try {// w ww .j a v a 2s .c o m Document document = new Document(PageSize.A4, 22, 22, 80, 72); PdfWriter writer = PdfWriter.getInstance(document, out); writer.setPageEvent(new ConversationPdfEventHandler(account, cr, cm)); // NPP by Tom if (cr.getTitle() != null) { document.addTitle(cr.getTitle()); } else { document.addTitle(""); } document.addAuthor("MiniG"); document.open(); document.add(Chunk.NEWLINE); Set<ClientMessage> scm = new LinkedHashSet<ClientMessage>(); for (int i = 0; i < cm.length; i++) { scm.add(cm[i]); } this.exportMessage(scm, document, false); document.close(); } catch (Exception e) { throw new ConversationExporterException("Cannot export conversation ", e); } }
From source file:fr.opensagres.xdocreport.itext.extension.NestedTable.java
License:Open Source License
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {//from w ww .j a v a 2 s. c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NestedTable.pdf")); document.open(); PdfPTable table = new PdfPTable(1); PdfPTable nestedTable = new PdfPTable(2); PdfPCell cell = new PdfPCell(nestedTable); PdfPCell cell1 = new PdfPCell(); cell1.addElement(new Chunk("cell1")); nestedTable.addCell(cell1); PdfPCell cell2 = new PdfPCell(); cell2.addElement(new Chunk("cell2")); nestedTable.addCell(cell2); table.addCell(cell); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:fr.opensagres.xdocreport.itext.extension.NestedTable2.java
License:Open Source License
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {//from w w w . ja va 2 s. co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NestedTable2.pdf")); document.open(); PdfPTable table = new PdfPTable(1); PdfPTable nestedTable = new PdfPTable(2); PdfPCell cell1 = new PdfPCell(); cell1.addElement(new Chunk("cell1")); nestedTable.addCell(cell1); PdfPCell cell2 = new PdfPCell(); cell2.addElement(new Chunk("cell2")); nestedTable.addCell(cell2); Paragraph paragraph = new Paragraph(); paragraph.add(new Chunk("eeeeeeeeee")); paragraph.add(nestedTable); PdfPCell cell = new PdfPCell(paragraph); //cell.addElement( nestedTable ); //cell.addElement( new Chunk("cell3") ); //cell. table.addCell(cell); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:fr.opensagres.xdocreport.itext.extension.SimpleTable.java
License:Open Source License
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {//from w ww.j a va2s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SimpleTable.pdf")); document.open(); PdfPTable table = new PdfPTable(2); PdfPCell cell; Paragraph p = new Paragraph("Text Text Text "); table.addCell("cell"); table.addCell(p); table.addCell("cell"); cell = new PdfPCell(p); p = new Paragraph("Text Text Text "); //Chunk c = new Chunk( "zzzzzzzzzz" ); //cell.setPadding( 0f ); //cell.getColumn().setAdjustFirstLine( false ); // make a room for borders //cell.setUseBorderPadding( false ); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(Color.red); cell.addElement(p); cell.setUseAscender(true); //cell.addElement(c ); // cell.setPaddingTop( 0f ); // cell.setPaddingLeft( 20f ); table.addCell(cell); //table.addCell( "cell" ); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:fr.opensagres.xdocreport.itext.extension.TableWithAlignment.java
License:Open Source License
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {// ww w .j a v a 2s. c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TableWithAlignment.pdf")); document.open(); PdfPTable table = new PdfPTable(2); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(true); table.setWidths(new float[] { 5, 10 }); table.setWidthPercentage(10); PdfPCell cell1 = new PdfPCell(); cell1.addElement(new Chunk("cell1")); table.addCell(cell1); PdfPCell cell2 = new PdfPCell(); cell2.addElement(new Chunk("cell2")); table.addCell(cell2); table.setSpacingBefore(-100); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:fr.opensagres.xdocreport.itext.extension.TableWithVerticalAlignment.java
License:Open Source License
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {//from w w w . j a va 2 s. c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TableWithVerticalAlignment.pdf")); document.open(); PdfPTable table = new PdfPTable(1); // PdfPCell cell1 = new PdfPCell(); // cell1.setVerticalAlignment( Element.ALIGN_BOTTOM ); // //cell1.setMinimumHeight( 100f ); // cell1.addElement( new Chunk( "cell1" ) ); // table.addCell( cell1 ); PdfPCell cell2 = new PdfPCell(); Paragraph p = new Paragraph(); p.add(new Chunk("cellp&")); cell2.addElement(p); cell2.setVerticalAlignment(Element.ALIGN_BOTTOM); cell2.setMinimumHeight(38f); table.addCell(cell2); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.utils.PDFUtils.java
License:Open Source License
/** * method to create PDF//from www . java 2 s . com * @param adminUser The admin user * @param locale The locale * @param strNameFile PDF name * @param out OutputStream * @param nIdRecord the id record * @param listIdEntryConfig list of config id entry * @param bExtractNotFilledField if true, extract empty fields, false */ public static void doCreateDocumentPDF(AdminUser adminUser, Locale locale, String strNameFile, OutputStream out, int nIdRecord, List<Integer> listIdEntryConfig, Boolean bExtractNotFilledField) { Document document = new Document(PageSize.A4); Plugin plugin = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME); EntryFilter filter; Record record = RecordHome.findByPrimaryKey(nIdRecord, plugin); filter = new EntryFilter(); filter.setIdDirectory(record.getDirectory().getIdDirectory()); filter.setIsGroup(EntryFilter.FILTER_TRUE); List<IEntry> listEntry = DirectoryUtils.getFormEntries(record.getDirectory().getIdDirectory(), plugin, adminUser); int nIdDirectory = record.getDirectory().getIdDirectory(); Directory directory = DirectoryHome.findByPrimaryKey(nIdDirectory, plugin); try { PdfWriter.getInstance(document, out); } catch (DocumentException e) { AppLogService.error(e); } document.open(); if (record.getDateCreation() != null) { SimpleDateFormat monthDayYearformatter = new SimpleDateFormat( AppPropertiesService.getProperty(PROPERTY_POLICE_FORMAT_DATE)); Font fontDate = new Font( DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)), DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_DATE)), DirectoryUtils .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_DATE))); Paragraph paragraphDate = new Paragraph( new Phrase(monthDayYearformatter.format(record.getDateCreation()).toString(), fontDate)); paragraphDate.setAlignment(DirectoryUtils .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_ALIGN_DATE))); try { document.add(paragraphDate); } catch (DocumentException e) { AppLogService.error(e); } } Image image; try { image = Image.getInstance(ImageIO.read(new File(AppPathService .getAbsolutePathFromRelativePath(AppPropertiesService.getProperty(PROPERTY_IMAGE_URL)))), null); image.setAlignment( DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_IMAGE_ALIGN))); float fitWidth; float fitHeight; try { fitWidth = Float.parseFloat(AppPropertiesService.getProperty(PROPERTY_IMAGE_FITWIDTH)); fitHeight = Float.parseFloat(AppPropertiesService.getProperty(PROPERTY_IMAGE_FITHEIGHT)); } catch (NumberFormatException e) { fitWidth = 100f; fitHeight = 100f; } image.scaleToFit(fitWidth, fitHeight); try { document.add(image); } catch (DocumentException e) { AppLogService.error(e); } } catch (BadElementException e) { AppLogService.error(e); } catch (MalformedURLException e) { AppLogService.error(e); } catch (IOException e) { AppLogService.error(e); } directory.getTitle(); Font fontTitle = new Font( DirectoryUtils.convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_NAME)), DirectoryUtils .convertStringToInt(AppPropertiesService.getProperty(PROPERTY_POLICE_SIZE_TITLE_DIRECTORY)), DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_STYLE_TITLE_DIRECTORY))); fontTitle.isUnderlined(); Paragraph paragraphHeader = new Paragraph(new Phrase(directory.getTitle(), fontTitle)); paragraphHeader.setAlignment(Element.ALIGN_CENTER); paragraphHeader.setSpacingBefore(DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_BEFORE_TITLE_DIRECTORY))); paragraphHeader.setSpacingAfter(DirectoryUtils.convertStringToInt( AppPropertiesService.getProperty(PROPERTY_POLICE_SPACING_AFTER_TITLE_DIRECTORY))); try { document.add(paragraphHeader); } catch (DocumentException e) { AppLogService.error(e); } builderPDFWithEntry(document, plugin, nIdRecord, listEntry, listIdEntryConfig, locale, bExtractNotFilledField); document.close(); }
From source file:fr.univlorraine.mondossierweb.controllers.CalendrierController.java
License:Apache License
/** * configure le document pdf./* w w w .j a v a 2 s . c om*/ * @param width * @param height * @param margin * @return doc */ private Document configureDocument(final float margin) { Document document = new Document(); document.setPageSize(PageSize.A4.rotate()); float marginPage = (margin / 2.54f) * 72f; document.setMargins(marginPage, marginPage, marginPage, marginPage); return document; }
From source file:fr.univlorraine.mondossierweb.controllers.InscriptionController.java
License:Apache License
/** * configure le document pdf./*from w w w. j a v a 2s . co m*/ * @param width * @param height * @param margin * @return doc */ private Document configureDocument() { Document document = new Document(); document.setPageSize(PageSize.A4); float marginTop = (MARGIN_TOP / 2.54f) * 72f; float marginRight = (MARGIN_RIGHT / 2.54f) * 72f; float marginBottom = (MARGIN_BOTTOM / 2.54f) * 72f; float marginLeft = (MARGIN_LEFT / 2.54f) * 72f; document.setMargins(marginLeft, marginRight, marginTop, marginBottom); return document; }