use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDStream method setFilters.
/**
* This will set the filters that are part of this stream.
*
* @param filters The filters that are part of this stream.
*/
public void setFilters(List<COSName> filters) {
COSBase obj = COSArrayList.converterToCOSArray(filters);
stream.setItem(COSName.FILTER, obj);
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDStream method getFileFilters.
/**
* This will get the list of filters that are associated with this stream.
* Or null if there are none.
*
* @return A list of all encoding filters to apply to this stream.
*/
public List<String> getFileFilters() {
List<String> retval = null;
COSBase filters = stream.getDictionaryObject(COSName.F_FILTER);
if (filters instanceof COSName) {
COSName name = (COSName) filters;
retval = new COSArrayList<String>(name.getName(), name, stream, COSName.F_FILTER);
} else if (filters instanceof COSArray) {
retval = COSArrayList.convertCOSNameCOSArrayToList((COSArray) filters);
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDNumberTreeNode method getNumbers.
/**
* This will return a map of numbers. The key will be a java.lang.Integer, the value will
* depend on where this class is being used.
*
* @return A map of COS objects.
*
* @throws IOException If there is a problem creating the values.
*/
public Map<Integer, COSObjectable> getNumbers() throws IOException {
Map<Integer, COSObjectable> indices = null;
COSBase numBase = node.getDictionaryObject(COSName.NUMS);
if (numBase instanceof COSArray) {
COSArray numbersArray = (COSArray) numBase;
indices = new HashMap<Integer, COSObjectable>();
for (int i = 0; i < numbersArray.size(); i += 2) {
COSBase base = numbersArray.getObject(i);
if (!(base instanceof COSInteger)) {
Log.e("PdfBox-Android", "page labels ignored, index " + i + " should be a number, but is " + base);
return null;
}
COSInteger key = (COSInteger) base;
COSBase cosValue = numbersArray.getObject(i + 1);
indices.put(key.intValue(), cosValue == null ? null : convertCOSToPD(cosValue));
}
indices = Collections.unmodifiableMap(indices);
}
return indices;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDPage method getViewports.
/**
* Get the viewports.
*
* @return a list of viewports or null if there is no /VP entry.
*/
public List<PDViewportDictionary> getViewports() {
COSBase base = page.getDictionaryObject(COSName.VP);
if (!(base instanceof COSArray)) {
return null;
}
COSArray array = (COSArray) base;
List<PDViewportDictionary> viewports = new ArrayList<PDViewportDictionary>();
for (int i = 0; i < array.size(); ++i) {
COSBase base2 = array.getObject(i);
if (base2 instanceof COSDictionary) {
viewports.add(new PDViewportDictionary((COSDictionary) base2));
} else {
Log.w("PdfBox-Android", "Array element " + base2 + " is skipped, must be a (viewport) dictionary");
}
}
return viewports;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDPage method getContentStreams.
/**
* Returns the content streams which make up this page.
*
* @return content stream iterator
*/
public Iterator<PDStream> getContentStreams() {
List<PDStream> streams = new ArrayList<PDStream>();
COSBase base = page.getDictionaryObject(COSName.CONTENTS);
if (base instanceof COSStream) {
streams.add(new PDStream((COSStream) base));
} else if (base instanceof COSArray && ((COSArray) base).size() > 0) {
COSArray array = (COSArray) base;
for (int i = 0; i < array.size(); i++) {
COSStream stream = (COSStream) array.getObject(i);
streams.add(new PDStream(stream));
}
}
return streams.iterator();
}
Aggregations