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:ExamplePdfPrinter.java
License:Open Source License
public static void main(String[] args) throws Exception { SpooledFile spooledFile = null; // TODO: provide your spool file! final IScsDataProvider dp = As400ScsDataProviderFactory.getPrintObjectDataProvider(spooledFile); final ReaderConfig rcfg = ReaderConfig.getDefault(); final SCSStreamReader reader = new SCSStreamReader(dp, rcfg); PrinterConfig pcfg = PrinterConfig.getDefault(); float FONT_SIZE = 9.0F; float leading = FONT_SIZE * 1.05F; // calculate font, font size, and margins for the PDF final Font monoSpacedFont = FontFactory.getFont(BaseFont.COURIER, FONT_SIZE); final Font monoSpacedFontBold = FontFactory.getFont(BaseFont.COURIER_BOLD, Font.BOLD); Rectangle pageSize = new Rectangle(PageSize.A4); final Document pdfdoc = new Document(pageSize); final FileOutputStream fos = new FileOutputStream("test.pdf"); final PdfWriter pdfwriter = PdfWriter.getInstance(pdfdoc, fos); pdfdoc.open();/*from w ww . ja v a 2 s . c o m*/ PdfPrinter pdfprinter = new PdfPrinter(pcfg, pdfdoc, monoSpacedFont, monoSpacedFontBold, leading); try { while (reader.hasNext()) { final IPrinterMicroCommand event = reader.next(); if (event == null) break; pdfprinter.runMicroCommand(event); } } catch (EndOfFileSignal e) { System.out.println("eof."); } pdfprinter.finish(); pdfdoc.close(); pdfwriter.close(); }
From source file:airportpainter.util.AirportPainter.java
License:Open Source License
public static void writeAirportImage(Airport airport, String filename, String backgroundColor_, boolean drawObjectsInAirport, boolean drawObjectsInMap, boolean drawTerrainInMap) { //Image image = new Image( Display.getCurrent(),400, 400); String pdfName = filename + ".pdf"; /*String pngName1=filename+"_airport.png"; String pngName2=filename+"_map.png";*/ backgroundColor = backgroundColor_;/* w w w. j av a 2 s. c om*/ final AirportPainter ap = new AirportPainter(airport); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); width = 520; height = ((int) PageSize.A4.height()) - 150 - 30 * airport.getRunwayCount() - 100; //int height=740; //BufferedImage bimage = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT); //Graphics2D g2d = bimage.createGraphics(); Document document = new Document(); PdfWriter writer; try { try { writer = PdfWriter.getInstance(document, new FileOutputStream(pdfName)); document.open(); g2d = writer.getDirectContent().createGraphicsShapes(PageSize.A4.width(), PageSize.A4.height()); ap.drawAirport(g2d, 0, 0, width, height - 30, drawObjectsInAirport); ap.createSheets1(airport, writer, document, pdfName, drawObjectsInMap, drawTerrainInMap); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } /* if (! backgroundColor.equals("")) { g2d.setColor(Color.decode("0x"+backgroundColor)); Polygon p = new Polygon(); p.addPoint(0, 0); p.addPoint(width, 0); p.addPoint(width, height); p.addPoint(0, height); p.addPoint(0, 0); g2d.fillPolygon(p); } System.out.print("Creating:"+pngName1+" ... "); */ /* File outputfile = new File(pngName1); try { ImageIO.write(bimage, "png", outputfile); } catch(Exception e) { System.out.println(e); } */ /*// doing PDF now Document document = new Document(); try { System.out.println(pdfName+" OK"); PdfWriter.getInstance(document, new FileOutputStream(pdfName)); // step 3: we open the document document.open(); // step 4: we add some paragraphs to the document document.add( new Paragraph(airport.getId()+" - "+airport.getName()) ); Image im; try { im = Image.getInstance(filename); document.add(im); // step 5: we close the document document.close(); } catch (BadElementException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex); } */ /*if (! keepPng) { outputfile.delete(); }*/ }
From source file:ambit.data.qmrf.Qmrf_Xml_Pdf.java
License:Open Source License
public void xml2pdf(InputSource xml, OutputStream pdf) { try {/*from ww w . j a v a 2 s. c om*/ Document document = new Document(PageSize.A4, 80, 50, 30, 65); PdfWriter writer = PdfWriter.getInstance(document, pdf); //writer.setViewerPreferences(PdfWriter.HideMenubar| PdfWriter.HideToolbar); writer.setViewerPreferences(PdfWriter.PageModeUseThumbs | PdfWriter.PageModeUseOutlines); //PdfOutline root = writer.getDirectContent().getRootOutline(); //new PdfOutline(root, new PDFAction("http://nina.acad.bg/qmrf"), "a bookmark"); //writer.addFileAttachment(arg0, arg1, arg2, arg3) if (docBuilder == null) docBuilder = docBuilderFactory.newDocumentBuilder(); docBuilder.setErrorHandler(new SimpleErrorHandler(getClass().getName())); QMRFSchemaResolver resolver = new QMRFSchemaResolver("http://ambit.acad.bg/qmrf/qmrf.dtd", null); resolver.setIgnoreSystemID(true); docBuilder.setEntityResolver(resolver); org.w3c.dom.Document doc = null; try { doc = docBuilder.parse(xml); } catch (Exception x) { document.addCreationDate(); document.addCreator(getClass().getName()); document.open(); document.add(new Paragraph(new Chunk(x.getMessage()))); document.close(); return; } document.addCreationDate(); document.addCreator(getClass().getName()); document.addKeywords(replaceTags(findNodeValue("keywords", doc))); document.addTitle(replaceTags(findNodeValue("QSAR_title", doc))); try { NodeList info = doc.getElementsByTagName("QMRF"); for (int i = 0; i < info.getLength(); i++) document.addSubject(findAttributeValue("name", info.item(i)) + '.' + findAttributeValue("version", info.item(i))); } catch (Exception x) { document.addSubject("QMRF"); } try { document.addAuthor(listNodeAttributes(doc, "qmrf_authors", "author_ref", "author", att_author, new Boolean(true))); } catch (Exception x) { document.addAuthor(getClass().getName()); } document.open(); PdfContentByte cb = writer.getDirectContent(); try { headerTable(document, doc); } catch (Exception x) { document.add(new Paragraph(new Chunk(x.getMessage()))); document.close(); return; } PdfOutline root = writer.getDirectContent().getRootOutline(); for (int i = 0; i < subchapters.length; i++) try { int align = Paragraph.ALIGN_LEFT; if (Mode.chapter == (Mode) subchapters[i][2]) { document.add(new Paragraph(new Chunk('\n'))); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); StringBuffer b = new StringBuffer(); b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc)); b.append('.'); b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc)); String bookmark = b.toString(); Chunk title = new Chunk(bookmark); title.setLocalDestination(bookmark); title.setFont(bfont); PdfDestination destination = new PdfDestination(PdfDestination.FITH); PdfOutline outline = new PdfOutline(root, destination, bookmark); Paragraph p = new Paragraph(title); PdfPCell cell = new PdfPCell(p); cell.setBackgroundColor(chapterColor); table.addCell(cell); document.add(table); float pos = writer.getVerticalPosition(false); if (pos < 90) document.newPage(); } else { Phrase phrase = new Phrase(); switch ((Mode) subchapters[i][2]) { case title: { StringBuffer b = new StringBuffer(); String cn = findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc); if (cn == null) break; b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc)); b.append('.'); b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc)); String subchapterBookmark = b.toString(); b.append(':'); Chunk title = new Chunk(b.toString()); title.setLocalDestination(subchapterBookmark); title.setFont(bfont); phrase.add(title); PdfDestination destination = new PdfDestination(PdfDestination.FITBH); PdfOutline outline = new PdfOutline(root, destination, subchapterBookmark); break; } case text: { createNodePhrase(subchapters[i][0].toString(), doc, phrase, font); align = Paragraph.ALIGN_JUSTIFIED; break; } case answer: { String a = findAnswer(subchapters[i][0].toString(), doc); if (a != null) { Chunk answer = new Chunk(a); answer.setFont(font); phrase.add(answer); } break; } case dataset: { StringBuffer b = new StringBuffer(); b.append(findDataAvailable(subchapters[i][0].toString(), doc)); Chunk dataset = new Chunk(b.toString()); dataset.setFont(font); phrase.add(dataset); break; } case attachments: { PdfPTable table = getAttachmentsAsTable(doc, "attachment_training_data"); if (table != null) { phrase.add(new Paragraph("Training set(s)")); phrase.add(table); } table = getAttachmentsAsTable(doc, "attachment_validation_data"); if (table != null) { phrase.add(new Paragraph("Test set(s)")); phrase.add(table); } table = getAttachmentsAsTable(doc, "attachment_documents"); if (table != null) { phrase.add(new Paragraph("Supporting information")); phrase.add(table); } break; /* StringBuffer b = new StringBuffer(); b.append("Training set(s)\n"); b.append(listAttachments(doc,"attachment_training_data")); b.append("Test set(s)\n"); b.append(listAttachments(doc,"attachment_validation_data")); b.append("Supporting information\n"); b.append(listAttachments(doc,"attachment_documents")); Chunk attachments = new Chunk(b.toString()); attachments.setFont(font); phrase.add(attachments); break; */ } case reference: { try { String value = listNodeAttributes(doc, subchapters[i][0].toString(), subchapters[i][3].toString(), subchapters[i][4].toString(), (String[]) subchapters[i][5], (Boolean) subchapters[i][6]); Chunk reference = new Chunk(value); reference.setFont(font); align = Paragraph.ALIGN_JUSTIFIED; phrase.add(reference); } catch (Exception x) { } break; } } Paragraph p = new Paragraph(phrase); p.setAlignment(align); document.add(p); float pos = writer.getVerticalPosition(false); /* cb.moveTo(0, pos); cb.lineTo(PageSize.A4.width(), pos); cb.stroke(); */ if (pos < 90) document.newPage(); } } catch (Exception x) { x.printStackTrace(); } document.close(); } catch (Exception e) { e.printStackTrace(); System.err.println(e.getMessage()); } }
From source file:ambit.io.PDFWriter.java
License:Open Source License
public void setWriter(OutputStream out) throws CDKException { pdfDoc = new Document(PageSize.A4, 80, 50, 30, 65); try {/* w w w .j av a2 s . c o m*/ pdfWriter = PdfWriter.getInstance(pdfDoc, out); //writer.setViewerPreferences(PdfWriter.HideMenubar| PdfWriter.HideToolbar); pdfWriter.setViewerPreferences(PdfWriter.PageModeUseThumbs | PdfWriter.PageModeUseOutlines); pdfDoc.addCreationDate(); pdfDoc.addCreator(getClass().getName()); pdfDoc.addKeywords("structures"); pdfDoc.addTitle("structures"); pdfDoc.addSubject(""); pdfDoc.addAuthor("AMBIT"); pdfDoc.open(); /* pdfDoc.add(new Paragraph(method.getTitle())); pdfDoc.add(new Paragraph(method.getExplanation())); pdfDoc.add(new Paragraph()); */ table = new PdfPTable(new float[] { 3f, 5f }); table.setWidthPercentage(100); } catch (Exception x) { throw new CDKException(x.getMessage()); } }
From source file:ambit2.core.io.PDFWriter.java
License:Open Source License
public void setWriter(OutputStream out) throws CDKException { pdfDoc = new Document(PageSize.A4, 80, 50, 30, 65); try {/*w w w . jav a2 s . co m*/ pdfWriter = PdfWriter.getInstance(pdfDoc, out); //writer.setViewerPreferences(PdfWriter.HideMenubar| PdfWriter.HideToolbar); pdfWriter.setViewerPreferences(PdfWriter.PageModeUseThumbs | PdfWriter.PageModeUseOutlines); pdfDoc.addCreationDate(); pdfDoc.addCreator(getClass().getName()); pdfDoc.addKeywords("structures"); pdfDoc.addTitle("structures"); pdfDoc.addSubject(""); pdfDoc.addAuthor("Toxtree"); pdfDoc.open(); /* pdfDoc.add(new Paragraph(method.getTitle())); pdfDoc.add(new Paragraph(method.getExplanation())); pdfDoc.add(new Paragraph()); */ table = new PdfPTable(new float[] { 3f, 5f }); table.setWidthPercentage(100); } catch (Exception x) { throw new CDKException(x.getMessage()); } }
From source file:ambit2.core.processors.ProcessorFileExport.java
public FileOutputState process(Content content) throws AmbitException { if (content == null) throw new AmbitException("Workbook not assigned!"); Document document = new Document(PageSize.A4.rotate()); try {/* ww w . ja v a 2 s . c o m*/ File file = getOutput().getFile(); if (file.getName().endsWith(FileOutputState.extensions[FileOutputState.SDF_INDEX])) { writeSDF(content, new FileOutputStream(file)); return getOutput(); } else if (file.getName().endsWith(FileOutputState.extensions[FileOutputState.PDF_INDEX])) writePDF(document, new FileOutputStream(file)); else if (file.getName().endsWith(FileOutputState.extensions[FileOutputState.RTF_INDEX])) writeRTF(document, new FileOutputStream(file)); else if (file.getName().endsWith(FileOutputState.extensions[FileOutputState.HTML_INDEX])) writeHTML(document, new FileOutputStream(file)); else if (file.getName().endsWith(FileOutputState.extensions[FileOutputState.XLS_INDEX])) { writeXLS(content, new FileOutputStream(file)); return getOutput(); } document.open(); write(document, content); return getOutput(); } catch (DocumentException e) { throw new AmbitException(e); } catch (FileNotFoundException e) { throw new AmbitException(e); } finally { document.close(); } }
From source file:ambit2.data.qmrf.Qmrf_Xml_Pdf.java
License:Open Source License
public void xml2pdf(InputSource xml, OutputStream pdf) { try {//from ww w.j a v a 2 s. co m Document document = new Document(PageSize.A4, 80, 50, 30, 65); PdfWriter writer = PdfWriter.getInstance(document, pdf); //writer.setViewerPreferences(PdfWriter.HideMenubar| PdfWriter.HideToolbar); writer.setViewerPreferences(PdfWriter.PageModeUseThumbs | PdfWriter.PageModeUseOutlines); //PdfOutline root = writer.getDirectContent().getRootOutline(); //new PdfOutline(root, new PDFAction("http://nina.acad.bg/qmrf"), "a bookmark"); //writer.addFileAttachment(arg0, arg1, arg2, arg3) if (docBuilder == null) docBuilder = docBuilderFactory.newDocumentBuilder(); docBuilder.setErrorHandler(new SimpleErrorHandler(getClass().getName())); QMRFSchemaResolver resolver = new QMRFSchemaResolver("http://ambit2.acad.bg/qmrf/qmrf.dtd", null); resolver.setIgnoreSystemID(true); docBuilder.setEntityResolver(resolver); org.w3c.dom.Document doc = null; try { doc = docBuilder.parse(xml); } catch (Exception x) { document.addCreationDate(); document.addCreator(getClass().getName()); document.open(); document.add(new Paragraph(new Chunk(x.getMessage()))); document.close(); return; } document.addCreationDate(); document.addCreator(getClass().getName()); document.addKeywords(replaceTags(findNodeValue("keywords", doc))); document.addTitle(replaceTags(findNodeValue("QSAR_title", doc))); try { NodeList info = doc.getElementsByTagName("QMRF"); for (int i = 0; i < info.getLength(); i++) document.addSubject(findAttributeValue("name", info.item(i)) + '.' + findAttributeValue("version", info.item(i))); } catch (Exception x) { document.addSubject("QMRF"); } try { document.addAuthor(listNodeAttributes(doc, "qmrf_authors", "author_ref", "author", att_author, new Boolean(true))); } catch (Exception x) { document.addAuthor(getClass().getName()); } document.open(); PdfContentByte cb = writer.getDirectContent(); try { headerTable(document, doc); } catch (Exception x) { document.add(new Paragraph(new Chunk(x.getMessage()))); document.close(); return; } PdfOutline root = writer.getDirectContent().getRootOutline(); for (int i = 0; i < subchapters.length; i++) try { int align = Paragraph.ALIGN_LEFT; if (Mode.chapter == (Mode) subchapters[i][2]) { document.add(new Paragraph(new Chunk('\n'))); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); StringBuffer b = new StringBuffer(); b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc)); b.append('.'); b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc)); String bookmark = b.toString(); Chunk title = new Chunk(bookmark); title.setLocalDestination(bookmark); title.setFont(bfont); PdfDestination destination = new PdfDestination(PdfDestination.FITH); PdfOutline outline = new PdfOutline(root, destination, bookmark); Paragraph p = new Paragraph(title); PdfPCell cell = new PdfPCell(p); cell.setBackgroundColor(chapterColor); table.addCell(cell); document.add(table); float pos = writer.getVerticalPosition(false); if (pos < 90) document.newPage(); } else { Phrase phrase = new Phrase(); switch ((Mode) subchapters[i][2]) { case title: { StringBuffer b = new StringBuffer(); String cn = findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc); if (cn == null) break; b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc)); b.append('.'); b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc)); String subchapterBookmark = b.toString(); b.append(':'); Chunk title = new Chunk(b.toString()); title.setLocalDestination(subchapterBookmark); title.setFont(bfont); phrase.add(title); PdfDestination destination = new PdfDestination(PdfDestination.FITBH); PdfOutline outline = new PdfOutline(root, destination, subchapterBookmark); break; } case text: { createNodePhrase(subchapters[i][0].toString(), doc, phrase, font); align = Paragraph.ALIGN_JUSTIFIED; break; } case answer: { String a = findAnswer(subchapters[i][0].toString(), doc); if (a != null) { Chunk answer = new Chunk(a); answer.setFont(font); phrase.add(answer); } break; } case dataset: { StringBuffer b = new StringBuffer(); b.append(findDataAvailable(subchapters[i][0].toString(), doc)); Chunk dataset = new Chunk(b.toString()); dataset.setFont(font); phrase.add(dataset); break; } case attachments: { PdfPTable table = getAttachmentsAsTable(doc, "attachment_training_data"); if (table != null) { phrase.add(new Paragraph("Training set(s)")); phrase.add(table); } table = getAttachmentsAsTable(doc, "attachment_validation_data"); if (table != null) { phrase.add(new Paragraph("Test set(s)")); phrase.add(table); } table = getAttachmentsAsTable(doc, "attachment_documents"); if (table != null) { phrase.add(new Paragraph("Supporting information")); phrase.add(table); } break; /* StringBuffer b = new StringBuffer(); b.append("Training set(s)\n"); b.append(listAttachments(doc,"attachment_training_data")); b.append("Test set(s)\n"); b.append(listAttachments(doc,"attachment_validation_data")); b.append("Supporting information\n"); b.append(listAttachments(doc,"attachment_documents")); Chunk attachments = new Chunk(b.toString()); attachments.setFont(font); phrase.add(attachments); break; */ } case reference: { try { String value = listNodeAttributes(doc, subchapters[i][0].toString(), subchapters[i][3].toString(), subchapters[i][4].toString(), (String[]) subchapters[i][5], (Boolean) subchapters[i][6]); Chunk reference = new Chunk(value); reference.setFont(font); align = Paragraph.ALIGN_JUSTIFIED; phrase.add(reference); } catch (Exception x) { } break; } } Paragraph p = new Paragraph(phrase); p.setAlignment(align); document.add(p); float pos = writer.getVerticalPosition(false); /* cb.moveTo(0, pos); cb.lineTo(PageSize.A4.width(), pos); cb.stroke(); */ if (pos < 90) document.newPage(); } } catch (Exception x) { x.printStackTrace(); } document.close(); } catch (Exception e) { e.printStackTrace(); System.err.println(e.getMessage()); } }
From source file:appli_etudiants.ExportPDF.java
public static void main(Etudiants etudiant) throws SQLException, FileNotFoundException, BadElementException, IOException { try {/* w ww.ja v a2 s .c o m*/ Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/tesPDF.pdf")); document.open(); PdfContentByte canvas = writer.getDirectContentUnder(); Image image = Image.getInstance("c:/fond_cv.jpg"); image.setAbsolutePosition(0, 80); canvas.saveState(); PdfGState state = new PdfGState(); state.setFillOpacity(0.6f); canvas.setGState(state); canvas.addImage(image); canvas.restoreState(); LineSeparator lineSepa = new LineSeparator(); lineSepa.setLineColor(new Color(21, 96, 189)); Paragraph para1 = new Paragraph(); Paragraph para2 = new Paragraph(etudiant.getAdresse_rue()); Paragraph para3 = new Paragraph(etudiant.getAdresse_cp() + " " + etudiant.getAdresse_ville()); Paragraph para4 = new Paragraph(etudiant.getCourriel(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))); Paragraph para5 = new Paragraph(etudiant.getTel_personnel()); Paragraph para6 = new Paragraph(etudiant.getTel_professionnel()); Paragraph para7 = new Paragraph(etudiant.getSite_web()); para1.add(new Chunk(etudiant.getPrenom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD, new Color(21, 96, 189)))); para1.add( new Chunk(" " + etudiant.getNom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD))); Image image1 = Image.getInstance(DaoS4.getPhoto()); image1.scalePercent(50); image1.setAlignment(Image.RIGHT | Image.TEXTWRAP); image1.scaleAbsolute(94, 94); document.add(image1); document.add(para1); document.add(para2); document.add(para3); document.add(para4); document.add(para5); document.add(para6); para7.setSpacingAfter(25f); document.add(para7); Paragraph para8 = new Paragraph(DaoS4.getLibelleTitre()); para8.setSpacingBefore(25f); para8.setSpacingAfter(20f); document.add(para8); Paragraph para9 = new Paragraph(new Chunk("EXPERIENCE PROFESSIONELLE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para9.setSpacingBefore(15f); para9.setSpacingAfter(15f); document.add(para9); document.add(lineSepa); Paragraph para10 = new Paragraph(DaoS4.getLibelleExpPro()); para10.setSpacingAfter(15f); document.add(para10); Paragraph para11 = new Paragraph(new Chunk("FORMATION", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para11.setSpacingBefore(15f); para11.setSpacingAfter(15f); document.add(para11); document.add(lineSepa); Paragraph para12 = new Paragraph(DaoS4.getLibelleFormation()); para12.setSpacingAfter(15f); document.add(para12); Paragraph para13 = new Paragraph(new Chunk("INFORMATIQUE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para13.setSpacingBefore(15f); para13.setSpacingAfter(15f); document.add(para13); document.add(lineSepa); Paragraph para14 = new Paragraph(DaoS4.getLibelleInformatique()); para14.setSpacingAfter(15f); document.add(para14); Paragraph para15 = new Paragraph(new Chunk("LANGUE", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para15.setSpacingBefore(15f); para15.setSpacingAfter(15f); document.add(para15); document.add(lineSepa); Paragraph para16 = new Paragraph(DaoS4.getLibelleLangue()); para16.setSpacingAfter(15f); document.add(para16); Paragraph para17 = new Paragraph(new Chunk("CENTRES D'INTERET", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)))); para17.setSpacingBefore(15f); para17.setSpacingAfter(15f); document.add(para17); document.add(lineSepa); Paragraph para18 = new Paragraph(DaoS4.getLibelleInteret()); para18.setSpacingAfter(15f); document.add(para18); document.close(); } catch (DocumentException ex) { Logger.getLogger(ExportPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:at.htlpinkafeld.beans.JahresuebersichtBean.java
/** * pre processes the PDF for creating//w w w.ja v a 2s . co m * * @param document pdf-doc * @throws DocumentException may be thrown */ public void preProcessPDF(Object document) throws DocumentException { Document pdf = (Document) document; pdf.open(); pdf.setPageSize(PageSize.A4); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.addCell(getCell("Jahresbersicht - " + selectedYear.getYear(), PdfPCell.ALIGN_LEFT)); table.addCell(getCell("", PdfPCell.ALIGN_CENTER)); table.addCell(getCell("von " + selectedUser.getPersName(), PdfPCell.ALIGN_RIGHT)); pdf.add(table); pdf.add(new Paragraph("\n")); }
From source file:at.htlpinkafeld.beans.UserDetailsBean.java
public void preProcessPDF(Object document) throws DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A4.rotate()); pdf.open();/*from w ww . jav a 2 s. c o m*/ PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.addCell(getCell("Monatsbersicht - " + selectedDate.format(DateTimeFormatter.ofPattern("MM.yyyy")), PdfPCell.ALIGN_LEFT)); table.addCell(getCell("", PdfPCell.ALIGN_CENTER)); table.addCell(getCell("von " + selectedUser, PdfPCell.ALIGN_RIGHT)); pdf.add(table); pdf.add(new Paragraph("\n")); }