Example usage for com.itextpdf.text.pdf PdfArray getPdfObject

List of usage examples for com.itextpdf.text.pdf PdfArray getPdfObject

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfArray getPdfObject.

Prototype

public PdfObject getPdfObject(final int idx) 

Source Link

Document

Returns the PdfObject with the specified index.

Usage

From source file:de.gbv.marginalia.Marginalia.java

License:Open Source License

public static void dumpArray(PdfArray a) {
    if (a == null)
        return;//  w  w  w .  j av a2 s  .  c om
    for (int i = 0; i < a.size(); i++) {
        System.out.println(i + a.getPdfObject(i).toString());
    }
}

From source file:mkl.testarea.itext5.pdfcleanup.PdfCleanUpContentOperator.java

License:Open Source License

/**
 * Example.//from   w w w  .  ja  v  a  2  s.co  m
 *      TJ = [(h) 3 4 (q) 7 (w) (e)]
 *      Result = {0:0, 1:7, 2:7, 3:0, 4:0}
 *
 * @return Map whose key is an ordinal number of the string in the TJ array and value
 *         is the position adjustment.
 */
private Map<Integer, Float> structureTJarray(PdfArray array) {
    Map<Integer, Float> structuredTJoperands = new HashMap<Integer, Float>();

    if (array.size() == 0) {
        return structuredTJoperands;
    }

    Integer previousStrNum = 0;
    structuredTJoperands.put(previousStrNum, 0f);

    for (int i = 0; i < array.size(); ++i) {
        PdfObject currentObj = array.getPdfObject(i);

        if (currentObj instanceof PdfString && ((PdfString) currentObj).toUnicodeString().length() > 0) {
            ++previousStrNum;
            structuredTJoperands.put(previousStrNum, 0f);
        } else {
            Float oldOffset = structuredTJoperands.get(previousStrNum);
            structuredTJoperands.put(previousStrNum, oldOffset + ((PdfNumber) currentObj).floatValue());
        }
    }

    return structuredTJoperands;
}