List of usage examples for com.itextpdf.text Chapter addSection
public Section addSection(final Paragraph title)
Section
, adds it to this Section
and returns it. From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java
License:Apache License
/** * Das Element wird mit Datentyp, seinen Attributen und Kindelementen * geschrieben./*from w ww . j a va 2 s . c o m*/ * * @param currElement * Zu behandelndes Element * @param currChapter * Kapitel, zu dem das Element hinzugefgt wird * @param chapterEntry * Eintrag des Kapitels fr das Inhaltsverzeichnis * @param schemaQueues * Queues mit allen Elementen fr die einzelnen Schemas */ private void behandleElement(XSElementDecl currElement, Chapter currChapter, ContPdfEntry chapterEntry, Map<String, Queue<XSElementDecl>> schemaQueues) throws DocumentException { // Fr jedes Element eine Section; Titel ist der Elementname // eine Zeile Abstand docPdf.add(getEmptyLineText()); // Referenz des Elements String currReferenzString = getReferenceForElement(currElement); // Titel des Elements inkl. Sprungmarke Chunk chunkElem = getChunkElement(currElement.getName()); chunkElem.setLocalDestination(currReferenzString); Paragraph currElemPara = new Paragraph(getChunkElement("")); currElemPara.add(chunkElem); Section currSection = currChapter.addSection(currElemPara); // Eintrag fr Inhaltsverzeichnis (Element) listEntries.add(new ContPdfEntry(chapterEntry, currSection.getTitle().getContent(), currReferenzString, currPageNumber)); // Sektion dem Dokument (vorlufig) hinzufgen (wichtig fr das // Aktualisieren der Seitenzahl) currSection.setComplete(false); docPdf.add(currSection); // Anmerkung zum Element XSAnnotation ann = currElement.getAnnotation(); if (ann != null) { // Abstand currSection.add(getEmptyLineTextHalf()); String beschreibung = ann.getAnnotation().toString(); currSection.add(getParagraphTextItalic(beschreibung)); } // Abstand currSection.add(getEmptyLineTextHalf()); // Datentyp Paragraph paraTyp = new Paragraph(); XSType currType = currElement.getType(); paraTyp.add(getPhraseTextBold("Datentyp: ")); String strTyp = getNameWithPrefix(currType); if (currType.isLocal()) { strTyp = "<lokal definiert>"; } paraTyp.add(getPhraseText(strTyp + "\n")); // Basistyp if ((currType.getDerivationMethod() == XSType.RESTRICTION) || (currType.getDerivationMethod() == XSType.EXTENSION)) { paraTyp.add(getPhraseTextBold("basiert auf: ")); paraTyp.add(getPhraseText(getNameWithPrefix(currType.getBaseType()) + "\n")); } currSection.add(paraTyp); // Attribute (falls vorhanden) behandleAttribute(currType, currSection); // Kind-Elemente (falls vorhanden) if (currType.isComplexType()) { // Gruppentyp (sequence oder choice) String strCompositor = getCompositorStr(currType.asComplexType()); if (strCompositor.length() > 0) { // Abstand currSection.add(getEmptyLineTextHalf()); currSection.add(getParagraphTextBold(strCompositor + "-Elemente:")); behandleKindElemente(currElement, currSection, schemaQueues); } } // Sektion dem Dokument (endgltig) hinzufgen currSection.setComplete(true); docPdf.add(currSection); }
From source file:drugsupplychain.neu.css.gui.common.distributor.GenerateBillPDF.java
/** * add content to the page//ww w.j ava 2 s .c om * @param document * @throws DocumentException */ private static void addContent(Document document, Order order, Distributor distributor, Address billingAddress) throws DocumentException { Paragraph paragraph = new Paragraph(); Anchor anchor = new Anchor("DISTRIBUTOR INVOICE", catFont); anchor.setName("DISTRIBUTOR INVOICE"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("CUSTOMER DETAILS", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("ID: " + distributor.getOrganizationID())); subCatPart.add(new Paragraph("NAME: " + distributor.getName())); subCatPart.add(new Paragraph("LOCATION: " + distributor.getLocation())); subCatPart.add(new Paragraph("LICENSE NUMBER: " + distributor.getLincense().getLicenseNumber())); //add empty lines addEmptyLine(paragraph, 1); subCatPart.add(paragraph); subPara = new Paragraph("BILLING ADDRESS DETAILS", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("ADDRESS LINE 1: " + billingAddress.getAddressLine1())); subCatPart.add(new Paragraph("ADDRESS LINE 2: " + billingAddress.getAddressLine2())); subCatPart.add(new Paragraph("CITY: " + billingAddress.getCity())); subCatPart.add(new Paragraph("STATE: " + billingAddress.getState())); subCatPart.add(new Paragraph("COUNTRY: " + billingAddress.getCountry())); subCatPart.add(new Paragraph("ZIP CODE: " + billingAddress.getZipcode())); //add empty lines addEmptyLine(paragraph, 1); subCatPart.add(paragraph); subPara = new Paragraph("ORDER SUMMARY TABLE", subFont); subCatPart = catPart.addSection(subPara); //add empty lines addEmptyLine(paragraph, 1); subCatPart.add(paragraph); // add a table int totalPrice = createTable(subCatPart, order); subCatPart.add(new Paragraph("Total Price: " + totalPrice)); subCatPart.add(new Paragraph( "ORDER DATE(MM/DD/YYYY): " + ImplCommonUtil.getFormattedDate(order.getCreationDate()))); subCatPart.add(new Paragraph("BILL GENERATED BY: " + System.getProperty("user.name"))); // now add all this to the document document.add(catPart); }
From source file:edu.esprit.pi.gui.internalframes.PDFwithItextInternalFrame.java
public void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor(titreChapitre1jTextField.getText(), catFont); //anchor.setName("First Chapter"); // le socond paramtre est le numro du chapitre. Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph(titreParagraphe1TextField.getText(), subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph(descriptionjTextArea.getText())); // Nouvelle /* w w w . j a v a 2s. co m*/ Paragraph subPara2 = new Paragraph(description3jTextArea.getText(), subFont); Section subCatPart2 = catPart.addSection(subPara2); subCatPart2.add(new Paragraph(description4jTextArea.getText())); // Ajouter une liste de sections createList(subCatPart2); Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 3); subCatPart2.add(paragraph); // Ajouter un tableau createTable(subCatPart2); // Ajouter tout cela au document. document.add(catPart); // Nouvelle Section anchor = new Anchor(titreChapitre2jTextField.getText(), catFont); //anchor.setName("Second Chapter"); // Le socond paramtre est le numro du chapitre catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph(titreParagraphe2jTextField.getText(), subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph(description2jTextArea.getText())); // ajouter au document document.add(catPart); }
From source file:Ekon.zamestnanecToPDF.java
/** * pridani titulku/*from w w w.ja v a 2 s . co m*/ * * @param dokument * @throws DocumentException */ private static void addTitlePage(Document document, Zamestnanec zam) throws DocumentException { if (zam == null) { System.out.println("chyba"); return; } String jmeno = zam.getJmeno(); String prijmeni = zam.getPrijmeni(); String datumNarozeni = zam.getDatumNarozeni(); String mesto = zam.getMesto(); String ulice = zam.getUlice(); String kraj = zam.getKraj(); String pozice = zam.getPozice(); Anchor anchor = new Anchor("Vypis zamestnance", catFont); anchor.setName("Vypis zamestnance"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Zamestnanec", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Jmeno : " + jmeno)); subCatPart.add(new Paragraph("Prijmeni : " + prijmeni)); subCatPart.add(new Paragraph("Datum narozeni : " + datumNarozeni)); subCatPart.add(new Paragraph("Mesto : " + mesto)); subCatPart.add(new Paragraph("Ulice: " + ulice)); subCatPart.add(new Paragraph("Kraj : " + kraj)); subCatPart.add(new Paragraph("Pozice : " + pozice)); subPara = new Paragraph("Vypis hodin", subFont); subCatPart = catPart.addSection(subPara); Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 3); subCatPart.add(paragraph); // add a table createTable(subCatPart); // now add all this to the document document.add(catPart); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
/******************************************************************************************/ private void buildSocialViewChapter(Chapter chapter, Document document) { chapter.setTitle(getChapterTitleParagraph("Social View")); String chapterIntro = "The social view shows the involved stakeholders, which are represented as %iroles% and %iagents%. Agents refer to actual participants (stakeholders) known when modelling the " + getProjectName()/*from w ww .java 2 s.c o m*/ + " project, whereas roles are a generalisation (abstraction) of agents. To capture the connection between roles and agents, the %i play % relation is used to express the fact that certain agents play certain roles."; chapter.add(createParagraph(chapterIntro)); chapterIntro = "Stakeholders have goals to achieve and they make use of different information to achieve these goals. They interact with one another mainly by %i delegating goals% and %i exchanging information%. Information is represented by means of documents, which actors manipulate to achieve their goals."; chapter.add(createParagraph(chapterIntro)); if (generateSocialViewDiagramSection()) { buildSectionSocialDiagram(chapter.addSection(getSectionTitleParagraph("Social View Diagram")), document); chapter.add(Chunk.NEXTPAGE); } if (generateStakeholdersSection()) { buildSectionStakeholders(chapter.addSection(getSectionTitleParagraph("Stakeholders"))); } if (generateStakeholdersDocumentSection()) { buildSectionStakeholdersDocument( chapter.addSection(getSectionTitleParagraph("Stakeholders' documents"))); } if (generateStakeholdersDocumentAndGoalsSection()) { buildSectionStakeholdersDocumentAndGoals( chapter.addSection(getSectionTitleParagraph("Stakeholders' documents and goals"))); } if (generateGoalAnalysisSection()) { buildSectionGoalAnalysis(chapter.addSection(getSectionTitleParagraph("Goal Analysis"))); } if (generateGoalContributionSection()) { buildSectionGoalContribution(chapter.addSection(getSectionTitleParagraph("Contributions"))); } if (generateStakeholdersInteractionsSection()) { buildSectionStakeholdersInteractions( chapter.addSection(getSectionTitleParagraph("Stakeholders Interactions"))); } if (generateOrganisationalConstraintsSection()) { buildSectionOrganisationalConstraints( chapter.addSection(getSectionTitleParagraph("Organisational Constraints"))); } if (generateEventSection()) { buildEventsSection(chapter.addSection(getSectionTitleParagraph("Events"))); } chapter.setTriggerNewPage(true); chapter.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
/******************************************************************************************/ private void buildInformationViewChapter(Chapter chapter, Document document) { chapter.setTitle(getChapterTitleParagraph("Information View")); chapter.setTriggerNewPage(true);/*from www . ja v a 2 s . co m*/ String chapterIntro = "The information view gives a structured representation of the information and documents in the " + getProjectName() + " project. It shows what is the informational content of the documents represented in the social view. Information is represented by one or more documents (%itangible by%), and the same document can make tangible multiple information. Moreover, the information view considers composite documents (information) capturing these by means of %ipart of% relations."; chapter.add(createParagraph(chapterIntro)); if (generateInformationViewDiagramSection()) { buildSectionInformationViewDiagram( chapter.addSection(getSectionTitleParagraph("Information View Diagram")), document); chapter.add(Chunk.NEXTPAGE); } if (generateModellingOwnershipSection()) { buildSectionModellingOwnership(chapter.addSection(getSectionTitleParagraph("Modelling Ownership"))); } if (generateRepresentationInformationSection()) { buildSectionRepresentationInformation( chapter.addSection(getSectionTitleParagraph("Representation of Information"))); } if (generateCompositionSection()) { buildSectionComposition(chapter.addSection(getSectionTitleParagraph("Compositions"))); } chapter.setTriggerNewPage(true); chapter.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
/******************************************************************************************/ private void buildAuthorisationViewChapter(Chapter chapter, Document document) { chapter.setTitle(getChapterTitleParagraph("Authorisation View")); String chapterIntro = "The authorisation view shows the permission flow from a stakeholder to another, that is, the authorisations stakeholders grant to others about information, specifying the operations the others can perform over the information. Apart from granting authority on performing operations, a higher authority can be granted, that of further authorising other actors."; chapter.add(createParagraph(chapterIntro)); chapterIntro = "Authorisations start from the information owner. Therefore, in the authorisation view, ownership is preserved and inherited from the information view."; chapter.add(createParagraph(chapterIntro)); if (generateAuthorisationViewDiagramSection()) { buildSectionAuthorisationDiagram( chapter.addSection(getSectionTitleParagraph("Authorisation View Diagram")), document); chapter.add(Chunk.NEXTPAGE);//ww w. j av a 2 s .c om } if (generateAuthorisationFlowSection()) { buildSectionAuthorisationFlow(chapter.addSection(getSectionTitleParagraph("Authorisation Flow"))); } chapter.setTriggerNewPage(true); chapter.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
/******************************************************************************************/ private void buildAnalysisChapter(Chapter chapter, Document document) { chapter.setTitle(getChapterTitleParagraph("Analysis")); String chapterIntro = ""; chapter.add(createParagraph(chapterIntro)); if (generateConsistencyAnalysisSection()) { buildSectionConsistencyAnalysis(chapter.addSection(getSectionTitleParagraph("Consistency Analysis")), document);//from ww w . jav a2 s. c o m } if (generateSecurityAnalysisSection()) { buildSectionSecurityAnalysis(chapter.addSection(getSectionTitleParagraph("Security Analysis"))); } if (generateRiskAnalysisSection()) { buildSectionRiskAnalysis(chapter.addSection(getSectionTitleParagraph("Threat Analysis"))); } chapter.setTriggerNewPage(true); chapter.setComplete(true); }
From source file:eu.geopaparazzi.plugins.pdfexport.PdfExportDialogFragment.java
License:Open Source License
public void processNote(Document document, Note note, int count) throws Exception { String name = Utilities.makeXmlSafe(note.getName()); String form = note.getForm(); DaoImages daoImages = new DaoImages(); if (form != null && form.length() > 0) { JSONObject sectionObject = new JSONObject(form); if (!sectionObject.has(FormUtilities.ATTR_SECTIONNAME)) { return; }//from www .jav a 2 s . c om String sectionName = sectionObject.getString(FormUtilities.ATTR_SECTIONNAME); Anchor anchor = new Anchor(sectionName); anchor.setName(sectionName); Chapter currentChapter = new Chapter(new Paragraph(anchor), count); addEmptyLine(currentChapter, 3); PdfPTable infoTable = new PdfPTable(2); infoTable.setHeaderRows(0); infoTable.setWidthPercentage(90); currentChapter.add(infoTable); addKeyValueToTableRow(infoTable, "Timestamp", new Date(note.getTimeStamp()).toString()); addKeyValueToTableRow(infoTable, "Latitude", note.getLat() + ""); addKeyValueToTableRow(infoTable, "Longitude", note.getLon() + ""); addEmptyLine(currentChapter, 3); List<String> formsNames = TagsManager.getFormNames4Section(sectionObject); for (String formName : formsNames) { Paragraph section = new Paragraph(formName); currentChapter.addSection(section); addEmptyLine(currentChapter, 3); PdfPTable currentTable = new PdfPTable(2); currentTable.setHeaderRows(1); currentTable.setWidthPercentage(90); currentChapter.add(currentTable); JSONObject form4Name = TagsManager.getForm4Name(formName, sectionObject); JSONArray formItems = TagsManager.getFormItems(form4Name); for (int i = 0; i < formItems.length(); i++) { JSONObject formItem = formItems.getJSONObject(i); if (!formItem.has(FormUtilities.TAG_KEY)) { continue; } String type = formItem.getString(FormUtilities.TAG_TYPE); String key = formItem.getString(FormUtilities.TAG_KEY); String value = formItem.getString(FormUtilities.TAG_VALUE); String label = key; if (formItem.has(FormUtilities.TAG_LABEL)) { label = formItem.getString(FormUtilities.TAG_LABEL); } if (type.equals(FormUtilities.TYPE_PICTURES)) { if (value.trim().length() == 0) { continue; } String[] imageIdsSplit = value.split(Note.IMAGES_SEPARATOR); for (String imageId : imageIdsSplit) { Image image = daoImages.getImage(Long.parseLong(imageId)); String imgName = image.getName(); byte[] imageData = daoImages.getImageData(Long.parseLong(imageId)); com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData); Paragraph caption = new Paragraph(imgName); caption.setAlignment(Element.ALIGN_CENTER); PdfPCell keyCell = new PdfPCell(new Phrase(label)); keyCell.setHorizontalAlignment(Element.ALIGN_CENTER); keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE); keyCell.setPadding(10); currentTable.addCell(keyCell); PdfPCell valueCell = new PdfPCell(); valueCell.setHorizontalAlignment(Element.ALIGN_CENTER); valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE); valueCell.setPadding(10); valueCell.addElement(itextImage); valueCell.addElement(caption); currentTable.addCell(valueCell); } } else if (type.equals(FormUtilities.TYPE_MAP)) { if (value.trim().length() == 0) { continue; } String imageId = value.trim(); Image image = daoImages.getImage(Long.parseLong(imageId)); String imgName = image.getName(); byte[] imageData = daoImages.getImageData(Long.parseLong(imageId)); com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData); Paragraph caption = new Paragraph(imgName); caption.setAlignment(Element.ALIGN_CENTER); PdfPCell keyCell = new PdfPCell(new Phrase(label)); keyCell.setHorizontalAlignment(Element.ALIGN_CENTER); keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE); keyCell.setPadding(10); currentTable.addCell(keyCell); PdfPCell valueCell = new PdfPCell(); valueCell.setHorizontalAlignment(Element.ALIGN_CENTER); valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE); valueCell.setPadding(10); valueCell.addElement(itextImage); valueCell.addElement(caption); currentTable.addCell(valueCell); } else if (type.equals(FormUtilities.TYPE_SKETCH)) { if (value.trim().length() == 0) { continue; } String[] imageIdsSplit = value.split(Note.IMAGES_SEPARATOR); for (String imageId : imageIdsSplit) { Image image = daoImages.getImage(Long.parseLong(imageId)); String imgName = image.getName(); byte[] imageData = daoImages.getImageData(Long.parseLong(imageId)); com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData); Paragraph caption = new Paragraph(imgName); caption.setAlignment(Element.ALIGN_CENTER); PdfPCell keyCell = new PdfPCell(new Phrase(label)); keyCell.setHorizontalAlignment(Element.ALIGN_CENTER); keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE); keyCell.setPadding(10); currentTable.addCell(keyCell); PdfPCell valueCell = new PdfPCell(); valueCell.setHorizontalAlignment(Element.ALIGN_CENTER); valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE); valueCell.setPadding(10); valueCell.addElement(itextImage); valueCell.addElement(caption); currentTable.addCell(valueCell); } } else { addKeyValueToTableRow(currentTable, label, value); } } } document.add(currentChapter); document.newPage(); } }
From source file:eu.trentorise.smartcampus.citizenportal.service.PdfCreator.java
private static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("COMUNITA' DELLA VALLAGARINA", catFont); anchor.setName("COMUNITA' DELLA VALLAGARINA"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); catPart.setNumberDepth(0);/*w w w .ja va 2 s. c om*/ Paragraph subPara = new Paragraph("Graduatoria Generale", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.setNumberDepth(0); Anchor phaseClass = new Anchor("Fase: " + phase, smallBold); Anchor state = new Anchor("Stato: Confermata", smallBold); Anchor edFinPer = new Anchor("Edizione: " + edFin.getPeriod(), smallBold); Anchor edFinCat = new Anchor("Categoria: " + edFin.getCategory(), smallBold); Anchor edFinTool = new Anchor("Strumento: " + edFin.getTool(), smallBold); // subCatPart.add(new Paragraph("Graduatoria: Generale")); subCatPart.add(new Paragraph(phaseClass)); subCatPart.add(new Paragraph(state)); subCatPart.add(new Paragraph(edFinPer)); subCatPart.add(new Paragraph(edFinCat)); subCatPart.add(new Paragraph(edFinTool)); // add a list // createList(subCatPart); Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 1); 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", 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); }