List of usage examples for com.lowagie.text.pdf PdfWriter setBoxSize
public void setBoxSize(String boxName, Rectangle size)
From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java
License:Open Source License
public static void createLaborwertTable(Patient patient, String filename, LinkedList<String[]> laborBlatt, String footerText) throws IOException, DocumentException { // step 1//from w ww .jav a2 s . co m Document document = new Document(PageSize.A4); // step 2 PdfWriter.getInstance(document, new FileOutputStream(filename)); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3 writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent(); event.setHeaderText( patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")"); event.setFooterText(footerText); writer.setPageEvent(event); document.setMargins(56, 72, 60, 60); // step 3 document.open(); if (laborBlatt.size() == 0) { Paragraph p = new Paragraph(new Chunk("Keine Laborwerte vorhanden", fontTimesTitle)); p.setSpacingBefore(20f); document.add(p); } else { document.add(createTable2(laborBlatt)); } // step 5 document.close(); }
From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java
License:Open Source License
public static void createDiagnosenSheet(Patient patient, String filename, String footerText) throws DocumentException, IOException { StringBuffer sb = new StringBuffer("Diagnosen:\n"); sb.append(patient.getDiagnosen());/*from w w w .ja va 2s. com*/ sb.append("\n"); sb.append("Persnliche Anamnese:\n"); sb.append(patient.getPersAnamnese()); sb.append("\n"); // step 1 Document document = new Document(PageSize.A4); // step 2 PdfWriter.getInstance(document, new FileOutputStream(filename)); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3 //Rectangle rect = new Rectangle(30, 30, 559, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent(); event.setHeaderText( patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")"); event.setFooterText(footerText); writer.setPageEvent(event); document.setMargins(36, 72, 60, 60); // step 3 document.open(); document.add(new Chunk("")); // << this will do the trick. if (patient.getDiagnosen().length() > 0) { Paragraph p = new Paragraph("Diagnosen:", fontTimesTitle); p.setSpacingAfter(10f); document.add(p); String[] chunksDiag = patient.getDiagnosen().toString().split("(?m)^\\s*$"); for (String chunk : chunksDiag) { document.add(new Paragraph(chunk, fontTimes)); } } else { document.add(new Paragraph("Keine Diagnosen vorhanden", fontTimes)); } if (patient.getPersAnamnese().length() > 0) { Paragraph p = new Paragraph("Persnliche Anamnese:", fontTimesTitle); p.setSpacingBefore(10f); p.setSpacingAfter(10f); document.add(p); String[] chunksAnam = patient.getPersAnamnese().toString().split("(?m)^\\s*$"); for (String chunk : chunksAnam) { document.add(new Paragraph(chunk, fontTimes)); } } else { document.add(new Paragraph("Keine Persnliche Anamnese vorhanden", fontTimes)); } // step 5 document.close(); }
From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java
License:Open Source License
public static void createFixMediSheet(Patient patient, String filename, String footerText) throws DocumentException, IOException { Prescription[] prescriptions = patient.getFixmedikation(); StringBuffer sb = new StringBuffer(); for (Prescription prescription : prescriptions) { //System.out.println("Prescription: " + prescription.getLabel() + "/" + prescription.getDosis()); sb.append(prescription.getLabel()); sb.append("\r\n"); }//from w ww. j a v a 2 s . c o m // step 1 Document document = new Document(PageSize.A4); // step 2 PdfWriter.getInstance(document, new FileOutputStream(filename)); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3 //Rectangle rect = new Rectangle(30, 30, 559, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent(); event.setHeaderText( patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")"); event.setFooterText(footerText); writer.setPageEvent(event); document.setMargins(36, 72, 60, 60); // step 3 document.open(); document.add(new Chunk("")); // << this will do the trick. if (sb.length() > 0) { Paragraph p = new Paragraph("Fixmedikation:", fontTimesTitle); p.setSpacingAfter(10f); document.add(p); String[] chunksDiag = sb.toString().split("(?m)^\\s*$"); for (String chunk : chunksDiag) { document.add(new Paragraph(chunk, fontTimes)); } } else { //document.add(new Paragraph("Keine Medikationen vorhanden", fontTimes)); Paragraph p = new Paragraph(new Chunk("Keine Medikationen vorhanden", fontTimesTitle)); p.setSpacingBefore(20f); document.add(p); } // step 5 document.close(); }
From source file:classroom.filmfestival_c.Movies19.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // step 1/*from ww w . j av a 2s . c o m*/ Rectangle rect = PageSize.A4.rotate(); Document document = new Document(rect); try { // step 2 OutputStream os = new FileOutputStream(RESULT); PdfWriter writer = PdfWriter.getInstance(document, os); Rectangle art = new Rectangle(rect.getLeft(36), rect.getBottom(36), rect.getRight(36), rect.getTop(36)); writer.setBoxSize("art", art); // step 3 document.open(); // step 4 Session session = (Session) MySessionFactory.currentSession(); Query q = session.createQuery( "select distinct festival.id.day from FestivalScreening as festival order by festival.id.day"); java.util.List<Date> days = q.list(); for (Date day : days) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(day); if (gc.get(GregorianCalendar.YEAR) != YEAR) continue; createSheet(session, day, writer); document.newPage(); } // step 5 document.close(); } catch (IOException e) { LOGGER.error("IOException: ", e); } catch (DocumentException e) { LOGGER.error("DocumentException: ", e); } }
From source file:classroom.filmfestival_c.Movies20.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // step 1//from w w w .jav a 2 s . co m Rectangle rect = PageSize.A4.rotate(); Document document = new Document(rect); try { // step 2 OutputStream os = new FileOutputStream(RESULT); PdfWriter writer = PdfWriter.getInstance(document, os); Rectangle art = new Rectangle(rect.getLeft(36), rect.getBottom(36), rect.getRight(36), rect.getTop(36)); writer.setBoxSize("art", art); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); // step 3 document.open(); // step 4 PdfOutline root = writer.getDirectContent().getRootOutline(); Session session = (Session) MySessionFactory.currentSession(); Query q = session.createQuery( "select distinct festival.id.day from FestivalScreening as festival order by festival.id.day"); java.util.List<Date> days = q.list(); for (Date day : days) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(day); if (gc.get(GregorianCalendar.YEAR) != YEAR) continue; createSheet(session, day, writer); new PdfOutline(root, new PdfDestination(PdfDestination.FIT), day.toString()); document.newPage(); } // step 5 document.close(); } catch (IOException e) { LOGGER.error("IOException: ", e); } catch (DocumentException e) { LOGGER.error("DocumentException: ", e); } }
From source file:de.dhbw.humbuch.util.PDFHandler.java
/** * Creates the pdf with the information in the object that was passed to the * constructor previously./*ww w. j a va2s . c om*/ * * @param path * where the file will be saved */ public void savePDF(String path) { try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path)); event = new HeaderFooter(); writer.setBoxSize("art", new Rectangle(36, 54, 559, 788)); writer.setPageEvent(event); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } this.document.open(); this.addMetaData(document); this.insertDocumentParts(document); this.document.close(); }
From source file:de.dhbw.humbuch.util.PDFHandler.java
/** * Creates a ByteArrayOutputStream which contains the PDF as a byte array. * //from w ww . j a va 2 s . c o m * @return the byteArrayOutputStream the PDF is stored in, null if an error * occurred. */ public ByteArrayOutputStream createByteArrayOutputStreamForPDF() { ByteArrayOutputStream byteArrayOutputStream; try { byteArrayOutputStream = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, byteArrayOutputStream); event = new HeaderFooter(); writer.setBoxSize("art", new Rectangle(36, 54, 559, 788)); writer.setPageEvent(event); this.document.open(); this.addMetaData(document); int initialDocumentSize = writer.getCurrentDocumentSize(); this.insertDocumentParts(document); if (byteArrayOutputStream.size() > 0 || writer.getCurrentDocumentSize() > initialDocumentSize) { this.document.close(); } else { return null; } return byteArrayOutputStream; } catch (DocumentException e) { System.err.println("Could not create ByteArrayOutputStream of PDF data. " + e.getMessage()); } return null; }