Example usage for com.lowagie.text.pdf PdfName O

List of usage examples for com.lowagie.text.pdf PdfName O

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfName O.

Prototype

PdfName O

To view the source code for com.lowagie.text.pdf PdfName O.

Click Source Link

Document

A name

Usage

From source file:net.sf.jasperreports.engine.export.JRPdfExporterTagHelper.java

License:Open Source License

protected void createSpanTags(JRPrintElement element, PdfStructureElement parentTag) {
    int colSpan = 0;
    int rowSpan = 0;
    try {//from w ww  .ja v  a 2  s.  co m
        colSpan = Integer.valueOf(element.getPropertiesMap().getProperty(PROPERTY_TAG_COLSPAN)).intValue();
    } catch (NumberFormatException e) {
        try {
            colSpan = Integer
                    .valueOf(element.getPropertiesMap().getProperty(JRCellContents.PROPERTY_COLUMN_SPAN))
                    .intValue();
        } catch (NumberFormatException ex) {
        }
    }
    try {
        rowSpan = Integer.valueOf(element.getPropertiesMap().getProperty(PROPERTY_TAG_ROWSPAN)).intValue();
    } catch (NumberFormatException e) {
        try {
            rowSpan = Integer.valueOf(element.getPropertiesMap().getProperty(JRCellContents.PROPERTY_ROW_SPAN))
                    .intValue();
        } catch (NumberFormatException ex) {
        }
    }
    if (colSpan > 1 || rowSpan > 1) {
        PdfArray a = new PdfArray();
        PdfDictionary dict = new PdfDictionary();
        if (colSpan > 1) {
            dict.put(new PdfName("ColSpan"), new PdfNumber(colSpan));
        }
        if (rowSpan > 1) {
            dict.put(new PdfName("RowSpan"), new PdfNumber(rowSpan));
        }
        dict.put(PdfName.O, new PdfName("Table"));
        a.add(dict);
        parentTag.put(PdfName.A, a);
    }
}

From source file:questions.markedcontent.ObjectData.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A5.rotate());
    try {//from   www .j a  v a 2 s .c o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        writer.setTagged();

        document.open();
        PdfContentByte cb = writer.getDirectContent();
        PdfStructureTreeRoot tree = writer.getStructureTreeRoot();
        PdfStructureElement se = new PdfStructureElement(tree, new PdfName("Figure"));
        PdfStructureElement element = new PdfStructureElement(se, new PdfName("Element"));
        PdfDictionary userproperties = new PdfDictionary();
        userproperties.put(PdfName.O, PdfName.USERPROPERTIES);
        userproperties.put(PdfName.S, new PdfName("Figure"));
        PdfArray properties = new PdfArray();
        PdfDictionary property1 = new PdfDictionary();
        property1.put(PdfName.N, new PdfString("Name1"));
        property1.put(PdfName.V, new PdfString("Value1"));
        properties.add(property1);
        PdfDictionary property2 = new PdfDictionary();
        property2.put(PdfName.N, new PdfString("Name2"));
        property2.put(PdfName.V, new PdfString("Value2"));
        properties.add(property2);
        PdfDictionary property3 = new PdfDictionary();
        property3.put(PdfName.N, new PdfString("Name3"));
        property3.put(PdfName.V, new PdfString("Value3"));
        properties.add(property3);
        userproperties.put(PdfName.P, properties);
        element.put(PdfName.A, userproperties);

        PdfLayer lay1 = new PdfLayer("My object", writer);

        cb.beginMarkedContentSequence(element);
        cb.beginLayer(lay1);
        cb.setColorFill(Color.BLUE);
        cb.rectangle(50, 50, 200, 200);
        cb.fill();
        cb.endLayer();
        cb.endMarkedContentSequence();

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }

    document.close();

}