List of usage examples for com.itextpdf.text Document top
public float top(float margin)
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private String createPdf(Context context) throws Exception { BscReportPropertyUtils.loadData();/*from w ww.j a v a 2s. c om*/ BscReportSupportUtils.loadExpression(); // 2015-04-18 add String visionOid = (String) context.get("visionOid"); VisionVO vision = null; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } FontFactory.register(BscConstants.PDF_ITEXT_FONT); String fileName = UUID.randomUUID().toString() + ".pdf"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; OutputStream os = new FileOutputStream(fileFullPath); //Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); Document document = new Document(PageSize.A4, 10, 10, 10, 10); document.left(100f); document.top(150f); PdfWriter writer = PdfWriter.getInstance(document, os); document.open(); int dateRangeRows = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0) .getDateRangeScores().size(); PdfPTable table = new PdfPTable(MAX_COLSPAN); PdfPTable dateRangeTable = new PdfPTable(dateRangeRows); PdfPTable chartsTable = new PdfPTable(2); PdfPTable signTable = new PdfPTable(1); table.setWidthPercentage(100f); dateRangeTable.setWidthPercentage(100f); chartsTable.setWidthPercentage(100f); signTable.setWidthPercentage(100f); this.createHead(table, vision); this.createBody(table, vision); this.createDateRange(dateRangeTable, vision, context, dateRangeRows); this.putCharts(chartsTable, context); this.putSignature(signTable, context); document.add(chartsTable); document.add(table); document.add(dateRangeTable); document.add(signTable); document.close(); writer.close(); os.flush(); os.close(); os = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "kpi-report.pdf"); file = null; return oid; }
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java
License:Apache License
private String createPdf(Context context) throws Exception { BscReportPropertyUtils.loadData();/*from www. j av a 2 s .c o m*/ String visionOid = (String) context.get("visionOid"); VisionVO vision = null; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } FontFactory.register(BscConstants.PDF_ITEXT_FONT); String fileName = UUID.randomUUID().toString() + ".pdf"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; OutputStream os = new FileOutputStream(fileFullPath); Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); document.left(100f); document.top(150f); PdfWriter writer = PdfWriter.getInstance(document, os); document.open(); PdfPTable table = new PdfPTable(MAX_COLSPAN); table.setWidthPercentage(100f); PdfPTable signTable = new PdfPTable(1); signTable.setWidthPercentage(100f); this.createHead(table, vision, context); this.createBody(table, vision); this.putSignature(signTable, context); document.add(table); document.add(signTable); document.close(); writer.close(); os.flush(); os.close(); os = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "department-report.pdf"); file = null; return oid; }
From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java
License:Apache License
private String createPdf(Context context) throws Exception { BscReportPropertyUtils.loadData();/* w ww . ja v a 2s . c o m*/ String visionOid = (String) context.get("visionOid"); VisionVO vision = null; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } FontFactory.register(BscConstants.PDF_ITEXT_FONT); String fileName = UUID.randomUUID().toString() + ".pdf"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; OutputStream os = new FileOutputStream(fileFullPath); Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); document.left(100f); document.top(150f); PdfWriter writer = PdfWriter.getInstance(document, os); document.open(); PdfPTable table = new PdfPTable(MAX_COLSPAN); table.setWidthPercentage(100f); PdfPTable signTable = new PdfPTable(1); signTable.setWidthPercentage(100f); this.createHead(table, vision, context); this.createBody(table, vision); this.createFoot(table, context); this.putSignature(signTable, context); document.add(table); document.add(signTable); document.close(); writer.close(); os.flush(); os.close(); os = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "personal-report.pdf"); file = null; return oid; }
From source file:ufc.fbd.modelo.GeradorPdf.java
public GeradorPdf(Aluga aluga) { Document document = new Document(); try {//from w w w .ja v a 2 s.com PdfWriter.getInstance(document, new FileOutputStream("C://pdfsGerados/notaFiscal.pdf")); document.open(); document.addHeader("Nota Fiscal", "Cliente: " + aluga.getCliente().getNome() + " Cpf: " + aluga.getCliente().getCpf()); document.top(5.0f); document.add(new Paragraph("Nota Fiscal, Locadora: " + aluga.getFilme().getLocadora().getNome() + ", " + aluga.getCliente().getLocadora().getNome() + " " + aluga.getData())); document.add(new Paragraph(" ")); document.add(new Paragraph("Cliente: " + aluga.getCliente().getNome())); document.add(new Paragraph("Cpf: " + aluga.getCliente().getCpf())); document.add(new Paragraph(" ")); document.add(new Paragraph("Nome do Filme: " + aluga.getFilme().getNome())); document.add(new Paragraph("Categoria: " + aluga.getFilme().getCategoria().getCategoria())); document.add(new Paragraph("Indicao: " + aluga.getFilme().getIndicacao())); document.add(new Paragraph(" ")); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }