List of usage examples for com.itextpdf.text Anchor setName
public void setName(final String name)
Anchor
. From source file:org.zaproxy.zap.extension.alertReport.AlertReportExportPDF.java
License:Apache License
private static void addContent(Document document, java.util.List<Alert> alerts, ExtensionAlertReportExport extensionExport) throws DocumentException { Alert alert = alerts.get(0);//from w ww . jav a 2s . c o m Anchor anchor = new Anchor(alert.getAttack(), catFont); anchor.setName(alert.getAttack()); Paragraph content = new Paragraph(); content.add(new Paragraph(alert.getAlert(), catFont)); content.add(new Paragraph( extensionExport.getMessages().getString("alertreport.export.message.export.pdf.description"), subFont)); content.add(new Paragraph(getFieldAlertProperty(alert.getPluginId(), "description", alert.getDescription(), extensionExport))); addEmptyLine(content, 1); content.add(new Paragraph( extensionExport.getMessages().getString("alertreport.export.message.export.pdf.risk"), subFont)); content.add(new Paragraph(getFieldAlertProperty(alert.getPluginId(), "risk." + String.valueOf(alert.getRisk()), Alert.MSG_RISK[alert.getRisk()], extensionExport))); addEmptyLine(content, 1); content.add(new Paragraph( extensionExport.getMessages().getString("alertreport.export.message.export.pdf.reability"), subFont)); content.add(new Paragraph( getFieldAlertProperty(alert.getPluginId(), "reliability." + String.valueOf(alert.getReliability()), Alert.MSG_RELIABILITY[alert.getReliability()], extensionExport))); addEmptyLine(content, 1); content.add(new Paragraph( extensionExport.getMessages().getString("alertreport.export.message.export.pdf.urls"), subFont)); // write all url with the same pluginid for (int i = 0; i < alerts.size(); i++) { Alert alertAux = alerts.get(i); // add url link and attack anchor = new Anchor((i + 1) + "-" + alertAux.getUri()); anchor.setReference(alertAux.getUri()); content.add(anchor); if (!alertAux.getParam().isEmpty()) { content.add( new Paragraph(" " + extensionExport.getMessages() .getString("alertreport.export.message.export.pdf.parameters") + ": " + alertAux.getParam())); addEmptyLine(content, 1); } if (!alertAux.getAttack().isEmpty()) { content.add(new Paragraph( extensionExport.getMessages().getString("alertreport.export.message.export.pdf.attack"), subFont)); content.add(new Paragraph(alertAux.getAttack())); addEmptyLine(content, 1); } // add images test addEmptyLine(content, 1); String images = alertAux.getOtherInfo(); if (!images.isEmpty()) { String[] list = images.split("\n"); // for (int j = 0, lengh = list.length/2; j <= lengh; j += 2) { for (int j = 0; j < list.length; j++) { if (!((j + 1) >= list.length)) { String step = list[j]; Paragraph paragraph = new Paragraph(step); content.add(paragraph); addEmptyLine(content, 1); // add step and image String imageName = ""; String path = extensionExport.getParams().getWorkingDirImages(); if (((j + 1) < list.length) && (!list[j + 1].isEmpty())) { imageName = list[j + 1]; // if exist an image try { if ((imageName.endsWith(".png") || imageName.endsWith(".jpg")) && (!path.isEmpty())) { addImage(content, path + "/" + imageName, 60f); addEmptyLine(content, 1); paragraph = new Paragraph(extensionExport.getMessages() .getString("alertreport.export.message.export.pdf.image") + ": " + Integer.toString(j), litleFont); paragraph.setAlignment(Paragraph.ALIGN_CENTER); content.add(paragraph); } else { paragraph = new Paragraph(imageName); content.add(paragraph); addEmptyLine(content, 1); } } catch (Exception e) { logger.error(e.getMessage(), e); } } j++; } } } addEmptyLine(content, 1); } if (!alert.getSolution().equals("")) { addEmptyLine(content, 1); content.add(new Paragraph( extensionExport.getMessages().getString("alertreport.export.message.export.pdf.solution"), subFont)); content.add(new Paragraph( getFieldAlertProperty(alert.getPluginId(), "solution", alert.getSolution(), extensionExport))); } addEmptyLine(content, 1); if (!alert.getReference().equals("")) { content.add(new Paragraph( extensionExport.getMessages().getString("alertreport.export.message.export.pdf.references"), subFont)); content.add(new Paragraph(alert.getReference())); addEmptyLine(content, 1); } document.add(content); // Start a new page document.newPage(); }
From source file:others.pdfWriter.java
private static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("First Chapter", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // add a list createList(subCatPart);//from ww w . ja va 2s . c o m Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // add a table // createTableExercicios(subCatPart); // now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Second Chapter", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // now add all this to the document document.add(catPart); }
From source file:our.isaacmayur.expensemanager.GenerateReport.java
private static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("Expense Report", catFont); anchor.setName("Expense Report"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph paragraph = new Paragraph(); paragraph.add(new Paragraph("Report generated on " + new Date(), smallBold)); addEmptyLine(paragraph, 3);//from w ww.j av a2 s. c om catPart.add(paragraph); // Paragraph subPara = new Paragraph("Expense Table 1", subFont); // Section subCatPart = catPart.addSection(subPara); // subCatPart.add(new Paragraph("Expense")); // subPara = new Paragraph("Subcategory 2", subFont); // subCatPart = catPart.addSection(subPara); // subCatPart.add(new Paragraph("Paragraph 1")); // subCatPart.add(new Paragraph("Paragraph 2")); // subCatPart.add(new Paragraph("Paragraph 3")); // // add a list // createList(subCatPart); // Paragraph paragraph = new Paragraph(); // addEmptyLine(paragraph, 5); // subCatPart.add(paragraph); // add a table createTable(catPart); // now add all this to the document // document.add(catPart); // Next section // anchor = new Anchor("Second Chapter", catFont); // anchor.setName("Second Chapter"); // Second parameter is the number of the chapter // catPart = new Chapter(new Paragraph(anchor), 1); // subPara = new Paragraph("Subcategory", subFont); // subCatPart = catPart.addSection(subPara); // subCatPart.add(new Paragraph("This is a very important message")); // now add all this to the document document.add(catPart); Log.e("meta", "content"); }
From source file:pdf.PDFdescriptiva.java
private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, String[] variables) throws DocumentException { agregarTabla(document, titulo, arreglo); Anchor anchor = new Anchor("Datos", catFont); anchor.setName("Datos"); Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Variables", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("N: " + N)); subCatPart.add(new Paragraph("Maximo: " + variables[0])); subCatPart.add(new Paragraph("Minimo: " + variables[1])); subCatPart.add(new Paragraph("Rango: " + variables[2])); subCatPart.add(new Paragraph("Intervalos: " + variables[3])); subCatPart.add(new Paragraph("Amplitud: " + variables[4])); subCatPart.add(new Paragraph("Rango Ampliado: " + variables[5])); subCatPart.add(new Paragraph("Dif Rangos: " + variables[6])); subCatPart.add(new Paragraph("LIPI: " + variables[7])); subCatPart.add(new Paragraph("LSUI: " + variables[8])); subCatPart.add(new Paragraph("Desv Media: " + variables[9])); subCatPart.add(new Paragraph("Varianza: " + variables[10])); subCatPart.add(new Paragraph("Desv Estandar: " + variables[11])); subCatPart.add(new Paragraph("Media: " + variables[12])); subCatPart.add(new Paragraph("Mediana: " + variables[13])); subCatPart.add(new Paragraph("Moda: " + variables[14])); document.add(catPart);// ww w . j av a2 s.co m }
From source file:pdf.PDFmultiple.java
private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, Double b0, Double b1, Double b2, Double Se, Double[] prediccion) throws DocumentException { agregarTabla(document, titulo, arreglo); Anchor anchor = new Anchor("Datos", catFont); anchor.setName("Datos"); Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Variables", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("N: " + N)); subCatPart.add(new Paragraph("K: 2")); subCatPart.add(new Paragraph("b0: " + b0)); subCatPart.add(new Paragraph("b1: " + b1)); subCatPart.add(new Paragraph("b2: " + b2)); subCatPart.add(new Paragraph("Se: " + Se)); Paragraph espacio = new Paragraph(); addEmptyLine(espacio, 1);/*from w w w . ja va 2s. c o m*/ subCatPart.add(espacio); subPara = new Paragraph("Predicciones", subFont); subCatPart = catPart.addSection(subPara); if (prediccion[0] != null && prediccion[1] != null && prediccion[2] != null && prediccion[3] != null && prediccion[4] != null && prediccion[5] != null) { subCatPart.add(new Paragraph("X1: " + prediccion[0])); subCatPart.add(new Paragraph("X2: " + prediccion[1])); subCatPart.add(new Paragraph("Efectividad: " + prediccion[2])); addEmptyLine(espacio, 1); subCatPart.add(espacio); tablaPrediccion(subCatPart, prediccion[3], prediccion[4], prediccion[5]); } else { subCatPart.add(new Paragraph("No se realiz ninguna prediccion.")); } document.add(catPart); }
From source file:pdf.PDFsimple.java
private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, Double b0, Double b1, Double Se, Double dx, Double dy, Double dxy, Double r, Double[] prediccion) throws DocumentException { agregarTabla(document, titulo, arreglo); Anchor anchor = new Anchor("Datos", catFont); anchor.setName("Datos"); Chapter catPart = new Chapter(new Paragraph(anchor), 1); //comentario/*w ww.jav a 2 s .c o m*/ Paragraph subPara = new Paragraph("Variables", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("N: " + N)); subCatPart.add(new Paragraph("K: 1")); subCatPart.add(new Paragraph("b0: " + b0)); subCatPart.add(new Paragraph("b1: " + b1)); subCatPart.add(new Paragraph("Se: " + Se)); subCatPart.add(new Paragraph("DX: " + dx)); subCatPart.add(new Paragraph("DY: " + dy)); subCatPart.add(new Paragraph("DXY: " + dxy)); subCatPart.add(new Paragraph("R: " + r)); Paragraph espacio = new Paragraph(); addEmptyLine(espacio, 1); subCatPart.add(espacio); subPara = new Paragraph("Predicciones", subFont); subCatPart = catPart.addSection(subPara); if (prediccion[0] != null && prediccion[1] != null && prediccion[2] != null && prediccion[3] != null && prediccion[4] != null) { subCatPart.add(new Paragraph("X: " + prediccion[0])); subCatPart.add(new Paragraph("Efectividad: " + prediccion[1])); addEmptyLine(espacio, 1); subCatPart.add(espacio); tablaPrediccion(subCatPart, prediccion[2], prediccion[3], prediccion[4]); } else { subCatPart.add(new Paragraph("No se realiz ninguna prediccion.")); } document.add(catPart); }
From source file:pdfgen.pdf_generation_try5.java
public void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("Chapter 1: used for various paragraphs", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // add a list createList(subCatPart);//from www . j a v a 2 s .com Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // add a table createTable(subCatPart); // now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Second Chapter : only for checking", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // now add all this to the document document.add(catPart); }
From source file:report.pdfs.Basics_PDF_Report.java
private void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("Table Report", catFont); anchor.setName("Table Report"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph paragraph = new Paragraph(); // Add a table document.add(new Paragraph()); createTable(catPart);/*from www . j a v a 2 s . c om*/ // Now add all this to the document document.add(catPart); // Start a new page document.newPage(); // Next section anchor = new Anchor("Second Chapter", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 2); // Add an image addEmptyLine(paragraph, 5); addBarChart(catPart); // Now add all this to the document document.add(catPart); // Start a new page document.newPage(); // Next section anchor = new Anchor("Third Chapter", catFont); anchor.setName("Third Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 3); // Add an image addEmptyLine(paragraph, 5); addPieChart(catPart); // Now add all this to the document document.add(catPart); }
From source file:sipl.recursos.GenerarPDFGrafica.java
private void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor(Titulo, catFont); anchor.setName(Titulo); Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("", subFont); Section subCatPart = catPart.addSection(subPara); createTable(subCatPart);/*from w w w .j a v a 2s .c o m*/ String p = Titulo.charAt(0) + ""; if (p.equals("M")) { subPara = new Paragraph("", subFont); subCatPart = catPart.addSection(subPara); createTable2(subCatPart); } document.add(catPart); }
From source file:sipl.recursos.GenerarPDFListar.java
private void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor(Titulo, catFont); anchor.setName(Titulo); Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("", subFont); Section subCatPart = catPart.addSection(subPara); createTable(subCatPart);//from w ww. j av a 2s . c o m document.add(catPart); }