List of usage examples for com.itextpdf.text Document Document
public Document(Rectangle pageSize)
Document
-object. From source file:com.raghav.plot.ImageIntoPDF.java
public static void main(String[] args) throws Exception { Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("/home/raghav/zzzzz.pdf")); document.open();//from w w w. j a va 2 s .c om document.newPage(); //for 4 photo // for (int i=0;i<2;i++) { // Image image1 = Image.getInstance("/home/raghav/Desktop/Firmway-Reco.png"); // image1.setAbsolutePosition(40,80+(350*i)); // image1.scaleAbsolute(200, 260); // document.add(image1); // } // for (int i=0;i<2;i++) { // Image image1 = Image.getInstance("/home/raghav/Desktop/Firmway-Reco.png"); // image1.setAbsolutePosition(300, 80+(350*i)); // image1.scaleAbsolute(260, 200); // document.add(image1); // } //for 6 float margin = 10; float docHeight = ((document.getPageSize().getHeight()) / 3) - (2 * margin); float docwidth = ((document.getPageSize().getWidth()) / 2) - (2 * margin); for (int i = 0; i < 3; i++) { Image image1 = Image.getInstance("/home/raghav/myps/i1.jpeg"); image1.setAbsolutePosition(margin, margin * (i + 1) + (docHeight * i)); image1.scaleToFit(docwidth, docHeight); //image1.scaleAbsolute(190, 130); document.add(image1); } for (int i = 0; i < 3; i++) { Image image1 = Image.getInstance("/home/raghav/myps/i1.jpeg"); image1.setAbsolutePosition(docwidth + (2 * margin), margin * (i + 1) + (docHeight * i)); image1.scaleToFit(docwidth, docHeight); document.add(image1); } document.close(); }
From source file:com.rapidminer.gui.actions.ExportPdfAction.java
License:Open Source License
/** * Create the PDF from a {@link Component}. * //from w ww. j a va 2s . com * @param component */ private void createPdf(Component component) { if (component == null) { return; } // prompt user for pdf location File file = promptForPdfLocation(); if (file == null) { return; } try { // create pdf document Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); PdfContentByte cb = writer.getDirectContent(); createPdfViaTemplate(component, document, cb); document.close(); } catch (Exception e) { SwingTools.showSimpleErrorMessage("cannot_export_pdf", e, e.getMessage()); } }
From source file:com.rapidminer.gui.actions.ExportPdfAction.java
License:Open Source License
/** * Create the PDF from a {@link PlotterTemplate}. * // w w w .ja v a2s.c om * @param template */ private void createPdf(PlotterTemplate template) { if (template == null) { return; } // prompt user for pdf location File file = promptForPdfLocation(); if (file == null) { return; } try { // create pdf document Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); PdfContentByte cb = writer.getDirectContent(); createPdfViaTemplate(template, document, cb); document.close(); } catch (Exception e) { SwingTools.showSimpleErrorMessage("cannot_export_pdf", e, e.getMessage()); } }
From source file:com.sapito.direccion.PdfView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { ByteArrayOutputStream baos = createTemporaryOutputStream(); Document document = new Document(PageSize.LETTER); PdfWriter pdfWriter = PdfWriter.getInstance(document, baos); pdfWriter.setViewerPreferences(PdfWriter.ALLOW_PRINTING | PdfWriter.PageLayoutSinglePage); document.open();/*from ww w . j av a 2s .c o m*/ buildPdfDocument(model, document, pdfWriter, request, response); document.close(); response.setHeader("Content-Disposition", "attachment; filename=" + model.get("filename").toString() + ".pdf"); //response.setContentLength(baos.size()); System.out.println("size:" + baos.size()); writeToResponse(response, baos); }
From source file:com.timesheet.export.AbstractITextPdfViewCustom.java
protected Document newDocument() { return new Document(PageSize.A4); }
From source file:com.unicauca.coordinacionpis.managedbean.RegistroFormatoAController.java
public void agregarMetadatos() { // create document and writer Document document = new Document(PageSize.A4); PdfWriter writer;//from ww w . ja v a 2s .com try { writer = PdfWriter.getInstance(document, new FileOutputStream("D:\\aguaabril2016.pdf")); // add meta-data to pdf document.addAuthor("Memorynotfound"); document.addCreationDate(); document.addCreator("Memorynotfound.com"); document.addTitle("Add meta data to PDF"); document.addSubject("how to add meta data to pdf using itext"); document.addKeywords(metadatosAnteproyectos.getTitulo() + "," + metadatosAnteproyectos.getProfesor()); document.addLanguage(Locale.ENGLISH.getLanguage()); document.addHeader("type", "tutorial, example"); // add xmp meta data writer.createXmpMetadata(); document.open(); document.add(new Paragraph("Add meta-data to PDF using iText")); document.close(); } catch (FileNotFoundException ex) { Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex); } }