/** * Create a new PdfWriter for the given iText Document. * @param document the iText Document to create a writer for * @param os the OutputStream to write to * @return the PdfWriter instance to use * @throws DocumentException if thrown during writer creation */ protected PdfWriter newWriter(Document document, OutputStream os) throws DocumentException { return PdfWriter.getInstance(document, os); }
/** * Create a new PdfWriter for the given iText Document. * @param document the iText Document to create a writer for * @param os the OutputStream to write to * @return the PdfWriter instance to use * @throws DocumentException if thrown during writer creation */ protected PdfWriter newWriter(Document document, OutputStream os) throws DocumentException { return PdfWriter.getInstance(document, os); }
Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); this.onTableRender = onTableRender;
@Override public void export(FacesContext context, DataTable table, String filename, boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor, ExporterOptions options, MethodExpression onTableRender) throws IOException { try { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); this.onTableRender = onTableRender; if (preProcessor != null) { preProcessor.invoke(context.getELContext(), new Object[]{document}); } if (!document.isOpen()) { document.open(); } if (options != null) { expOptions = options; } document.add(exportPDFTable(context, table, pageOnly, selectionOnly, encodingType)); if (postProcessor != null) { postProcessor.invoke(context.getELContext(), new Object[]{document}); } document.close(); writePDFToResponse(context.getExternalContext(), baos, filename); } catch (DocumentException e) { throw new IOException(e.getMessage()); } }
private void createWriter(Document document, String title) throws DocumentException, IOException { final PdfWriter writer = PdfWriter.getInstance(document, output); //writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft); // title final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); // simple page numbers : x //HeaderFooter footer = new HeaderFooter(new Phrase(), true); //footer.setAlignment(Element.ALIGN_RIGHT); //footer.setBorder(Rectangle.TOP); //document.setFooter(footer); // add the event handler for advanced page numbers : x/y writer.setPageEvent(new PdfAdvancedPageNumberEvents()); }
Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); this.onTableRender = onTableRender;
/** * Create a new PdfWriter for the given iText Document. * @param document the iText Document to create a writer for * @param os the OutputStream to write to * @return the PdfWriter instance to use * @throws DocumentException if thrown during writer creation */ protected PdfWriter newWriter(Document document, OutputStream os) throws DocumentException { return PdfWriter.getInstance(document, os); }
/** * Create a new PdfWriter for the given iText Document. * @param document the iText Document to create a writer for * @param os the OutputStream to write to * @return the PdfWriter instance to use * @throws DocumentException if thrown during writer creation */ protected PdfWriter newWriter(Document document, OutputStream os) throws DocumentException { return PdfWriter.getInstance(document, os); }
public void setHeader(final Header header) { tocOutputStream = new ByteArrayOutputStream(); writer = null; try { writer = PdfWriter.getInstance(toc, tocOutputStream); writer.setPageEvent(header); } catch (DocumentException e) { LOG.error("Can not add TOC", e); } } }
/** * Initializes the PDF writer this export view uses to write the table document. * @param document The iText document to be written. * @param out The output stream to which the document is written. * @throws DocumentException If something goes wrong during initialization. */ protected void initItextWriter(Document document, OutputStream out) throws DocumentException { PdfWriter.getInstance(document, out).setPageEvent(new PageNumber()); }
protected DocWriter createWriterForStream(OutputStream stream) throws DocumentException { if (documentType == PDF) { return PdfWriter.getInstance(document, stream); } else if (documentType == RTF) { return RtfWriter2.getInstance(document, stream); } else if (documentType == HTML) { return HtmlWriter.getInstance(document, stream); } throw new IllegalArgumentException("unknown document type"); } }
/** * Creates a document. * * @param outputStream The output stream to write the document content. * @param pageSize the page size. * @return A Document. */ public static Document openDocument( OutputStream outputStream, Rectangle pageSize ) { try { Document document = new Document( pageSize ); PdfWriter.getInstance( document, outputStream ); document.open(); return document; } catch ( DocumentException ex ) { throw new RuntimeException( "Failed to open PDF document", ex ); } }
/** * Creates an endowment total report in PDF * * @param endowmentAssetStatementReportDataHolders * @param reportHeaderDataHolderForEndowment * @param listKemidsInHeader * @return */ public ByteArrayOutputStream generateEndowmentTotalReport(List<AssetStatementReportDataHolder> endowmentAssetStatementReportDataHolders, EndowmentReportHeaderDataHolder reportHeaderDataHolderForEndowment, String listKemidsInHeader) { ByteArrayOutputStream pdfStream = new ByteArrayOutputStream(); try { Document document = new Document(); PdfWriter.getInstance(document, pdfStream); document.open(); generateEndowmentTotalReport(endowmentAssetStatementReportDataHolders, reportHeaderDataHolderForEndowment, document, listKemidsInHeader, false); document.close(); return pdfStream; } catch (Exception e) { LOG.error("Error in generateEndowmentDetailReport(): " + e.getMessage()); return null; } }
private void serializeToPDF(EntityBean bean, OutputStream stream) { ServletOutputStream servletStream = (ServletOutputStream) stream; DiscrepancyNoteBean discNBean = (DiscrepancyNoteBean) bean; StringBuilder writer = new StringBuilder(); writer.append(serializeToString(discNBean, false, 0)); Document pdfDoc = new Document(); try { PdfWriter.getInstance(pdfDoc, servletStream); pdfDoc.open(); pdfDoc.add(new Paragraph(writer.toString())); } catch (DocumentException e) { e.printStackTrace(); } pdfDoc.close(); }
private void printImageToPdf(final Entity attachment, HttpServletResponse response) { Document document = new Document(); try { PdfWriter.getInstance(document, response.getOutputStream()); document.open(); document.setPageSize(PageSize.A4); pdfHelper.addMetaData(document); pdfHelper.addImage(document, attachment.getStringField(TechnologyAttachmentFields.ATTACHMENT)); document.close(); } catch (Exception e) { LOG.error("Problem with printing document - " + e.getMessage()); document.close(); } }
public void serializeListToPDF(String content, OutputStream stream) { ServletOutputStream servletStream = (ServletOutputStream) stream; Document pdfDoc = new Document(); try { PdfWriter.getInstance(pdfDoc, servletStream); pdfDoc.open(); pdfDoc.add(new Paragraph(content)); } catch (DocumentException e) { e.printStackTrace(); } pdfDoc.close(); }
/** * @see org.kuali.kfs.module.bc.document.service.BudgetRequestImportService#generatePdf(java.util.List, java.io.ByteArrayOutputStream) */ @NonTransactional public void generatePdf(List<String> errorMessages, ByteArrayOutputStream baos) throws DocumentException { Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); for (String error : errorMessages) { document.add(new Paragraph(error)); } document.close(); }
/** * @see org.kuali.kfs.module.bc.document.service.BudgetConstructionReportsServiceHelper#generatePdf(java.util.List, * java.io.ByteArrayOutputStream) */ @NonTransactional public void generatePdf(List<String> errorMessages, ByteArrayOutputStream baos) throws DocumentException { Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); for (String error : errorMessages) { document.add(new Paragraph(error)); } document.close(); }
private void createWriter(Document document, String title) throws DocumentException, IOException { final PdfWriter writer = PdfWriter.getInstance(document, output); //writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft); // title final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); // simple page numbers : x //HeaderFooter footer = new HeaderFooter(new Phrase(), true); //footer.setAlignment(Element.ALIGN_RIGHT); //footer.setBorder(Rectangle.TOP); //document.setFooter(footer); // add the event handler for advanced page numbers : x/y writer.setPageEvent(new PdfAdvancedPageNumberEvents()); }
/** * * @see org.kuali.kfs.module.bc.service.PayrateImportService#generatePdf(java.lang.StringBuilder, java.io.ByteArrayOutputStream) */ @NonTransactional public void generatePdf(List<ExternalizedMessageWrapper> logMessages, ByteArrayOutputStream baos) throws DocumentException { Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); for (ExternalizedMessageWrapper messageWrapper : logMessages) { String message; if (messageWrapper.getParams().length == 0 ) message = SpringContext.getBean(KualiConfigurationService.class).getPropertyString(messageWrapper.getMessageKey()); else { String temp = SpringContext.getBean(KualiConfigurationService.class).getPropertyString(messageWrapper.getMessageKey()); message = MessageFormat.format(temp, (Object[])messageWrapper.getParams()); } document.add(new Paragraph(message)); } document.close(); }