Example usage for com.itextpdf.text.pdf PdfName A

List of usage examples for com.itextpdf.text.pdf PdfName A

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfName A.

Prototype

PdfName A

To view the source code for com.itextpdf.text.pdf PdfName A.

Click Source Link

Document

A name

Usage

From source file:com.poet.ar.remover.AnnotationRemover.java

/**
 * remove annotation that matches keywords
 *
 * @param page/*  w  w w  . j a v a 2  s.  c  o  m*/
 * @return count of removed annotations
 */
private static int doRemoveAnnotation(PdfDictionary page) {

    // all annotations in page i
    PdfArray annoArray = page.getAsArray(PdfName.ANNOTS);
    List<Integer> willRemovedIx = new ArrayList<Integer>();

    if (annoArray != null) {

        PdfDictionary annotation = null;
        PdfDictionary a = null;
        PdfString uri = null;
        for (int i = 0; i < annoArray.size(); i++) {

            annotation = annoArray.getAsDict(i);

            if (annotation == null) {
                continue;
            }

            a = annotation.getAsDict(PdfName.A);

            if (a == null) {
                continue;
            }

            uri = a.getAsString(PdfName.URI);

            if (uri == null) {
                continue;
            }

            String uriStr = uri.toString().trim();

            if (keywords.contains(uriStr)) {
                willRemovedIx.add(i);
            }

        }

        int i = 0;
        for (Integer ix : willRemovedIx) {
            annoArray.remove(ix - i++);
        }

    }

    return willRemovedIx.size();
}

From source file:org.orbisgis.core.renderer.PdfRendererWithAttributes.java

License:Open Source License

@Override
public void beginFeature(long id, DataSource sds) {
    int fieldNameIndex;
    try {/* w  w  w.j a  v  a2  s .  c  om*/
        fieldNameIndex = sds.getFieldIndexByName(fieldName);
    } catch (DriverException ex) {
        Logger.getLogger(PdfRendererWithAttributes.class.getName()).log(Level.SEVERE, null, ex);
        Logger.getLogger("Field name used for attributes does not exist: by default, we use feature + id");
        fieldNameIndex = -1;

    }

    try {
        String attributeName;

        if (fieldNameIndex > -1) {
            attributeName = sds.getFieldValue(id, fieldNameIndex).toString();
        } else {
            attributeName = "feature " + (id + 1);
        }

        PdfStructureElement e = new PdfStructureElement(top, new PdfName(attributeName));
        PdfDictionary userProperties = new PdfDictionary();
        userProperties.put(PdfName.O, PdfName.USERPROPERTIES);
        PdfArray properties = new PdfArray();

        for (int i = 0; i < sds.getFieldCount(); i++) {
            if ((sds.getFieldType(i).getTypeCode() & Type.GEOMETRY) == 0) {
                PdfDictionary property = new PdfDictionary();
                property.put(PdfName.N, new PdfString(sds.getFieldName(i)));
                Value v = sds.getFieldValue(id, i);
                property.put(PdfName.V, new PdfString(v.toString()));
                properties.add(property);
            }
        }

        userProperties.put(PdfName.P, properties);
        e.put(PdfName.A, userProperties);

        pTemp = cb.createTemplate(width, height);
        cb.beginMarkedContentSequence(e);

    } catch (DriverException ex) {
        Logger.getLogger(PdfRendererWithAttributes.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.orbisgis.core_export.PdfRendererWithAttributes.java

License:Open Source License

@Override
public void beginFeature(long id, ResultSet rs) {
    try {/*w  w  w. j  a va 2  s  .  c  o m*/
        String attributeName;
        attributeName = rs.getString(fieldName);
        PdfStructureElement e = new PdfStructureElement(top, new PdfName(attributeName));
        PdfDictionary userProperties = new PdfDictionary();
        userProperties.put(PdfName.O, PdfName.USERPROPERTIES);
        PdfArray properties = new PdfArray();
        SpatialResultSetMetaData metaData = rs.getMetaData().unwrap(SpatialResultSetMetaData.class);

        int geometryField = metaData.getFirstGeometryFieldIndex();
        PdfDictionary property = new PdfDictionary();
        property.put(PdfName.N, new PdfString(metaData.getColumnName(geometryField)));
        property.put(PdfName.V, new PdfString(rs.getString(geometryField)));
        properties.add(property);

        userProperties.put(PdfName.P, properties);
        e.put(PdfName.A, userProperties);

        pTemp = cb.createTemplate(width, height);
        cb.beginMarkedContentSequence(e);

    } catch (SQLException ex) {
        Logger.getLogger(PdfRendererWithAttributes.class.getName()).log(Level.SEVERE, null, ex);
    }
}