List of usage examples for com.itextpdf.text Paragraph add
@Override public boolean add(Element o)
Element
to the Paragraph
. 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 ww w . j a v a2 s . 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
public static void addTitlePageProfessor(Document document, String title, String user) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);// ww w . ja v a2 s .com // Lets write a big header preface.add(new Paragraph(title, catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Lista gerada por: " + user + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(preface, 2); document.add(preface); addEmptyLine(preface, 3); }
From source file:others.pdfWriter.java
public static void addTitlePage(Document document, String title, String user) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);//from ww w. j ava 2 s.c o m // Lets write a big header preface.add(new Paragraph(title, catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Ficha gerada por: " + user + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(preface, 2); preface.add(new Paragraph("Ficha de Treino", smallBold)); document.add(preface); addEmptyLine(preface, 3); // Start a new page }
From source file:others.pdfWriter.java
public static void addNumbers(Document document, int alunos, int professores, int exercicios, int fichas) throws DocumentException { Paragraph numbers = new Paragraph(); addEmptyLine(numbers, 1);/*from www. jav a 2s. com*/ // Lets write a big header numbers.add(new Paragraph("Numeros totais", catFont)); addEmptyLine(numbers, 1); // Will create: Report generated by: _name, _date numbers.add(new Paragraph("Alunos Cadastrados: " + alunos, smallBold)); addEmptyLine(numbers, 2); numbers.add(new Paragraph("Professores Cadastrados: " + professores, smallBold)); addEmptyLine(numbers, 2); numbers.add(new Paragraph("Exercicios Cadastrados: " + exercicios, smallBold)); addEmptyLine(numbers, 2); numbers.add(new Paragraph("Fichas Cadastradas: " + professores, smallBold)); document.add(numbers); addEmptyLine(numbers, 3); }
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);// w w w . j a v a 2 s . co m 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.AcademicSection.java
private static Paragraph getSectionTitle(String title) { Paragraph result = new Paragraph(title, LifetimeFonts.FONT_DEFAULT); result.add(PdfUtility.LINE_SEPARATOR); result.add(NEWLINE);/*from ww w . j av a 2s . co m*/ result.add(NEWLINE); return result; }
From source file:pdf.CoverLetterUtility.java
License:Apache License
private void addTitle(Document document) { Paragraph titleParagraph = new Paragraph(); titleParagraph.setAlignment(Paragraph.ALIGN_CENTER); TitlePhrase name = new TitlePhrase(getUserFullname(), LifetimeFonts.FONT_HEADER); TitlePhrase email = new TitlePhrase(getUserEmail(), LifetimeFonts.FONT_KEY); titleParagraph.add(name); titleParagraph.add(Chunk.NEWLINE);//from ww w.j a v a2s . co m titleParagraph.add(email); titleParagraph.add(Chunk.NEWLINE); try { document.add(titleParagraph); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:pdf.CoverLetterUtility.java
License:Apache License
private void addReference(Document document) { ValuePhrase position = new ValuePhrase("Position:" + jobOffer.getPosition(), LifetimeFonts.FONT_ORG); ValuePhrase reference = new ValuePhrase("Reference:" + jobOffer.getReference(), LifetimeFonts.FONT_DEFAULT); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); //current.setSpacingBefore(10f); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE);//from www. j a v a 2s.co m paragraph.add(position); paragraph.add(Chunk.NEWLINE); paragraph.add(reference); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); try { document.add(paragraph); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:pdf.CoverLetterUtility.java
License:Apache License
private void addIntroduction(Document document) { TitlePhrase introTitle = new TitlePhrase("Introduction", LifetimeFonts.FONT_BOLD); ValuePhrase introduction = new ValuePhrase(letter.getIntroduction(), LifetimeFonts.FONT_DEFAULT); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED); //current.setSpacingBefore(10f); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE);/*from ww w.j a v a 2s.c om*/ paragraph.add(introTitle); paragraph.add(Chunk.NEWLINE); paragraph.add(introduction); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); try { document.add(paragraph); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:pdf.CoverLetterUtility.java
License:Apache License
private void addSalutation(Document document) { Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED); //current.setSpacingBefore(10f); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE);/*from w w w.ja va 2 s . c om*/ paragraph.add(new ValuePhrase("Dear " + jobOffer.getContactTitle() + " " + jobOffer.getContactName())); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); try { document.add(paragraph); } catch (DocumentException ex) { Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex); } }