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:gestioninscription.FenSessions.java
private void btnFeuilleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnFeuilleMouseClicked String req;// ww w . ja v a 2s . com req = "select numero, libelleform, niveauform, datedebut, nb_places, nb_inscrits, c.matricule, nom, typestatut, rue, cp, ville "; req += "from session_form s, inscription i, client c where s.numero = i.num_session and i.matricule = c.matricule and s.numero =" + tableSession.getValueAt(tableSession.getSelectedRow(), 0); stmt1 = GestionBdd.connexionBdd(GestionBdd.TYPE_MYSQL, "formarmor", "localhost", "root", ""); ResultSet rs2 = GestionBdd.envoiRequeteLMD(stmt1, req); Document document = new Document(PageSize.A4); System.out.println(req); try { // etape 2: // creation du writer -> PDF ou HTML PdfWriter.getInstance(document, new FileOutputStream(out)); // etape 3: Ouverture du document document.open(); // etape 4: Ajout du contenu au document document.add(new Phrase("texte dans le pdf")); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // etape 5: Fermeture du document document.close(); System.out.println("Document '" + out + "' generated"); }
From source file:gui.TransHistory.java
public void Convertpdf() throws Exception { display();//from w w w.j av a2 s.c o m Document document = new Document(PageSize.A4.rotate()); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Table.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); Graphics2D g2 = cb.createGraphics(500, 500); Shape oldClip = g2.getClip(); g2.clipRect(20, 20, 500, 500); jTable1.print(g2); jTable1.getTableHeader().paint(g2); g2.setClip(oldClip); g2.dispose(); cb.restoreState(); cb.saveState(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); //send mail query = "select email from profile_id where user_id = ?"; psmt = con.prepareStatement(query); psmt.setString(1, t.user); rs = psmt.executeQuery(); rs.next(); SendMailWithAttachment smail = new SendMailWithAttachment(); String message = "hereby is the requested transction report of account " + "no. = " + t.accNo + " from date " + fDate + " to " + toDate; smail.send(rs.getString(1), "Table.pdf", message); }
From source file:include.nseer_cookie.MakePdf.java
License:Open Source License
public void make(String database, String tablename, String sql1, String sql2, String filename, int everypage, HttpSession session) {//w w w .j a va2 s.com try { nseer_db aaa = new nseer_db(database); nseer_db demo_db = new nseer_db(database); ServletContext context = session.getServletContext(); String path = context.getRealPath("/"); Masking reader = new Masking(configFile); Vector columnNames = new Vector(); Vector tables = reader.getTableNicks(); Iterator loop = tables.iterator(); while (loop.hasNext()) { String tablenick = (String) loop.next(); columnNames = reader.getColumnNames(tablenick); } int cpage = 1; //? int spage = 1; int ipage = everypage; String pagesql = sql1; //? ResultSet pagers = demo_db.executeQuery(pagesql); pagers.next(); int allCol = pagers.getInt("A"); allpage = (int) Math.ceil((allCol + ipage - 1) / ipage); // for (int m = 1; m <= allpage; m++) { spage = (m - 1) * ipage; String sql = sql2 + " limit " + spage + "," + ipage; ResultSet bbb = aaa.executeQuery(sql); //ResultSetMetaData tt=bbb.getMetaData(); // int b = columnNames.size(); // int a = 0; while (bbb.next()) { a++; } // bbb.first(); // ?? Rectangle rectPageSize = new Rectangle(PageSize.A4);// rectPageSize = rectPageSize.rotate(); Document document = new Document(rectPageSize, 20, 20, 20, 20); //? Document PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path + filename + m + ".pdf")); //?PDF?? document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); //? com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 8, com.lowagie.text.Font.NORMAL); // Paragraph title1 = new Paragraph("nseer ERP", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC)); Chapter chapter1 = new Chapter(title1, 1); // ? chapter1.setNumberDepth(0); Paragraph title11 = new Paragraph(tablename, FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD)); Section section1 = chapter1.addSection(title11); //? Table t = new Table(b, a); // ? t.setPadding(1); // t.setSpacing(0); // ? t.setBorderWidth(1); // do { // // for (int k = 0; k < b; k++) { // Cell cell = new Cell( new Paragraph(bbb.getString((String) columnNames.elementAt(k)), FontChinese)); //? // t.addCell(cell); // ? // } // } while (bbb.next()); // section1.add(t); // document.add(chapter1); // document.close(); } // ? } catch (Exception pp) { pp.printStackTrace(); } }
From source file:include.nseer_cookie.printPDF.java
License:Open Source License
public Document print_type_across(String print_type, int print_left, int print_right, int print_top, int print_bottom) { try {/*from w w w .j av a2 s . c o m*/ if (print_type.equals("A0")) document = new Document(PageSize.A0.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A1")) document = new Document(PageSize.A1.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A2")) document = new Document(PageSize.A2.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A3")) document = new Document(PageSize.A3.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A4")) document = new Document(PageSize.A4.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A5")) document = new Document(PageSize.A5.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A6")) document = new Document(PageSize.A6.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A7")) document = new Document(PageSize.A7.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A8")) document = new Document(PageSize.A8.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("A9")) document = new Document(PageSize.A9.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("B0")) document = new Document(PageSize.B0.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("B1")) document = new Document(PageSize.B1.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("B2")) document = new Document(PageSize.B2.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("B3")) document = new Document(PageSize.B3.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("B4")) document = new Document(PageSize.B4.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("B5")) document = new Document(PageSize.B5.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_A")) document = new Document(PageSize.ARCH_A.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_B")) document = new Document(PageSize.ARCH_B.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_C")) document = new Document(PageSize.ARCH_C.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_D")) document = new Document(PageSize.ARCH_D.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_E")) document = new Document(PageSize.ARCH_E.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("FLSA")) document = new Document(PageSize.FLSA.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("FLSE")) document = new Document(PageSize.FLSE.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("NOTE")) document = new Document(PageSize.NOTE.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("_11X17")) document = new Document(PageSize._11X17.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("LETTER")) document = new Document(PageSize.LETTER.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("HALFLETTER")) document = new Document(PageSize.HALFLETTER.rotate(), print_left, print_right, print_top, print_bottom); if (print_type.equals("LEDGER")) document = new Document(PageSize.LEDGER.rotate(), print_left, print_right, print_top, print_bottom); } catch (Exception e) { e.printStackTrace(); } return document; }
From source file:include.nseer_cookie.printPDF.java
License:Open Source License
public Document print_type_vertical(String print_type, int print_left, int print_right, int print_top, int print_bottom) { try {// w w w.ja v a 2 s.c o m if (print_type.equals("A0")) document = new Document(PageSize.A0, print_left, print_right, print_top, print_bottom); if (print_type.equals("A1")) document = new Document(PageSize.A1, print_left, print_right, print_top, print_bottom); if (print_type.equals("A2")) document = new Document(PageSize.A2, print_left, print_right, print_top, print_bottom); if (print_type.equals("A3")) document = new Document(PageSize.A3, print_left, print_right, print_top, print_bottom); if (print_type.equals("A4")) document = new Document(PageSize.A4, print_left, print_right, print_top, print_bottom); if (print_type.equals("A5")) document = new Document(PageSize.A5, print_left, print_right, print_top, print_bottom); if (print_type.equals("A6")) document = new Document(PageSize.A6, print_left, print_right, print_top, print_bottom); if (print_type.equals("A7")) document = new Document(PageSize.A7, print_left, print_right, print_top, print_bottom); if (print_type.equals("A8")) document = new Document(PageSize.A8, print_left, print_right, print_top, print_bottom); if (print_type.equals("A9")) document = new Document(PageSize.A9, print_left, print_right, print_top, print_bottom); if (print_type.equals("B0")) document = new Document(PageSize.B0, print_left, print_right, print_top, print_bottom); if (print_type.equals("B1")) document = new Document(PageSize.B1, print_left, print_right, print_top, print_bottom); if (print_type.equals("B2")) document = new Document(PageSize.B2, print_left, print_right, print_top, print_bottom); if (print_type.equals("B3")) document = new Document(PageSize.B3, print_left, print_right, print_top, print_bottom); if (print_type.equals("B4")) document = new Document(PageSize.B4, print_left, print_right, print_top, print_bottom); if (print_type.equals("B5")) document = new Document(PageSize.B5, print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_A")) document = new Document(PageSize.ARCH_A, print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_B")) document = new Document(PageSize.ARCH_B, print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_C")) document = new Document(PageSize.ARCH_C, print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_D")) document = new Document(PageSize.ARCH_D, print_left, print_right, print_top, print_bottom); if (print_type.equals("ARCH_E")) document = new Document(PageSize.ARCH_E, print_left, print_right, print_top, print_bottom); if (print_type.equals("FLSA")) document = new Document(PageSize.FLSA, print_left, print_right, print_top, print_bottom); if (print_type.equals("FLSE")) document = new Document(PageSize.FLSE, print_left, print_right, print_top, print_bottom); if (print_type.equals("NOTE")) document = new Document(PageSize.NOTE, print_left, print_right, print_top, print_bottom); if (print_type.equals("_11X17")) document = new Document(PageSize._11X17, print_left, print_right, print_top, print_bottom); if (print_type.equals("LETTER")) document = new Document(PageSize.LETTER, print_left, print_right, print_top, print_bottom); if (print_type.equals("HALFLETTER")) document = new Document(PageSize.HALFLETTER, print_left, print_right, print_top, print_bottom); if (print_type.equals("LEDGER")) document = new Document(PageSize.LEDGER, print_left, print_right, print_top, print_bottom); } catch (Exception e) { e.printStackTrace(); } return document; }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Mthode principale qui gre l'export d'un tableau vers un fichier ODS. * * @param export paramtres du document exporter * @param out flux de sortie/*from w ww .j ava2s. co m*/ * @throws DocumentException Exception */ public final void exportData(final Export export, final OutputStream out) throws DocumentException { // step 1: creation of a document-object final boolean landscape = export.getOrientation() == Export.Orientation.Landscape; final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4; final Document document = new Document(pageSize, 20, 20, 50, 50); // left, // right, // top, // bottom // step 2: we create a writer that listens to the document and directs a // PDF-stream to out createWriter(document, out); // we add some meta information to the document, and we open it final String title = export.getTitle(); if (title != null) { final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } final String author = export.getAuthor(); document.addAuthor(author); document.addCreator(CREATOR); document.open(); try { // pour ajouter l'ouverture automatique de la bote de dialogue // imprimer // (print(false) pour imprimer directement) // ((PdfWriter) writer).addJavaScript("this.print(true);", false); for (final ExportSheet exportSheet : export.getSheets()) { final Table datatable; if (exportSheet.hasDtObject()) { // table datatable = new Table(2); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // data rows renderObject(exportSheet, datatable); } else { // table datatable = new Table(exportSheet.getExportFields().size()); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // headers renderHeaders(exportSheet, datatable); // data rows renderList(exportSheet, datatable); } document.add(datatable); } } finally { // we close the document document.close(); } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Mthode principale qui gre l'export d'un tableau vers un fichier ODS. * * @param export paramtres du document exporter * @param out flux de sortie/*from ww w . j av a2s . c o m*/ * @throws DocumentException Exception */ public final void exportData(final Export export, final OutputStream out) throws DocumentException { // step 1: creation of a document-object final boolean landscape = export.getOrientation() == Export.Orientation.Landscape; final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4; final Document document = new Document(pageSize, 20, 20, 50, 50); // left, right, top, bottom // step 2: we create a writer that listens to the document and directs a PDF-stream to out createWriter(document, out); // we add some meta information to the document, and we open it final String title = export.getTitle(); if (title != null) { final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } final String author = export.getAuthor(); document.addAuthor(author); document.addCreator(CREATOR); document.open(); try { // pour ajouter l'ouverture automatique de la bote de dialogue imprimer (print(false) pour imprimer directement) // ((PdfWriter) writer).addJavaScript("this.print(true);", false); for (final ExportSheet exportSheet : export.getSheets()) { final Table datatable; if (exportSheet.hasDtObject()) { // table datatable = new Table(2); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // data rows renderObject(exportSheet, datatable); } else { // table datatable = new Table(exportSheet.getExportFields().size()); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // headers renderHeaders(exportSheet, datatable); // data rows renderList(exportSheet, datatable); } document.add(datatable); } } finally { // we close the document document.close(); } }
From source file:is.idega.idegaweb.egov.cases.business.CaseWriter.java
License:Open Source License
protected MemoryFileBuffer writePDF(IWContext iwc) { Font titleFont = new Font(Font.HELVETICA, 14, Font.BOLD); Font labelFont = new Font(Font.HELVETICA, 11, Font.BOLD); Font textFont = new Font(Font.HELVETICA, 11, Font.NORMAL); try {/*from ww w . j a va 2 s . co m*/ MemoryFileBuffer buffer = new MemoryFileBuffer(); MemoryOutputStream mos = new MemoryOutputStream(buffer); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, mos); document.addAuthor("Idegaweb eGov"); document.addSubject("Case"); document.open(); document.newPage(); String title = iwrb.getLocalizedString("case_overview", "Case overview"); Paragraph cTitle = new Paragraph(title, titleFont); cTitle.setSpacingAfter(24); document.setPageCount(1); document.add(cTitle); int[] widths = { 25, 75 }; PdfPTable table = new PdfPTable(2); table.setWidths(widths); table.getDefaultCell().setBorder(0); table.getDefaultCell().setPaddingBottom(8); CaseCategory category = theCase.getCaseCategory(); CaseCategory parentCategory = category.getParent(); CaseType type = theCase.getCaseType(); User user = theCase.getOwner(); Address address = user != null ? getUserBusiness(iwc).getUsersMainAddress(user) : null; PostalCode postal = null; if (address != null) { postal = address.getPostalCode(); } Phone phone = null; if (user != null) { try { phone = getUserBusiness(iwc).getUsersHomePhone(user); } catch (NoPhoneFoundException e) { //No phone found... } } Email email = null; if (user != null) { try { email = getUserBusiness(iwc).getUsersMainEmail(user); } catch (NoEmailFoundException e) { //No email found... } } IWTimestamp created = new IWTimestamp(theCase.getCreated()); if (user != null) { table.addCell(new Phrase(iwrb.getLocalizedString("name", "Name"), labelFont)); table.addCell(new Phrase( new Name(user.getFirstName(), user.getMiddleName(), user.getLastName()).getName(locale), textFont)); table.addCell(new Phrase(iwrb.getLocalizedString("personal_id", "Personal ID"), labelFont)); table.addCell(new Phrase(PersonalIDFormatter.format(user.getPersonalID(), locale), textFont)); table.addCell(new Phrase(iwrb.getLocalizedString("address", "Address"), labelFont)); table.addCell(new Phrase(address != null ? address.getStreetAddress() : "-", textFont)); table.addCell(new Phrase(iwrb.getLocalizedString("zip_code", "Postal code"), labelFont)); table.addCell(new Phrase(postal != null ? postal.getPostalAddress() : "-", textFont)); table.addCell(new Phrase(iwrb.getLocalizedString("home_phone", "Home phone"), labelFont)); table.addCell(new Phrase(phone != null ? phone.getNumber() : "-", textFont)); table.addCell(new Phrase(iwrb.getLocalizedString("email", "Email"), labelFont)); table.addCell(new Phrase(email != null ? email.getEmailAddress() : "-", textFont)); table.addCell(new Phrase("")); table.addCell(new Phrase("")); table.addCell(new Phrase("")); table.addCell(new Phrase("")); } table.addCell(new Phrase(iwrb.getLocalizedString("case_nr", "Case nr."), labelFont)); table.addCell(new Phrase(theCase.getPrimaryKey().toString(), textFont)); if (getCasesBusiness(iwc).useTypes()) { table.addCell(new Phrase(iwrb.getLocalizedString("case_type", "Case type"), labelFont)); table.addCell(new Phrase(type.getName(), textFont)); } if (parentCategory != null) { table.addCell(new Phrase(iwrb.getLocalizedString("case_category", "Case category"), labelFont)); table.addCell(new Phrase(parentCategory.getLocalizedCategoryName(locale), textFont)); table.addCell(new Phrase(iwrb.getLocalizedString("sub_case_category", "Case category"), labelFont)); table.addCell(new Phrase(category.getLocalizedCategoryName(locale), textFont)); } else { table.addCell(new Phrase(iwrb.getLocalizedString("case_category", "Case category"), labelFont)); table.addCell(new Phrase(category.getLocalizedCategoryName(locale), textFont)); } table.addCell(new Phrase(iwrb.getLocalizedString("created_date", "Created date"), labelFont)); table.addCell(new Phrase(created.getLocaleDateAndTime(locale, IWTimestamp.SHORT, IWTimestamp.SHORT), textFont)); if (theCase.getSubject() != null) { table.addCell(new Phrase(iwrb.getLocalizedString("subject", "Subject"), labelFont)); table.addCell(new Phrase(theCase.getSubject(), textFont)); } table.addCell(new Phrase(iwrb.getLocalizedString("message", "Message"), labelFont)); table.addCell(new Phrase(theCase.getMessage(), textFont)); if (theCase.getReference() != null) { table.addCell(new Phrase(iwrb.getLocalizedString("reference", "Reference"), labelFont)); table.addCell(new Phrase(theCase.getReference(), textFont)); } table.setWidthPercentage(100); document.add(table); document.close(); try { mos.close(); } catch (Exception ex) { ex.printStackTrace(); } buffer.setMimeType("application/pdf"); return buffer; } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
protected Document getLetterDocumentTemplate() { // Margins defined in millimeters: float headFootMarginsMM = 9.0f; float leftRightMarginsMM = 30.0f; // Margins defined in points: float headFootMargins = getPointsFromMM(headFootMarginsMM); float leftRightMargins = getPointsFromMM(leftRightMarginsMM); Document document = new Document(PageSize.A4, leftRightMargins, leftRightMargins, headFootMargins, headFootMargins);// ww w .jav a 2s.c o m // document.setMargins(leftRightMargins,leftRightMargins,headFootMargins,headFootMargins); document.addAuthor("IdegaWeb"); document.addSubject("PrintedLetter"); // document.open(); return document; }
From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java
License:Open Source License
private ByteArrayOutputStream exportAsPdf(Experiment3VO experiment, List<Buffer3VO> buffers, Proposal3VO proposal) throws Exception { Document document = new Document(PageSize.A4.rotate(), 10, 10, 20, 20); document.addTitle("exportSamplesView"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); HeaderFooter header = new HeaderFooter( new Phrase(proposal.getTitle() + " " + proposal.getCode() + proposal.getNumber()), false); header.setAlignment(Element.ALIGN_CENTER); header.getBefore().getFont().setSize(8); HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorderWidth(1);// w w w .ja v a2 s . co m footer.getBefore().getFont().setSize(6); document.setHeader(header); document.setFooter(footer); document.open(); BaseFont bf = BaseFont.createFont(FONTS[0][0], FONTS[0][1], BaseFont.EMBEDDED); Font font = new Font(bf, 6); document.add(new Paragraph("Data Acquisition: " + experiment.getName(), font)); document.add(new Paragraph("Type: " + experiment.getType(), font)); document.add(new Paragraph("Date: " + experiment.getCreationDate(), font)); document.add(new Paragraph("Proposal: " + proposal.getCode() + proposal.getNumber(), font)); document.add(new Paragraph("Title: " + proposal.getTitle(), font)); document.add(new Paragraph(" ")); document.add(new Paragraph("Measurements", PdfRtfExporter.FONT_DOC_BOLD)); document.add(new Paragraph(" ")); document.add(this.getMeasurementTable(experiment, buffers)); document.newPage(); document.add(new Paragraph(" ")); document.add(new Paragraph("Analysis", PdfRtfExporter.FONT_DOC_BOLD)); document.add(new Paragraph(" ")); document.add(this.getAnalysis(experiment, buffers)); document.newPage(); document.add(this.getImageTable(experiment, buffers)); document.close(); return baos; }