List of usage examples for com.itextpdf.text Document setPageSize
public boolean setPageSize(Rectangle pageSize)
From source file:privilege.mouchard.MouchardCtrl.java
@Override public void imprimerTraceurPdf() { try {/*w w w . j a v a 2 s . co m*/ } catch (Exception e) { Personnel user = UtilitaireSession.getInstance().getuser(); if (user != null) { String fichier = "Liste_actionUtilisateur du " + new Date() + "_.pdf"; Document mouchard = new Document(); try { PdfWriter.getInstance(mouchard, new FileOutputStream(Utilitaires.path + "/" + fichier)); mouchard.setMargins(5, 5, 5, 5); mouchard.addCreator("School Manager"); mouchard.setPageSize(PageSize.A4); mouchard.open(); if (!getTraceurs().isEmpty()) { PdfPTable table = new PdfPTable(6); table.setComplete(true); table.addCell(PrintUtils.createPdfPCell("Liste des actions utilisateur", 6, detail)); table.addCell(new Paragraph("Nom")); table.addCell(PrintUtils.createPdfPCell("Prnom ", true)); table.addCell(PrintUtils.createPdfPCell("Action ", 3, true)); table.addCell(PrintUtils.createPdfPCell("Date", true)); for (int i = 0; i < getTraceurs().size(); i++) { } JsfUtil.addSuccessMessage("Liste cre avec succs !"); } mouchard.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(MouchardCtrl.class.getName()).log(Level.SEVERE, null, ex); } } else { JsfUtil.addWarningMessage("Aucune session utilisateur initie !"); } } }
From source file:procuracoes.classes.Digitalizacao.java
public void salva(String user) throws MorenaException, SQLException { source = TwainManager.selectSource(null); npag = 0;/*from w ww . ja v a 2 s. co m*/ if (source != null) { morenaImage = new MorenaImage(source); //cria um objeto MorenaImage que manipula a imagem direta do scanner image = Toolkit.getDefaultToolkit().createImage(morenaImage); //cria um objeto Image para receber a imagem i.add(npag, image); bimg = new BufferedImage(morenaImage.getWidth(), //cria um bufferedImage para poder salvar a imagem morenaImage.getHeight(), BufferedImage.TYPE_INT_RGB); g = bimg.createGraphics();//cria um graphics2d para manipular a imagem do buffer g.drawImage(i.get(npag), 0, 0, null);//desenha o objeto Image no BufferedImage try { ImageIO.write(bimg, "jpg", new File("C:/temp/teste" + Integer.toString(npag) + ".jpg")); //Cria um novo arquivo jpg; s.add("C:/temp/teste" + Integer.toString(npag) + ".jpg"); //Se a pasta no existir, a converso no funciona; } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Erro ao salvar imagem " + ex); } //---------------------------------------// JFrame f = new JFrame(); f.setBounds(50, 200, 1500, 600); f.setTitle("Visualizador"); f.setMaximumSize(new Dimension(1500, 600)); f.setMinimumSize(new Dimension(1500, 600)); cx = 0; cy = 0; resizedImg = new BufferedImage(100, 150, BufferedImage.TYPE_INT_ARGB); g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(i.get(npag), 0, 0, 100, 150, null); g2.dispose(); x = new JLabel(new ImageIcon(resizedImg)); GridBagLayout grid = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); GridBagConstraints d = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; d.gridheight = 8; d.gridwidth = 3; c.ipadx = 10; c.ipady = 10; c.gridx = cx; c.gridy = cy; d.gridheight = 0; d.gridwidth = 3; d.fill = GridBagConstraints.VERTICAL; d.anchor = d.PAGE_END; d.gridy = 5; f.setLayout(grid); f.add(new JLabel("Deseja continuar escaniando?"), d); JButton j1 = new JButton("Sim"); j1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { morenaImage = new MorenaImage(source); //cria um objeto MorenaImage que manipula a imagem direta do scanner image = Toolkit.getDefaultToolkit().createImage(morenaImage); //cria um objeto Image para receber a imagem i.add(npag, image); bimg = new BufferedImage(morenaImage.getWidth(), //cria um bufferedImage para poder salvar a imagem morenaImage.getHeight(), BufferedImage.TYPE_INT_RGB); g = bimg.createGraphics(); //cria um graphics2d para manipular a imagem do buffer g.drawImage(i.get(npag), 0, 0, null); //desenha o objeto Image no BufferedImage try { ImageIO.write(bimg, "jpg", new File("C:/temp/teste" + Integer.toString(npag) + ".jpg")); //Cria um novo arquivo jpg; s.add("C:/temp/teste" + Integer.toString(npag) + ".jpg"); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Erro ao salvar imagem " + ex); } //--------------------------------------------// resizedImg = new BufferedImage(100, 150, BufferedImage.TYPE_INT_ARGB); g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(i.get(npag), 0, 0, 100, 150, null); g2.dispose(); if (npag < 8) { cx = npag; } else if (npag >= 24) { cx = npag - 24; cy = 3; } else if (npag >= 16) { cx = npag - 16; cy = 2; } else if (npag >= 8) { cx = npag - 8; cy = 1; } x = new JLabel(new ImageIcon(resizedImg)); c.gridx = cx; c.gridy = cy; f.add(x, c); f.validate(); //----------------------------------------------// npag++; } }); f.add(j1, d); JButton j2 = new JButton("Nao"); j2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Document document = new Document(); Rectangle r = new Rectangle(morenaImage.getWidth(), morenaImage.getHeight()); document.setPageSize(r); try { String output = getNovoCaminho(); FileOutputStream fos = new FileOutputStream(output); PdfWriter writer = PdfWriter.getInstance(document, fos); writer.open(); document.open(); int j = 0; while (j < npag) { document.add(com.itextpdf.text.Image.getInstance(s.get(j))); j++; } document.close(); writer.close(); } catch (DocumentException | IOException | SQLException ex) { JOptionPane.showMessageDialog(null, "Erro ao criar arquivo pdf " + ex); } try { TwainManager.close(); InsereProc in; in = new InsereProc(user); in.setVisible(true); f.dispose(); } catch (SQLException | TwainException ex) { Logger.getLogger(Digitalizacao.class.getName()).log(Level.SEVERE, null, ex); } } }); f.add(j2, d); f.add(x, c); npag++; f.validate(); f.setVisible(true); f.toFront(); } else { JOptionPane.showMessageDialog(null, "Documneto nao encontrado !"); } }
From source file:rs.marko.helper.Kreiranje.java
public static File createPdfStatistika(List<Stavkadnevneberbe> stavke, Date pocetak, Date kraj) { Document document = new Document(); File yourFile = null;/*from w w w. j av a 2 s .c o m*/ try { yourFile = new File(System.getProperty("user.home") + "/Desktop/" + pocetak + "_" + kraj + ".pdf"); if (!yourFile.exists()) { yourFile.createNewFile(); } FileOutputStream oFile = new FileOutputStream(yourFile, false); document.setPageSize(PageSize.A4.rotate()); PdfWriter.getInstance(document, oFile); document.open(); // String text = ""; // for (int i = 0; i < 10000; i++) { // text += "test"; // , } // String jmbg = stavke.get(0).getDobavljac().getJmbg(); PdfPTable table = new PdfPTable( new float[] { 300f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f }); table.setWidthPercentage(100); table.setSpacingBefore(0f); table.setSpacingAfter(0f); Paragraph p = new Paragraph("Od: " + pocetak + " do: " + kraj); p.add(new Paragraph(" ")); document.add(p); PdfPCell c = new PdfPCell(new Phrase("")); // PdfPCell c1 = new PdfPCell(new Phrase("Sifra")); // c1.setHorizontalAlignment(Element.ALIGN_CENTER); // c1.setRowspan(2); // c1.setColspan(2); // table.addCell(c1); PdfPCell c1 = new PdfPCell(new Phrase("Dobavljac")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_MIDDLE); c1.setRowspan(2); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("Tacne")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("I Klasa")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("II Klasa")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("III Klasa")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("Svega")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(3); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Cena")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); Font font = new Font(BaseFont.createFont(), 10, Font.NORMAL); // table.setHeaderRows(3); List<String> jmbgovi = new ArrayList<>(); Map<Double, Double> kt = new HashMap<>(); Map<Double, Double> k1 = new HashMap<>(); Map<Double, Double> k2 = new HashMap<>(); Map<Double, Double> k3 = new HashMap<>(); Map<Double, Double> ukupnoTacneVrednost = new HashMap<>(); Map<Double, Double> ukupnoPrvaKlasaVrednost = new HashMap<>(); Map<Double, Double> ukupnoDrugaKlasaVrednost = new HashMap<>(); Map<Double, Double> ukupnoTrecaKlasaVrednost = new HashMap<>(); for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) { if (!jmbgovi.contains(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg())) { jmbgovi.add(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg()); } } Double ukupnoKolicinaTacne = 0.0; Double ukupnoKolicinaPrvaKlasa = 0.0; Double ukupnoKolicinaDrugaKlasa = 0.0; Double ukupnoKolicinaTrecaKlasa = 0.0; Double ukupnoCenaTacne = 0.0; Double ukupnoCenaPrvaKlasa = 0.0; Double ukupnoCenaDrugaKlasa = 0.0; Double ukupnoCenaTrecaKlasa = 0.0; Double ukupanIznosSvih = 0.0; for (String j : jmbgovi) { String imeDobavljaca = null; for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) { if (stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg().equals(j)) { if (imeDobavljaca == null) { imeDobavljaca = stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getIme() + " " + stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getPrezime(); } if (!kt.containsKey(stavkaDnevneBerbe.getCenatacne()) && stavkaDnevneBerbe.getTacne() != 0) { kt.put(stavkaDnevneBerbe.getCenatacne(), new Double(0)); } if (!k1.containsKey(stavkaDnevneBerbe.getCenaprvaklasa()) && stavkaDnevneBerbe.getCenaprvaklasa() != 0) { k1.put(stavkaDnevneBerbe.getCenaprvaklasa(), new Double(0)); } if (!k2.containsKey(stavkaDnevneBerbe.getCenadrugaklasa()) && stavkaDnevneBerbe.getCenadrugaklasa() != 0) { k2.put(stavkaDnevneBerbe.getCenadrugaklasa(), new Double(0)); } if (!k3.containsKey(stavkaDnevneBerbe.getCenatrecaklasa()) && stavkaDnevneBerbe.getCenatrecaklasa() != 0) { k3.put(stavkaDnevneBerbe.getCenatrecaklasa(), new Double(0)); } } } for (Stavkadnevneberbe s : stavke) { if (s.getDnevnaberba().getDobavljac().getJmbg().equals(j)) { if (kt.containsKey(s.getCenatacne())) { kt.put(s.getCenatacne(), kt.get(s.getCenatacne()) + s.getTacne()); } if (k1.containsKey(s.getCenaprvaklasa())) { k1.put(s.getCenaprvaklasa(), k1.get(s.getCenaprvaklasa()) + s.getPrvaklasa()); } if (k2.containsKey(s.getCenadrugaklasa())) { k2.put(s.getCenadrugaklasa(), k2.get(s.getCenadrugaklasa()) + s.getDrugaklasa()); } if (k3.containsKey(s.getCenatrecaklasa())) { k3.put(s.getCenatrecaklasa(), k3.get(s.getCenatrecaklasa()) + s.getTrecaklasa()); } } } c1 = new PdfPCell(new Phrase(imeDobavljaca)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); Iterator it = kt.entrySet().iterator(); Double ukupnoKolicinaT = 0.0; Double ukupnoCenaT = 0.0; Double ukupanIznos = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaT += (Double) pair.getValue(); ukupnoCenaT += (Double) pair.getKey(); ukupanIznos += ((Double) pair.getValue() * (Double) pair.getKey()); //ukupno vrednost if (ukupnoTacneVrednost.containsKey((Double) pair.getKey())) { ukupnoTacneVrednost.put((Double) pair.getKey(), ukupnoTacneVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoTacneVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaT, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznos, 2) + "", font)); table.addCell(c1); it = k1.entrySet().iterator(); Double ukupnoKolicinaP = 0.0; Double ukupnoCenaP = 0.0; Double ukupanIznosP = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaP += (Double) pair.getValue(); ukupnoCenaP += (Double) pair.getKey(); ukupanIznosP += ((Double) pair.getValue() * (Double) pair.getKey()); if (ukupnoPrvaKlasaVrednost.containsKey((Double) pair.getKey())) { ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(), ukupnoPrvaKlasaVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaP, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosP, 2) + "", font)); table.addCell(c1); it = k2.entrySet().iterator(); Double ukupnoKolicinaD = 0.0; Double ukupnoCenaD = 0.0; Double ukupanIznosD = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaD += (Double) pair.getValue(); ukupnoCenaD += (Double) pair.getKey(); ukupanIznosD += ((Double) pair.getValue() * (Double) pair.getKey()); if (ukupnoDrugaKlasaVrednost.containsKey((Double) pair.getKey())) { ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(), ukupnoDrugaKlasaVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaD, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosD, 2) + "", font)); table.addCell(c1); it = k3.entrySet().iterator(); Double ukupnoKolicinaTr = 0.0; Double ukupnoCenaTr = 0.0; Double ukupanIznosT = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaTr += (Double) pair.getValue(); ukupnoCenaTr += (Double) pair.getKey(); ukupanIznosT += ((Double) pair.getValue() * (Double) pair.getKey()); if (ukupnoTrecaKlasaVrednost.containsKey((Double) pair.getKey())) { ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(), ukupnoTrecaKlasaVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaTr, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosT, 2) + "", font)); table.addCell(c1); Double ukupnoKolicina = ukupnoKolicinaT + ukupnoKolicinaP + ukupnoKolicinaD + ukupnoKolicinaTr; Double ukupnoVrednost = ukupanIznos + ukupanIznosP + ukupanIznosD + ukupanIznosT; Double ukupnoCena = ukupnoVrednost / ukupnoKolicina; c1 = new PdfPCell(new Phrase(round(ukupnoKolicina, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupnoCena, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupnoVrednost, 2) + "", font)); table.addCell(c1); ukupanIznosSvih += ukupnoVrednost; ukupnoKolicinaTacne += ukupnoKolicinaT; ukupnoKolicinaPrvaKlasa += ukupnoKolicinaP; ukupnoKolicinaDrugaKlasa += ukupnoKolicinaD; ukupnoKolicinaTrecaKlasa += ukupnoKolicinaTr; ukupnoCenaTacne += ukupanIznos; ukupnoCenaPrvaKlasa += ukupanIznosP; ukupnoCenaDrugaKlasa += ukupanIznosD; ukupnoCenaTrecaKlasa += ukupanIznosT; kt.clear(); k1.clear(); k2.clear(); k3.clear(); } c1 = new PdfPCell(new Phrase("UKUPNO")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaTacne + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaTacne + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaPrvaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaPrvaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaDrugaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaDrugaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaTrecaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaTrecaKlasa + "", font)); table.addCell(c1); Double ukupnoKolicinaSve = ukupnoKolicinaTacne + ukupnoKolicinaPrvaKlasa + ukupnoKolicinaDrugaKlasa + ukupnoKolicinaTrecaKlasa; Double prosecnaCena = ukupanIznosSvih / ukupnoKolicinaSve; c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaSve, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(prosecnaCena, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosSvih, 2) + "", font)); table.addCell(c1); //PDV c1 = new PdfPCell(new Phrase("PDV")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); table.addCell(c); Iterator it = ukupnoTacneVrednost.entrySet().iterator(); Double ukupnoTacnePdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); if ((Double) pair.getKey() == 110) { ukupnoTacnePdv += (((Double) pair.getValue() / (Double) pair.getKey()) * 106); } else { ukupnoTacnePdv += (Double) pair.getValue(); } } c1 = new PdfPCell(new Phrase(round(ukupnoTacnePdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); table.addCell(c); it = ukupnoPrvaKlasaVrednost.entrySet().iterator(); Double ukupnoPrvaKlasaPdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoPrvaKlasaPdv += (Double) pair.getValue(); } c1 = new PdfPCell(new Phrase(round(ukupnoPrvaKlasaPdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); table.addCell(c); it = ukupnoDrugaKlasaVrednost.entrySet().iterator(); Double ukupnoDrugaKlasaPdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoDrugaKlasaPdv += (Double) pair.getValue(); } c1 = new PdfPCell(new Phrase(round(ukupnoDrugaKlasaPdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); table.addCell(c); it = ukupnoTrecaKlasaVrednost.entrySet().iterator(); Double ukupnoTrecaKlasaPdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoTrecaKlasaPdv += (Double) pair.getValue(); } c1 = new PdfPCell(new Phrase(round(ukupnoTrecaKlasaPdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); c = new PdfPCell(new Phrase("")); c.setColspan(2); table.addCell(c); Double ukupnoSvePDV = ukupnoTacnePdv + ukupnoPrvaKlasaPdv + ukupnoDrugaKlasaPdv + ukupnoTrecaKlasaPdv; c1 = new PdfPCell(new Phrase(round(ukupnoSvePDV * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); c = new PdfPCell(new Phrase("")); c.setColspan(10); table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); c1 = new PdfPCell(new Phrase("DOBITAK")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell( new Phrase(round((ukupnoSvePDV * (110.0f / 100.0f)) - ukupanIznosSvih, 2) + "", font)); table.addCell(c1); document.add(table); document.add(new Paragraph(" ")); } catch (DocumentException ex) { Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex); } document.close(); return yourFile; }
From source file:se.billes.pdf.renderer.process.Renderer.java
License:Open Source License
public void onRender() throws PdfRenderException { long startTime = new Date().getTime(); System.err.println(startTime + ": Renderer called"); PdfDocument pdfDocument = pdfRequest.getDocument(); File destinationPdf = new File(pdfRequest.getPath(), pdfDocument.getName()); Document document = new Document(); boolean finishedRender = false; PdfWriter writer = null;//ww w . j av a 2s . c om try { writer = PdfWriter.getInstance(document, new FileOutputStream(destinationPdf)); document.addAuthor("iText"); writer.setBoxSize("trim", new SizeFactory().getTrimBoxAsRectangle(pdfDocument)); document.setPageSize(new SizeFactory().getSizeAsRectangle(pdfDocument)); document.open(); for (Page page : pdfDocument.getPages()) { page.onNewPage(writer, document); } System.err.println(new Date().getTime() + ": Renderer finished"); finishedRender = true; } catch (FileNotFoundException e) { generatePdfRenderException(e); } catch (DocumentException e) { generatePdfRenderException(e); } catch (Exception e) { generatePdfRenderException(e); } finally { try { writer.close(); } catch (Exception e) { } try { document.close(); } catch (Exception e) { } ImageFactory.clear(); if (finishedRender) { System.err.println(new Date().getTime() + ": document closed"); long endTime = new Date().getTime(); PdfAction action = new PdfAction(); action.setFile(destinationPdf.getAbsolutePath()); action.setExecutionOfPdfRendering(endTime - startTime); action.setTotalTimeOfExecution(endTime - pdfRequest.getStartExecutionTime()); action.setSuccess(true); action.setParams(pdfRequest.getParams()); PdfResponse response = new PdfResponse(); response.setAction(action); onRendered(response); } } }
From source file:se.inera.intyg.rehabstod.service.export.pdf.PdfExportServiceImpl.java
License:Open Source License
@Override public byte[] export(List<SjukfallEnhet> sjukfallList, PrintSjukfallRequest printSjukfallRequest, RehabstodUser user, int total) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try {/* w w w . ja v a 2 s . c o m*/ unicodeCapableFont = new Font( BaseFont.createFont(UNICODE_CAPABLE_FONT_PATH, BaseFont.IDENTITY_H, BaseFont.EMBEDDED), 9, Font.NORMAL); Document document = new Document(); document.setPageSize(PageSize.A4); document.setMargins(20, 20, 60, 20); PdfWriter writer = PdfWriter.getInstance(document, bos); // Add handlers for page events writer.setPageEvent(new HeaderEventHandler( Image.getInstance( IOUtils.toByteArray(resourcePatternResolver.getResource(LOGO_PATH).getInputStream())), user.getNamn(), user.getValdVardenhet().getNamn())); writer.setPageEvent(new PageNumberingEventHandler()); document.open(); // Add the front page with meta info document.add(createFrontPage(printSjukfallRequest, user, sjukfallList.size(), total)); // Switch to landscape mode document.setPageSize(PageSize.A4.rotate()); document.newPage(); // Add table with all sjukfall (could span several pages) document.add(createSjukfallTable(sjukfallList, user.getUrval(), printSjukfallRequest.isShowPatientId(), isSrsFeatureActive(user))); // Finish off by closing the document (will invoke the event handlers) document.close(); } catch (DocumentException | IOException | RuntimeException e) { throw new PdfExportServiceException("Failed to create PDF export!", e); } return bos.toByteArray(); }
From source file:Servlets.ReportsServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//ww w . j av a2 s. com * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Paragraph pp; Paragraph palaglapgh, signParagraph, dateParagrapgh; Chunk chk; Paragraph underText; Chunk chuk1; Chunk chuk2; Paragraph regionText; String x; ResultSet dir; Paragraph regionTexts; String repLot; repLot = request.getParameter("report"); String repNum = request.getParameter("ITLot"); Paragraph newDate; response.setContentType("application/pdf"); OutputStream out = response.getOutputStream(); //Create document for pdf Document doc = new Document(); //PDF writer to write into document PdfWriter docwriter = null; DecimalFormat df = new DecimalFormat("0.00"); switch (repLot) { default: break; case "IT Report": //Copied code start from here try { // //file path //String path = "docs/" + "Name"; docwriter = PdfWriter.getInstance(doc, out); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } //document header attributes doc.addAuthor("CHED CU"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Grant Monitor"); doc.addTitle(repLot); doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape //doc.setPageSize(PageSize.A4); doc.setMargins(20f, 20f, 10f, 10f); //open document doc.open(); //Creating a paragraphs and chunks pp = new Paragraph("Cocoa Health And Extension Division", forTitle); pp.setAlignment(Element.ALIGN_CENTER); palaglapgh = new Paragraph("(Cocobod)", bfBold12); palaglapgh.setAlignment(Element.ALIGN_CENTER); signParagraph = new Paragraph("Sign: ..............", bfBold12); signParagraph.setAlignment(Element.ALIGN_LEFT); dateParagrapgh = new Paragraph("Date: ...........", bfBold12); chk = new Chunk("From GIS Office, Accra", bfBold12); chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position underText = new Paragraph(chk); underText.setAlignment(Element.ALIGN_CENTER); chuk1 = new Chunk("Lot No:", forTitle2); chuk1.setUnderline(.1f, -2f); chuk2 = new Chunk(repNum.toUpperCase(), forTitle2); regionText = new Paragraph(repLot, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); x = ""; dir = manager.PDFdemos(repNum); try { if (dir.next()) { x = dir.getString(12); } } catch (SQLException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } regionTexts = new Paragraph(x, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); //add the PDF table to the paragraph //palaglapgh.add(table); //Table Generation block regionText.add(reports(repNum, repLot, .25f)); //SECTION TO ADD ELEMENTS TO PDF // add the paragraph to the document doc.add(pp); //doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(palaglapgh); doc.add(underText); doc.add(chuk1); doc.add(chuk2); //Current Date and time insertion newDate = new Paragraph(date, bf12); newDate.setAlignment(Element.ALIGN_RIGHT); doc.add(newDate); doc.add(regionTexts); doc.add(regionText); doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(Chunk.NEWLINE); doc.add(signParagraph); doc.add(dateParagrapgh); //close the document doc.close(); //close the writer docwriter.close(); out.close(); break; case "TR Report": //Copied code start from here try { // //file path //String path = "docs/" + "Name"; docwriter = PdfWriter.getInstance(doc, out); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } //document header attributes doc.addAuthor("CHED CU"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Grant Monitor"); doc.addTitle(repLot); //doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape doc.setPageSize(PageSize.A4); doc.setMargins(30f, 30f, 20f, 20f); //open document doc.open(); //Creating a paragraphs and chunks pp = new Paragraph("Cocoa Health And Extension Division", forTitle); pp.setAlignment(Element.ALIGN_CENTER); palaglapgh = new Paragraph("(Cocobod)", bfBold12); palaglapgh.setAlignment(Element.ALIGN_CENTER); signParagraph = new Paragraph("Sign: ..............", bfBold12); signParagraph.setAlignment(Element.ALIGN_LEFT); dateParagrapgh = new Paragraph("Date: ...........", bfBold12); chk = new Chunk("From GIS Office, Accra", bfBold12); chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position underText = new Paragraph(chk); underText.setAlignment(Element.ALIGN_CENTER); chuk1 = new Chunk("Lot No:", forTitle2); chuk1.setUnderline(.1f, -2f); // 0.1 thickness and -2 position chuk2 = new Chunk(repNum.toUpperCase(), forTitle2); regionText = new Paragraph(repLot, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); x = ""; dir = manager.PDFdemos(repNum); try { if (dir.next()) { x = dir.getString(12); } } catch (SQLException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } regionTexts = new Paragraph(x, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); //add the PDF table to the paragraph //palaglapgh.add(table); //Table Generation block regionText.add(reports(repNum, repLot, .1f)); //SECTION TO ADD ELEMENTS TO PDF // add the paragraph to the document doc.add(pp); //doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(palaglapgh); doc.add(underText); doc.add(chuk1); doc.add(chuk2); //Current Date and time insertion newDate = new Paragraph(date, bf12); newDate.setAlignment(Element.ALIGN_RIGHT); doc.add(newDate); doc.add(regionTexts); doc.add(regionText); doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(Chunk.NEWLINE); doc.add(signParagraph); doc.add(dateParagrapgh); //close the document doc.close(); //close the writer docwriter.close(); out.close(); break; case "RP Report": //Copied code start from here try { // //file path //String path = "docs/" + "Name"; docwriter = PdfWriter.getInstance(doc, out); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } //document header attributes doc.addAuthor("CHED CU"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Grant Monitor"); doc.addTitle(repLot); doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape //doc.setPageSize(PageSize.A4); doc.setMargins(30f, 30f, 20f, 20f); //open document doc.open(); //Creating a paragraphs and chunks pp = new Paragraph("Cocoa Health And Extension Division", forTitle); pp.setAlignment(Element.ALIGN_CENTER); palaglapgh = new Paragraph("(Cocobod)", bfBold12); palaglapgh.setAlignment(Element.ALIGN_CENTER); signParagraph = new Paragraph("Sign: ..............", bfBold12); signParagraph.setAlignment(Element.ALIGN_LEFT); dateParagrapgh = new Paragraph("Date: ...........", bfBold12); chk = new Chunk("From GIS Office, Accra", bfBold12); chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position underText = new Paragraph(chk); underText.setAlignment(Element.ALIGN_CENTER); chuk1 = new Chunk("RP Lot No:", forTitle2); chuk1.setUnderline(.1f, -2f); chuk2 = new Chunk(repNum.toUpperCase(), forTitle2); regionText = new Paragraph(repLot, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); x = ""; dir = manager.PDFreplants(repNum); try { if (dir.next()) { x = dir.getString(22); } } catch (SQLException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } regionTexts = new Paragraph(x, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); //add the PDF table to the paragraph //palaglapgh.add(table); //Table Generation block regionText.add(RPreport(repNum)); //SECTION TO ADD ELEMENTS TO PDF // add the paragraph to the document doc.add(pp); //doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(palaglapgh); doc.add(underText); doc.add(chuk1); doc.add(chuk2); //Current Date and time insertion newDate = new Paragraph(date, bf12); newDate.setAlignment(Element.ALIGN_RIGHT); doc.add(newDate); doc.add(regionTexts); doc.add(regionText); doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(Chunk.NEWLINE); doc.add(signParagraph); doc.add(dateParagrapgh); //close the document doc.close(); //close the writer docwriter.close(); out.close(); break; case "Rehab Report": //Copied code start from here try { // //file path //String path = "docs/" + "Name"; docwriter = PdfWriter.getInstance(doc, out); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } //document header attributes doc.addAuthor("CHED CU"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Grant Monitor"); doc.addTitle(repLot); doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape //doc.setPageSize(PageSize.A4); doc.setMargins(5f, 5f, 3f, 3f); //open document doc.open(); //Creating a paragraphs and chunks pp = new Paragraph("Cocoa Health And Extension Division", forTitle); pp.setAlignment(Element.ALIGN_CENTER); palaglapgh = new Paragraph("(Cocobod)", bfBold12); palaglapgh.setAlignment(Element.ALIGN_CENTER); signParagraph = new Paragraph("Sign: ..............", bfBold12); signParagraph.setAlignment(Element.ALIGN_LEFT); dateParagrapgh = new Paragraph("Date: ...........", bfBold12); chk = new Chunk("Component 1 Rehabilitation Tree Removal Cost From GIS Office, Accra", bfBold12); chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position underText = new Paragraph(chk); underText.setAlignment(Element.ALIGN_CENTER); chuk1 = new Chunk("RP Lot No:", bfBold12); chuk1.setUnderline(.1f, -2f); chuk2 = new Chunk(repNum, bfBold12); regionText = new Paragraph(repLot, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); x = ""; dir = manager.PDFRehab(repNum);//SHOULD BE CHANGED!!!! try { if (dir.next()) { x = dir.getString(21); } } catch (SQLException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } regionTexts = new Paragraph(x, forTitle2); regionText.setAlignment(Element.ALIGN_CENTER); //add the PDF table to the paragraph //palaglapgh.add(table); //Table Generation block regionText.add(reports(repNum)); //SECTION TO ADD ELEMENTS TO PDF // add the paragraph to the document doc.add(pp); //doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(palaglapgh); doc.add(underText); doc.add(chuk1); doc.add(chuk2); //Current Date and time insertion newDate = new Paragraph(date, bf12); newDate.setAlignment(Element.ALIGN_RIGHT); doc.add(newDate); doc.add(regionTexts); doc.add(regionText); doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(Chunk.NEWLINE); doc.add(signParagraph); doc.add(dateParagrapgh); //close the document doc.close(); //close the writer docwriter.close(); out.close(); //Copied CODES break; } } catch (DocumentException ex) { Logger.getLogger(ReportsServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:src.GUI.PDFGEN.java
License:Open Source License
public void PDFAB(String Headline, int AmountExer, GUISETTINGSPDF k) { Document Doc = new Document(); Rectangle Rec = new Rectangle(PageSize.A4); Doc.setPageSize(Rec); try {/*from ww w . j a v a 2 s. com*/ F = File.createTempFile("Blatt", ".pdf"); PdfWriter.getInstance(Doc, new FileOutputStream(F)); Doc.open(); Paragraph Para = new Paragraph(Headline, FONTS.FontHeader()); Para.setAlignment(Element.ALIGN_CENTER); Doc.add(Para); First = new MEMORY(); Current = First; GUISETTINGSPDF D = k; //Image Img = Image.getInstance("Logo"); //Doc.add(Img); for (int i = 1; i <= AmountExer; i++) { List = new List(List.ORDERED, List.ALPHABETICAL); for (int c = 0; c < k.taskNumber; c++) { TERM Term = new TERM(k.aoAddition, k.aoSubtraction, k.aoMultiplication, k.aoDivision, k.bracketDepht, k.Substitutions, k.Digits, k.decimalPlaces, k.justPositive); Current.writeExercise(Term.infix() + "="); Current.writeSolution(Double.parseDouble(Term.getSolution())); List.add(new ListItem(Current.readExercise())); Current.Next = new MEMORY(); Current = Current.Next; } Doc.add(new Paragraph(" \n Aufgabe " + i, FONTS.Font())); k = k.next; Doc.add(List); } Doc.close(); Desktop.getDesktop().open(F); PDFLB(AmountExer, D); Desktop.getDesktop().open(G); } catch (Exception e) { e.printStackTrace(); } }
From source file:src.GUI.PDFGEN.java
License:Open Source License
private void PDFLB(int AmountExer, GUISETTINGSPDF k) { Document Doc = new Document(); Rectangle Rec = new Rectangle(PageSize.A4); Doc.setPageSize(Rec); try {/*from w w w . j av a2 s.c om*/ G = File.createTempFile("Blatt", ".pdf"); PdfWriter.getInstance(Doc, new FileOutputStream(G)); Doc.open(); Paragraph Para = new Paragraph("Lsungsblatt", FONTS.FontHeader()); Para.setAlignment(Element.ALIGN_CENTER); Doc.add(Para); for (int i = 1; i <= AmountExer; i++) { List = new List(List.ORDERED, List.ALPHABETICAL); for (int c = 0; c < k.taskNumber; c++) { String S = First.readExercise() + First.readSolution(); List.add(new ListItem(S)); First = First.Next; } Doc.add(new Paragraph(" \n Aufgabe" + i, FONTS.Font())); Doc.add(List); k = k.next; } Doc.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:tn.esprit.twin1.brogrammers.eventify.Eventify.util.TicketGenerator.java
public static void GenerateTicket(Ticket ticket) { Document document = new Document(); try {//from w w w. j a v a 2s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FILE)); Rectangle pagesize = new Rectangle(700, 300); document.open(); Paragraph emptyline = new Paragraph(); emptyline.add(new Paragraph(" ")); document.setPageSize(pagesize); document.newPage(); //PIC PdfContentByte canvas = writer.getDirectContentUnder(); Image image = Image.getInstance(IMAGE); //image.scaleAbsolute(pagesize.rotate()); image.setAbsolutePosition(0, 0); canvas.addImage(image); //PIC document.addTitle("Your Access To" + ticket.getEvent().getTitle()); document.addSubject(ticket.getEvent().getTheme()); document.addKeywords(ticket.getEvent().getTitle() + "Ticket"); document.addAuthor("Mohamed Firas Ouertani"); document.addCreator("Mohamed Firas Ouertani"); Paragraph prefacetitle = new Paragraph(); prefacetitle.add(new Paragraph("Your Ticket For " + ticket.getEvent().getTitle(), bigFont)); document.add(prefacetitle); document.add(emptyline); Paragraph prefacetime = new Paragraph(); prefacetime.add(new Paragraph(ticket.getEvent().getStartTime().toString(), greyFont)); document.add(prefacetime); document.add(emptyline); document.add(emptyline); Paragraph prefacetype = new Paragraph(); prefacetype.add(new Paragraph("You Reserved For: " + ticket.getTypeTicket(), catFont)); document.add(prefacetype); //QR BarcodeQRCode qrcode = new BarcodeQRCode( "REF:#" + ticket.getEvent().getId() + "" + ticket.getEvent().getTitle().trim(), 1, 1, null); Image qrcodeImage = qrcode.getImage(); qrcodeImage.setAbsolutePosition(520, 70); qrcodeImage.scalePercent(400); document.add(qrcodeImage); //QR //Bar PdfContentByte cb = writer.getDirectContent(); Barcode128 code128 = new Barcode128(); BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.setCode("REF:#" + ticket.getEvent().getId() + "" + ticket.getEvent().getTitle().trim()); codeEAN.setCodeType(BarcodeEAN.EAN13); Image codeEANImage = code128.createImageWithBarcode(cb, null, null); codeEANImage.setAbsolutePosition(10, 10); codeEANImage.scalePercent(125); document.add(codeEANImage); //Bar document.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Utility.PDFDemo.java
public void cretePDF(String name, String rpor) throws FileNotFoundException { try {//from w ww. ja va 2 s . c o m //Create document for pdf Document doc = new Document(); //PDF writer to write into document PdfWriter docwriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { // //file path //String path = "docs/" + name; docwriter = PdfWriter.getInstance(doc, new FileOutputStream(rpor + ".pdf")); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } //document header attributes doc.addAuthor("CHED CU"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Grant Monitor"); doc.addTitle(rpor); doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape //doc.setPageSize(PageSize.A4); doc.setMargins(30f, 30f, 20f, 20f); //open document doc.open(); //Creating a paragraphs and chunks Paragraph pp = new Paragraph("Cocoa Health And Extension", forTitle); pp.setAlignment(Element.ALIGN_CENTER); Paragraph palaglapgh = new Paragraph("(Cocobod)", bfBold12); palaglapgh.setAlignment(Element.ALIGN_CENTER); Chunk chk = new Chunk("From GIS Office, Accra", bfBold12); chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position Paragraph underText = new Paragraph(chk); underText.setAlignment(Element.ALIGN_CENTER); Chunk chuk1 = new Chunk("Lot No:", bfBold12); chuk1.setUnderline(.1f, -2f); Chunk chuk2 = new Chunk(name, bfBold12); Paragraph regionText = new Paragraph(rpor, bfBold12); regionText.setAlignment(Element.ALIGN_CENTER); String rporx = ""; // ResultSet dir = manager.PDFdemos(name); // try { // if (dir.next()) { // rporx = dir.getString(12); // // } // } catch (SQLException ex) { // Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); // } Paragraph regionTexts = new Paragraph(rporx, bfBold12); regionText.setAlignment(Element.ALIGN_CENTER); //add the PDF table to the paragraph //palaglapgh.add(table); //Table Generation block regionText.add(reports()); //SECTION TO ADD ELEMENTS TO PDF // add the paragraph to the document doc.add(pp); //doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(palaglapgh); doc.add(underText); doc.add(chuk1); doc.add(chuk2); //Current Date and time insertion Paragraph newDate = new Paragraph(new Date().toString(), bf12); newDate.setAlignment(Element.ALIGN_RIGHT); doc.add(newDate); doc.add(regionTexts); doc.add(regionText); //close the document doc.close(); //close the writer docwriter.close(); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } }