use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class BeginMarkedContentSequenceWithProperties method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
COSName tag = null;
COSDictionary properties = null;
for (COSBase argument : arguments) {
if (argument instanceof COSName) {
tag = (COSName) argument;
} else if (argument instanceof COSDictionary) {
properties = (COSDictionary) argument;
}
}
context.beginMarkedContentSequence(tag, properties);
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class SetStrokingColorSpace method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
COSBase base = arguments.get(0);
if (!(base instanceof COSName)) {
return;
}
PDColorSpace cs = context.getResources().getColorSpace((COSName) base);
context.getGraphicsState().setStrokingColorSpace(cs);
context.getGraphicsState().setStrokingColor(cs.getInitialColor());
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class SetNonStrokingColorSpace method process.
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
COSName name = (COSName) arguments.get(0);
PDColorSpace cs = context.getResources().getColorSpace(name);
context.getGraphicsState().setNonStrokingColorSpace(cs);
context.getGraphicsState().setNonStrokingColor(cs.getInitialColor());
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class PDSimpleFont method readEncoding.
/**
* Reads the Encoding from the Font dictionary or the embedded or substituted font file.
* Must be called at the end of any subclass constructors.
*
* @throws IOException if the font file could not be read
*/
protected void readEncoding() throws IOException {
COSBase encoding = dict.getDictionaryObject(COSName.ENCODING);
if (encoding != null) {
if (encoding instanceof COSName) {
COSName encodingName = (COSName) encoding;
this.encoding = Encoding.getInstance(encodingName);
if (this.encoding == null) {
Log.w("PdfBox-Android", "Unknown encoding: " + encodingName.getName());
// fallback
this.encoding = readEncodingFromFont();
}
} else if (encoding instanceof COSDictionary) {
COSDictionary encodingDict = (COSDictionary) encoding;
Encoding builtIn = null;
Boolean symbolic = getSymbolicFlag();
boolean isFlaggedAsSymbolic = symbolic != null && symbolic;
COSName baseEncoding = encodingDict.getCOSName(COSName.BASE_ENCODING);
boolean hasValidBaseEncoding = baseEncoding != null && Encoding.getInstance(baseEncoding) != null;
if (!hasValidBaseEncoding && isFlaggedAsSymbolic) {
builtIn = readEncodingFromFont();
}
if (symbolic == null) {
symbolic = false;
}
this.encoding = new DictionaryEncoding(encodingDict, !symbolic, builtIn);
}
} else {
this.encoding = readEncodingFromFont();
}
// normalise the standard 14 name, e.g "Symbol,Italic" -> "Symbol"
String standard14Name = Standard14Fonts.getMappedFontName(getName());
// assign the glyph list based on the font
if ("ZapfDingbats".equals(standard14Name)) {
glyphList = GlyphList.getZapfDingbats();
} else {
// StandardEncoding and Symbol are in the AGL
glyphList = GlyphList.getAdobeGlyphList();
}
}
use of com.tom_roush.pdfbox.cos.COSName in project PdfBox-Android by TomRoush.
the class PDType0Font method fetchCMapUCS2.
/**
* Fetches the corresponding UCS2 CMap if the font's CMap is predefined.
*/
private void fetchCMapUCS2() throws IOException {
// if the font is composite and uses a predefined cmap (excluding Identity-H/V)
// or whose descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
// Adobe-Korea1 character collection:
COSName name = dict.getCOSName(COSName.ENCODING);
if (isCMapPredefined && !(name == COSName.IDENTITY_H || name == COSName.IDENTITY_V) || isDescendantCJK) {
// a) Map the character code to a CID using the font's CMap
// b) Obtain the ROS from the font's CIDSystemInfo
// c) Construct a second CMap name by concatenating the ROS in the format "R-O-UCS2"
// d) Obtain the CMap with the constructed name
// e) Map the CID according to the CMap from step d), producing a Unicode value
// todo: not sure how to interpret the PDF spec here, do we always override? or only when Identity-H/V?
String strName = null;
if (isDescendantCJK) {
strName = descendantFont.getCIDSystemInfo().getRegistry() + "-" + descendantFont.getCIDSystemInfo().getOrdering() + "-" + descendantFont.getCIDSystemInfo().getSupplement();
} else if (name != null) {
strName = name.getName();
}
// try to find the corresponding Unicode (UC2) CMap
if (strName != null) {
CMap prdCMap = CMapManager.getPredefinedCMap(strName);
String ucs2Name = prdCMap.getRegistry() + "-" + prdCMap.getOrdering() + "-UCS2";
cMapUCS2 = CMapManager.getPredefinedCMap(ucs2Name);
}
}
}
Aggregations