use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDType3Font method getCharProc.
/**
* Returns the stream of the glyph for the given character code
*
* @param code character code
* @return the stream to be used to render the glyph
*/
public PDType3CharProc getCharProc(int code) {
String name = getEncoding().getName(code);
COSBase base = getCharProcs().getDictionaryObject(COSName.getPDFName(name));
if (base instanceof COSStream) {
return new PDType3CharProc(this, (COSStream) base);
}
return null;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDType3Font method getFontBBox.
/**
* This will get the fonts bounding box from its dictionary.
*
* @return The fonts bounding box.
*/
public PDRectangle getFontBBox() {
COSBase base = dict.getDictionaryObject(COSName.FONT_BBOX);
PDRectangle retval = null;
if (base instanceof COSArray) {
retval = new PDRectangle((COSArray) base);
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDFontDescriptor method getFontFile.
/**
* A stream containing a Type 1 font program.
*
* @return A stream containing a Type 1 font program.
*/
public PDStream getFontFile() {
PDStream retval = null;
COSBase obj = dic.getDictionaryObject(COSName.FONT_FILE);
if (obj instanceof COSStream) {
retval = new PDStream((COSStream) obj);
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDCIDFont method readWidths.
private void readWidths() {
widths = new HashMap<Integer, Float>();
COSBase wBase = dict.getDictionaryObject(COSName.W);
if (wBase instanceof COSArray) {
COSArray wArray = (COSArray) wBase;
int size = wArray.size();
int counter = 0;
while (counter < size) {
COSNumber firstCode = (COSNumber) wArray.getObject(counter++);
COSBase next = wArray.getObject(counter++);
if (next instanceof COSArray) {
COSArray array = (COSArray) next;
int startRange = firstCode.intValue();
int arraySize = array.size();
for (int i = 0; i < arraySize; i++) {
COSNumber width = (COSNumber) array.getObject(i);
widths.put(startRange + i, width.floatValue());
}
} else {
COSNumber secondCode = (COSNumber) next;
COSNumber rangeWidth = (COSNumber) wArray.getObject(counter++);
int startRange = firstCode.intValue();
int endRange = secondCode.intValue();
float width = rangeWidth.floatValue();
for (int i = startRange; i <= endRange; i++) {
widths.put(i, width);
}
}
}
}
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class MergeAcroFormsTest method compareFieldProperties.
private void compareFieldProperties(PDField sourceField, PDField toBeComapredField) {
// List of keys for comparison
// Don't include too complex properties such as AP as this will fail the test because
// of a stack overflow when
final String[] keys = { "FT", "T", "TU", "TM", "Ff", "V", "DV", "Opts", "TI", "I", "Rect", "DA" };
COSDictionary sourceFieldCos = sourceField.getCOSObject();
COSDictionary toBeComparedCos = toBeComapredField.getCOSObject();
for (String key : keys) {
COSBase sourceBase = sourceFieldCos.getDictionaryObject(key);
COSBase toBeComparedBase = toBeComparedCos.getDictionaryObject(key);
if (sourceBase != null) {
assertEquals("The content of the field properties shall be the same", sourceBase.toString(), toBeComparedBase.toString());
} else {
assertNull("If the source property is null the compared property shall be null too", toBeComparedBase);
}
}
}
Aggregations