Example usage for com.itextpdf.text Anchor setName

List of usage examples for com.itextpdf.text Anchor setName

Introduction

In this page you can find the example usage for com.itextpdf.text Anchor setName.

Prototype

public void setName(final String name) 

Source Link

Document

Sets the name of this Anchor.

Usage

From source file:drugsupplychain.neu.css.gui.common.distributor.GenerateBillPDF.java

/**
 * add content to the page//  w  w w.j a va 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.avans.ivh5.shared.util.generateInvoicePDF.java

private static void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("Factuur12", catFont);
    anchor.setName("Factuur");

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    // add a list
    //createList(subCatPart);
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, (int) 1);
    catPart.add(paragraph);//from   w  ww . j  av a 2 s .  c  o  m

    // add a table
    createTable(catPart);

    createTable2(catPart);

    createTable3(catPart);

    createTable4(catPart);

    createTable5(catPart);

    // now add all this to the document
    document.add(catPart);

}

From source file:Ekon.zamestnanecToPDF.java

/**
 * pridani titulku/*  w  ww. j av a  2 s  .com*/
 *
 * @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.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;
        }/*www .j ava2 s  . c o m*/
        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  .j  a  v  a 2s  . c  o m
    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);
}

From source file:generadorPDF.generarPDF.java

private static void addContent(Document document, Socio sociox, Resolucion res) 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"));
       subCatPart.add(new Paragraph(sociox.getApellido() + sociox.getNombre() + sociox.getLegajo_socio()));

       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);/*  w  ww  . jav a2 s.  co  m*/
       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", 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:klasy.PdfFiles.java

public 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.j a  v  a  2 s  .c om
    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", 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:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addDevicePage(Document document) {
    Anchor anchor = new Anchor("Device Information");
    anchor.setName("Device Information");
    Chapter chap = new Chapter(new Paragraph(anchor), 1);

    Paragraph subpara = new Paragraph("Device Information", HeadingFont);
    subpara.setAlignment(Paragraph.ALIGN_CENTER);
    addEmptyLine(subpara, 1);// w w  w . java2s . c om
    createTableRowFormat(subpara, "DeviceBasicInfo");

    try {
        document.add(subpara);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:negotiation.Contract.FormContractPdf.java

public static void addContents(Document document) throws DocumentException {
    Anchor anchor = new Anchor("Contract", catFont);
    anchor.setName("Contract");

    Paragraph para = new Paragraph();
    para.add(new Paragraph("1. General", subFont));
    String para1 = ContractContents.addGeneral("userA", "ManagerD", "aws", "2014", "2015");
    para.add(para1);//from   w  ww.  j a va  2 s . c o  m
    addEmptyLine(para, 1);

    para.add(new Paragraph("2. Scope & description of the service", subFont));
    String para2 = ContractContents.addDescription("aws-ec2", "www.aws.com", "computing service");
    para.add(para2);

    para.add(new Paragraph("3. Service hours & exceptions", subFont));
    String para3 = ContractContents.addTime("2014", "2015");
    para.add(para3);

    para.add(new Paragraph("4. Service components & dependencies", subFont));
    String para4 = ContractContents.addComponents("aws-ec2", "computing service");
    para.add(para4);

    para.add(new Paragraph("5. Support", subFont));
    String para5 = ContractContents.addSupport("University of Manchester", "Mon-Fri: 9:00am - 5:00pm");
    para.add(para5);

    para.add(new Paragraph("5.1 Incident handling", smallBold));
    String para6 = ContractContents.addHandling("Incident handling ...");
    para.add(para6);

    para.add(new Paragraph("5.2 Fulfillment of service requests", smallBold));
    String para7 = ContractContents.addFulfillment("Fulfillment ...");
    para.add(para7);

    para.add(new Paragraph("6. Service level targets", subFont));
    String para8 = AwsEc2ContractContents.addTargets();
    //String para8 = ContractContents.addTargets("Availability", "24 hours");
    para.add(para8);

    para.add(new Paragraph("7. Limitations & constaints", subFont));
    String para9 = AwsEc2ContractContents.addConstaints();
    //String para9 = ContractContents.addConstaints("Wordload limits...");
    para.add(para9);

    para.add(new Paragraph("8. Communication, reporting & escalation", subFont));
    para.add(new Paragraph("8.1 General communication", smallBold));
    String para10 = ContractContents.addContacts("123", "456", "789");
    para.add(para10);

    para.add(new Paragraph("8.2 Regular reporting", smallBold));
    String para11 = ContractContents.addReport("20150520", "regular check", "once a week",
            "University of Manchester.");
    para.add(para11);

    para.add(new Paragraph("8.3 SLA violations", smallBold));
    String para12 = AwsEc2ContractContents.addViolations();
    //String para12 = ContractContents.addViolations("Penalty required when performance cannot rearch agreed SLAs.");
    para.add(para12);

    para.add(new Paragraph("8.4 Escalation & complaints", smallBold));
    String para13 = ContractContents
            .addEscalation("Please contact University of Manchester via provided email.");
    para.add(para13);

    para.add(new Paragraph("9. Information security & data protection", subFont));
    String para14 = ContractContents
            .addProtection("All the data should be kept within University of Manchester network domain.");
    para.add(para14);

    para.add(new Paragraph("10. Additional responsibilities of the service provider", subFont));
    String para15 = ContractContents.addProviderResp("Provider should ...");
    para.add(para15);

    para.add(new Paragraph("11. Customer responsibilities", subFont));
    String para16 = ContractContents.addCustomerResp("Customer should ...");
    para.add(para16);

    para.add(new Paragraph("12. Review", subFont));
    String para17 = ContractContents.addReview("Review should be taken...");
    para.add(para17);

    para.add(new Paragraph("13. Glossary of terms", subFont));
    String para18 = AwsEc2ContractContents.addTerms();
    //String para18 = ContractContents.addTerms("aws-ec2", "computing services");
    para.add(para18);

    para.add(new Paragraph("14. Document control", subFont));
    String para19 = ContractContents.addControl(55555, "SLA on" + glo_service, "University of Manchester",
            "University of Manchester", "1.0", "2015", "2016", "No change so far");
    para.add(para19);

    document.add(para);
}

From source file:org.tvd.thptty.management.util.Report.java

private 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);/* w ww.  jav a 2 s  .c  o m*/
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);

    paragraph.setFont(smallBold);
    // Add a table
    paragraph.add(createTable(subCatPart));
    subCatPart.add(paragraph);

    // 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);

}