List of usage examples for com.itextpdf.text Document Document
public Document()
Document
-object. From source file:PrintAll.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* ww w. ja va 2 s . co m*/ * * @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 { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); //donaations Vector<String> donations = dao.get_donation(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.addTitle("USER INFORMATION SUMMARY"); document.add(new Paragraph("LightHouse Chapel International")); document.add(new Paragraph(" ")); document.add(new Paragraph("INFORMATION SUMMARY")); document.add(new Paragraph(" ")); document.add(new Paragraph("=========== TITHES ===============")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Amount " + " " + "Date ")); document.add(new Paragraph("")); double total = 0.00; for (int x = 0; x < list.size(); ++x) { total += list.get(x).getAmount(); document.add(new Paragraph(x + " " + list.get(x).getAmount() + " " + list.get(x).getDate())); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("============ USERS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " SURNAME " + " ACCOUNT NUMBER ")); for (User user : users) { document.add(new Paragraph(" " + user.getName() + " " + " " + user.getSurname() + " " + " " + user.getAccountNumber())); } document.add(new Paragraph(" ")); document.add(new Paragraph("============ PROJECTS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " NUMBER " + " COST ")); for (int x = 0; x < projects.size(); ++x) { String[] data = projects.get(x).split("@"); document.add(new Paragraph(" " + data[1] + " " + " " + data[0] + " " + " " + data[4])); } document.close(); } catch (Exception ex) { Logger.getLogger(PrintAll.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:PrintTitheReport.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from www.ja v a 2 s. c o m * * @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 { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.add(new Paragraph("=========== TITHES ===============")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Amount " + " " + "Date ")); document.add(new Paragraph("")); document.add(new Paragraph("")); double total = 0.00; for (int x = 0; x < list.size(); ++x) { total += list.get(x).getAmount(); document.add(new Paragraph( (1 + x) + " " + list.get(x).getAmount() + " " + list.get(x).getDate())); } document.add(new Paragraph("")); document.add(new Paragraph("")); document.add(new Paragraph("")); document.add(new Paragraph("")); document.add(new Paragraph("")); document.add(new Paragraph("")); document.add(new Paragraph("Total Number of people who paid tithe : " + list.size())); document.close(); } catch (Exception ex) { response.sendRedirect("systemError.jsp"); } }
From source file:user_details.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed int option = JOptionPane.showConfirmDialog(null, "Are you sure?"); if (option == 0) { Document document = new Document(); PdfWriter writer;/* w ww.ja va 2 s . c o m*/ try { try { writer = PdfWriter.getInstance(document, new FileOutputStream("Your_Resume.pdf")); } catch (FileNotFoundException ex) { Logger.getLogger(user_details.class.getName()).log(Level.SEVERE, null, ex); } Font fontdesign1 = FontFactory.getFont("Times-Roman", 20, Font.BOLD); Font fontdesign2 = FontFactory.getFont("Times-Roman", 10, Font.ITALIC); Font fontdesign4 = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font fontdesign3 = FontFactory.getFont("Times-Roman", 11); document.open(); Paragraph namepara = new Paragraph(fname + " " + lname, fontdesign1); namepara.setAlignment(Element.ALIGN_CENTER); document.add(namepara); document.add(Chunk.NEWLINE); if (edu_details.equals("") || edu_details.equals("-")) { } else { Paragraph eduTitle = new Paragraph("EDUCATIONAL QUALIFICATION:", fontdesign4); document.add(eduTitle); Paragraph edupara = new Paragraph(edu_details, fontdesign3); document.add(edupara); } document.add(Chunk.NEWLINE); if (present_comp.equals("") || present_comp.equals("-")) { } else { Paragraph Present_compTitle = new Paragraph("CURRENT COMPANY AND POSITION:", fontdesign4); document.add(Present_compTitle); Paragraph Present_compPara = new Paragraph(present_comp, fontdesign3); document.add(Present_compPara); } document.add(Chunk.NEWLINE); if (past_emp.equals("") || past_emp.equals("-")) { } else { Paragraph Past_compTitle = new Paragraph("PAST EMPLOYMENT DETAILS:", fontdesign4); document.add(Past_compTitle); Paragraph Past_compPara = new Paragraph(past_emp, fontdesign3); document.add(Past_compPara); } document.add(Chunk.NEWLINE); if (key_responsibility.equals("") || key_responsibility.equals("-")) { } else { Paragraph KeyTitle = new Paragraph("KEY RESPONSIBILITIES: ", fontdesign4); document.add(KeyTitle); Paragraph Keypara = new Paragraph(key_responsibility, fontdesign3); document.add(Keypara); } document.add(Chunk.NEWLINE); if (accomplishments.equals("") || accomplishments.equals("-")) { } else { Paragraph AccTitle = new Paragraph("ACCOMPLISHMENTS AND ACHIEVEMENTS:", fontdesign4); document.add(AccTitle); Paragraph Accpara = new Paragraph(accomplishments, fontdesign3); document.add(Accpara); } document.add(Chunk.NEWLINE); if (training.equals("") || training.equals("-")) { } else { Paragraph TrainingTitle = new Paragraph("On-Job TRAININGS/SEMINARS/WORKSHOPS:", fontdesign4); document.add(TrainingTitle); Paragraph Trainingpara = new Paragraph(training, fontdesign3); document.add(Trainingpara); } document.add(Chunk.NEWLINE); Paragraph RefTitle = new Paragraph("REFERENCES:", fontdesign4); document.add(RefTitle); for (int i = 0; i < refno; i++) { Paragraph refpara = new Paragraph(i + 1 + "." + ref[i], fontdesign3); document.add(refpara); } document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); Paragraph contactpara = new Paragraph("PHONE: " + contactNo, fontdesign2); document.add(contactpara); if (fthername.equals("") || fthername.equals("-")) { } else { Paragraph fthrnamepara = new Paragraph("FATHER'S NAME: " + fthername, fontdesign2); document.add(fthrnamepara); } Paragraph dobpara = new Paragraph("DOB: " + dob, fontdesign2); document.add(dobpara); Paragraph addresspara = new Paragraph("PERMANENT ADDRESS: " + pa, fontdesign2); document.add(addresspara); document.close(); } catch (DocumentException ex) { Logger.getLogger(user_details.class.getName()).log(Level.SEVERE, null, ex); } references.dispose(); new user_details().setVisible(true); JOptionPane.showMessageDialog(null, "Congratulations! Your resume has been created. Kindly check the directory."); } else { JOptionPane.showMessageDialog(null, "Okay! You can edit your Information."); } }
From source file:ReservationArchiveFrame.java
private void tabletoPDFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tabletoPDFActionPerformed // TODO add your handling code here: String title = ""; if (jTabbedPane2.getSelectedIndex() == 0) { model = (DefaultTableModel) reservationpersonalinfotable.getModel(); title = "PersonalInformation"; } else if (jTabbedPane2.getSelectedIndex() == 1) { model = (DefaultTableModel) reservationcontactinfotable.getModel(); title = "ContactInformation"; } else if (jTabbedPane2.getSelectedIndex() == 2) { model = (DefaultTableModel) reservationaddressinfotable.getModel(); title = "Address"; } else {/*from ww w . j av a2s .co m*/ model = (DefaultTableModel) reservationstatusinfotable.getModel(); title = "ReservationStatus"; } Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(path + "\\PDF\\" + title + "ReservationArchive.pdf")); document.open(); PdfPTable tab = new PdfPTable(model.getColumnCount()); for (int i = 0; i < model.getColumnCount(); i++) { tab.addCell(model.getColumnName(i)); } for (int i = 0; i < model.getRowCount(); i++) { for (int j = 0; j < model.getColumnCount(); j++) { if (model.getValueAt(i, j) != null) { tab.addCell(model.getValueAt(i, j).toString()); } else { tab.addCell("-"); } } } document.add(tab); JOptionPane.showMessageDialog(null, "Data saved at " + path + "'\\PDF\\" + title + "ReservationArchive.pdf' successfully", "Message", JOptionPane.INFORMATION_MESSAGE); document.close(); } catch (FileNotFoundException | DocumentException ex) { // Logger.getLogger(ReservationArchiveFrame.class.getName()).log(Level.SEVERE, null, ex); new MessageDialog().error(this, ex.getMessage()); } }
From source file:TransientArchiveFrame.java
private void tabletoPDFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tabletoPDFActionPerformed // TODO add your handling code here: String title = "Transient"; if (jTabbedPane2.getSelectedIndex() == 0) { model = (DefaultTableModel) transientpersonalinfo.getModel(); title += "Personal Information"; } else if (jTabbedPane2.getSelectedIndex() == 1) { model = (DefaultTableModel) checkintable.getModel(); title += " Check-in Details"; } else {/*w w w.j a va 2 s . c o m*/ model = (DefaultTableModel) guesttable.getModel(); title += " guests"; } Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(path + "\\PDF\\" + title + " TransientArchive.pdf")); document.open(); PdfPTable tab = new PdfPTable(model.getColumnCount()); for (int i = 0; i < model.getColumnCount(); i++) { tab.addCell(model.getColumnName(i)); } for (int i = 0; i < model.getRowCount(); i++) { for (int j = 0; j < model.getColumnCount(); j++) { if (model.getValueAt(i, j) != null) { tab.addCell(model.getValueAt(i, j).toString()); } else { tab.addCell("-"); } } } document.add(tab); JOptionPane.showMessageDialog(null, "Data saved at " + path + "'\\PDF\\" + title + "TransienttArchive.pdf' successfully", "Message", JOptionPane.INFORMATION_MESSAGE); document.close(); } catch (FileNotFoundException | DocumentException ex) { // Logger.getLogger(TransientArchiveFrame.class.getName()).log(Level.SEVERE, null, ex); new MessageDialog().error(this, ex.getMessage()); } }
From source file:PrintingServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//w w w . j a va2s.c o m * * @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, DocumentException { try { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); //donaations Vector<String> donations = dao.get_donation(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.addTitle("USER INFORMATION SUMMARY"); document.add(new Paragraph("LightHouse Chapel International")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("INFORMATION SUMMARY")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("=========== TITHES ===============")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Amount " + " " + "Date ")); document.add(new Paragraph("")); document.add(new Paragraph("")); double total = 0.00; for (int x = 0; x < list.size(); ++x) { total += list.get(x).getAmount(); document.add(new Paragraph(x + " " + list.get(x).getAmount() + " " + list.get(x).getDate())); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("============ USERS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " SURNAME " + " ACCOUNT NUMBER ")); for (User user : users) { document.add(new Paragraph(" " + user.getName() + " " + " " + user.getSurname() + " " + " " + user.getAccountNumber())); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("============ PROJECTS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " NUMBER " + " COST ")); for (int x = 0; x < projects.size(); ++x) { String[] data = projects.get(x).split("@"); document.add(new Paragraph(" " + data[1] + " " + " " + data[0] + " " + " " + data[4])); } } catch (SQLException ex) { response.sendRedirect("systemError.jsp"); } catch (ClassNotFoundException ex) { response.sendRedirect("systemError.jsp"); } }
From source file:Registration_Tenant.java
private void saveToPdf() { try {// w w w .jav a2s . c o m String gend = ""; Document doc = new Document(); BufferedReader br = new BufferedReader(new FileReader("dir\\defaults.txt")); String path = ""; try { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); } path = sb.toString().trim(); } finally { br.close(); } FileOutputStream fos = new FileOutputStream( path + "\\registration\\" + lastNameTextField.getText().trim() + ", " + firstNameTextField.getText().trim() + "RegistrationResidentForm.pdf"); PdfWriter pdfWriter = PdfWriter.getInstance(doc, fos); PdfReader pdfReader = new PdfReader("RegistrationResidentForm.pdf"); PdfStamper pdfStamper = new PdfStamper(pdfReader, fos); for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) { PdfContentByte content = pdfStamper.getOverContent(i); byte[] cc = null; if (file != null) { File thisFile = new File(file); cc = Files.readAllBytes(thisFile.toPath()); } if (cc != null) { Image image1 = Image.getInstance(cc); image1.scaleAbsolute(95, 105); image1.setAbsolutePosition(465f, 635f); content.addImage(image1); } //Text over the existing page BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.EMBEDDED); content.beginText(); content.setFontAndSize(bf, 10); //last name content.showTextAligned(PdfContentByte.ALIGN_LEFT, lastNameTextField.getText().trim(), 175, 610, 0); //first name content.showTextAligned(PdfContentByte.ALIGN_LEFT, firstNameTextField.getText().trim(), 325, 610, 0); //middle name content.showTextAligned(PdfContentByte.ALIGN_LEFT, middleNameTextField.getText().trim(), 470, 610, 0); //college content.showTextAligned(PdfContentByte.ALIGN_LEFT, collegeTextField.getText().trim(), 180, 582, 0); //Course and year content.showTextAligned(PdfContentByte.ALIGN_LEFT, courseTextField.getText().trim() + " - " + yearTextField.getText().trim(), 180, 568, 0); //department content.showTextAligned(PdfContentByte.ALIGN_LEFT, departmentTextField.getText().trim(), 400, 582, 0); String g; if (male.isSelected()) { g = "Male";//6 } else { g = "Female";//6 } //Sex content.showTextAligned(PdfContentByte.ALIGN_LEFT, g, 400, 568, 0); //Home address content.showTextAligned(PdfContentByte.ALIGN_LEFT, homeAddressTextArea.getText(), 110, 540, 0); //resident mobile no1 content.showTextAligned(PdfContentByte.ALIGN_LEFT, MobileNumber1.getText().trim(), 187, 485, 0); //resident mobile no2 content.showTextAligned(PdfContentByte.ALIGN_LEFT, MobileNumber2.getText().trim(), 187, 470, 0); //student email content.showTextAligned(PdfContentByte.ALIGN_LEFT, email.getText().trim(), 397, 485, 0); //fathers name content.showTextAligned(PdfContentByte.ALIGN_LEFT, fatherNameTextField.getText().trim(), 110, 443, 0); //fathers area code content.showTextAligned(PdfContentByte.ALIGN_LEFT, fACodeTextField.getText().trim(), 300, 443, 0); //father landline content.showTextAligned(PdfContentByte.ALIGN_LEFT, fphoneNumberTextField.getText().trim(), 355, 443, 0); //father mobile content.showTextAligned(PdfContentByte.ALIGN_LEFT, fMobileNumberTextField.getText().trim(), 490, 443, 0); //father email content.showTextAligned(PdfContentByte.ALIGN_LEFT, fEmailTextField.getText().trim(), 110, 430, 0); //mother name content.showTextAligned(PdfContentByte.ALIGN_LEFT, motherNameTextField.getText().trim(), 110, 402, 0); //mother area code content.showTextAligned(PdfContentByte.ALIGN_LEFT, mACodeTextField.getText().trim(), 300, 402, 0); //mother landline content.showTextAligned(PdfContentByte.ALIGN_LEFT, mphoneNumberTextField.getText().trim(), 355, 402, 0); //mother mobile content.showTextAligned(PdfContentByte.ALIGN_LEFT, mMobileNumberTextField.getText().trim(), 490, 402, 0); //mother email content.showTextAligned(PdfContentByte.ALIGN_LEFT, mEmailTextField.getText().trim(), 110, 387, 0); //guardian name content.showTextAligned(PdfContentByte.ALIGN_LEFT, guardianNameTextField.getText().trim(), 170, 335, 0); //guardian contact number content.showTextAligned(PdfContentByte.ALIGN_LEFT, gContactNumber1.getText().trim(), 470, 335, 0); //guardian address content.showTextAligned(PdfContentByte.ALIGN_LEFT, guardianAddress.getText().trim(), 125, 322, 0); //guardian relation content.showTextAligned(PdfContentByte.ALIGN_LEFT, relationToGuardian.getText().trim(), 170, 307, 0); content.setFontAndSize(bf, 12); //room details content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Room No.: " + roomNumberTextField.getSelectedItem().toString().trim() + " - " + roomTypeTextField.getText().trim(), 355, 235, 0); content.endText(); } pdfStamper.close(); pdfReader.close(); fos.close(); pdfWriter.close(); } catch (DocumentException ex) { // Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex); new MessageDialog().error(this, ex.getMessage()); } catch (FileNotFoundException ex) { // Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex); new MessageDialog().error(this, ex.getMessage()); } catch (IOException ex) { // Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex); new MessageDialog().error(this, ex.getMessage()); } }
From source file:pdf_demo2.java
public static void main(String[] args) { try {//from w ww .j ava 2s .co m Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open(); addMetaData(document); addTitlePage(document); addContent(document); document.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:JT.java
public void createPdf(String filename) throws DocumentException, IOException { // step 1/*from w w w . j av a 2 s . com*/ Document document = new Document(); // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3 BaseFont bf = BaseFont.createFont("C:\\Windows\\Fonts\\vuTimes.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font font = new Font(bf, 15); document.open(); // step 4 String pa = "H? v tn : L Ng?c Long\n" + "MSSV : 20142659\n" + "?? ti : Xy dng chng trnh qun l th vin"; pa += "\n\nTr?ng ?i H?c Bch Khoa H Ni Cng Ha - X Hi - Ch Ngha - Vit Nam\n" + " Th vin T Quang Bu ?c Lp - T Do - Hnh Phc"; pa += "\n\n TM KIM S?CH THEO xxx"; document.add(new Paragraph(pa, font)); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(jTable1.getWidth(), jTable1.getHeight()); Graphics2D g2; g2 = tp.createGraphicsShapes(jTable1.getWidth(), jTable1.getHeight()); jTable1.print(g2); float x = 50, y = 300; g2.dispose(); cb.addTemplate(tp, x, y); // step 5 document.close(); }
From source file:ImprimirTransServlet.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request// w ww . j a va 2 s . c om * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String valorDDLCuenta = request.getParameter("btnImprimir"); System.out.println(valorDDLCuenta); int pos = valorDDLCuenta.indexOf(" "); String idTrans = valorDDLCuenta.substring(pos + 1); System.out.println(idTrans); String infoTrans = getInfoTransaccion(Integer.parseInt(idTrans)); String monto = admon.getCadenaEtiquetas(infoTrans, "<monto>"); String idSalida = admon.getCadenaEtiquetas(infoTrans, "<idSalida>"); String idDestino = admon.getCadenaEtiquetas(infoTrans, "<idDestino>"); String seguro = admon.getCadenaEtiquetas(infoTrans, "<idSeguro>"); String prestamo = admon.getCadenaEtiquetas(infoTrans, "<idPrestamo>"); String tipo = admon.getCadenaEtiquetas(infoTrans, "<tipo>"); String fecha = admon.getCadenaEtiquetas(infoTrans, "<fecha>"); Document document = new Document(); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C://pdf//ReciboTransaccion" + idTrans + ".pdf")); document.open(); document.add(new Paragraph("Transaccion: " + idTrans)); document.add(new Paragraph("Cuenta Origen: " + idSalida)); if (!idDestino.equals("-1")) { document.add(new Paragraph("Cuenta Destino: " + idDestino)); } document.add(new Paragraph("Monto: " + monto)); if (!seguro.equals("-1")) { document.add(new Paragraph("Seguro: " + seguro)); } if (!prestamo.equals("-1")) { document.add(new Paragraph("Prestamo: " + prestamo)); } document.add(new Paragraph("Tipo: " + tipo)); document.add(new Paragraph("Fecha: " + fecha)); document.close(); writer.close(); } catch (DocumentException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } request.getRequestDispatcher("/menuTransaccion.jsp").forward(request, response); }