/** * Get the value as a text string; i.e., a string encoded in UTF-16BE * or PDFDocEncoding. Simple latin alpha-numeric characters are preserved in * both these encodings. * @return the text string value * @throws IOException */ public String getTextStringValue() throws IOException { return PDFStringUtil.asTextString(getStringValue()); }
/** * Get the value as a text string; i.e., a string encoded in UTF-16BE * or PDFDocEncoding. Simple latin alpha-numeric characters are preserved in * both these encodings. * @return the text string value * @throws IOException */ public String getTextStringValue() throws IOException { return PDFStringUtil.asTextString(getStringValue()); }
/** * Get the value as a text string; i.e., a string encoded in UTF-16BE * or PDFDocEncoding. Simple latin alpha-numeric characters are preserved in * both these encodings. * @return the text string value * @throws IOException */ public String getTextStringValue() throws IOException { return PDFStringUtil.asTextString(getStringValue()); }
/** * get the value as a String. Will return null if the object * isn't a STRING, NAME, or KEYWORD. This method will <b>NOT</b> * convert a NUMBER to a String. */ public String getStringValue() throws IOException { if (type == INDIRECT) { return dereference().getStringValue(); } else if (type == STRING || type == NAME || type == KEYWORD) { return (String)value; } // wrong type return null; }
/** * get the value as a String. Will return null if the object * isn't a STRING, NAME, or KEYWORD. This method will <b>NOT</b> * convert a NUMBER to a String. */ public String getStringValue() throws IOException { if (type == INDIRECT) { return dereference().getStringValue(); } else if (type == STRING || type == NAME || type == KEYWORD) { return (String)value; } // wrong type return null; }
public static boolean isLastFilter(PDFObject dict, Set<String> filters) throws IOException { PDFObject filter = dict.getDictRef("Filter"); if (filter == null) { return false; } else if (filter.getType() == PDFObject.NAME) { return filters.contains(filter.getStringValue()); } else { final PDFObject[] ary = filter.getArray(); return filters.contains(ary[ary.length - 1].getStringValue()); } }
/** * Identify whether a given PDFObject identifies itself as a crossreference * stream * @param header the object to test * @return whether the object is an xref stream * @throws IOException if there's a problem reading the header */ private boolean isXrefStream(PDFObject header) throws IOException { return header.getType() == PDFObject.STREAM && "XRef".equals(header.getDictRef("Type").getStringValue()); }
/** * Get a destination, given a name. This means the destination is in * the root node's dests dictionary. */ private static PDFObject getDestFromName(PDFObject name, PDFObject root) throws IOException { // find the dests object in the root node PDFObject dests = root.getDictRef("Dests"); if (dests != null) { // find this name in the dests dictionary return dests.getDictRef(name.getStringValue()); } // not found return null; }
/** * Get a destination, given a name. This means the destination is in * the root node's dests dictionary. */ private static PDFObject getDestFromName(PDFObject name, PDFObject root) throws IOException { // find the dests object in the root node PDFObject dests = root.getDictRef("Dests"); if (dests != null) { // find this name in the dests dictionary return dests.getDictRef(name.getStringValue()); } // not found return null; }
/** * Get a destination, given a name. This means the destination is in * the root node's dests dictionary. */ private static PDFObject getDestFromName(PDFObject name, PDFObject root) throws IOException { // find the dests object in the root node PDFObject dests = root.getDictRef("Dests"); if (dests != null) { // find this name in the dests dictionary return dests.getDictRef(name.getStringValue()); } // not found return null; }
/** * The name of the Crypt filter to apply * @param param the parameters to the Crypt filter * @return the name of the crypt filter to apply * @throws IOException if there's a problem reading the objects */ private static String getCryptFilterName(PDFObject param) throws IOException { String cfName = PDFDecrypterFactory.CF_IDENTITY; if (param != null) { final PDFObject nameObj = param.getDictRef("Name"); if (nameObj != null && nameObj.getType() == PDFObject.NAME) { cfName = nameObj.getStringValue(); } } return cfName; }
/** * Insert a PDF object into the command stream. The object must * either be an Image or a Form, which is a set of PDF commands * in a stream. * @param obj the object to insert, an Image or a Form. */ private void doXObject(PDFObject obj) throws IOException { String type = obj.getDictRef("Subtype").getStringValue(); if (type == null) { type = obj.getDictRef ("S").getStringValue (); } if (type.equals("Image")) { doImage(obj); } else if (type.equals("Form")) { doForm(obj); } else { throw new PDFParseException("Unknown XObject subtype: " + type); } }
/** * Insert a PDF object into the command stream. The object must * either be an Image or a Form, which is a set of PDF commands * in a stream. * @param obj the object to insert, an Image or a Form. */ private void doXObject(PDFObject obj) throws IOException { String type = obj.getDictRef("Subtype").getStringValue(); if (type == null) { type = obj.getDictRef ("S").getStringValue (); } if (type.equals("Image")) { doImage(obj); } else if (type.equals("Form")) { doForm(obj); } else { throw new PDFParseException("Unknown XObject subtype: " + type); } }
/** * Insert a PDF object into the command stream. The object must * either be an Image or a Form, which is a set of PDF commands * in a stream. * @param obj the object to insert, an Image or a Form. */ private void doXObject(PDFObject obj) throws IOException { String type = obj.getDictRef("Subtype").getStringValue(); if (type == null) { type = obj.getDictRef ("S").getStringValue (); } if (type.equals("Image")) { doImage(obj); } else if (type.equals("Form")) { doForm(obj); } else { throw new PDFParseException("Unknown XObject subtype: " + type); } }
/** * returns true only if this object is a DICTIONARY or a * STREAM, and the "Type" entry in the dictionary matches a * given value. * @param match the expected value for the "Type" key in the * dictionary * @return whether the dictionary is of the expected type */ public boolean isDictType(String match) throws IOException { if (type == INDIRECT) { return dereference().isDictType(match); } else if (type != DICTIONARY && type != STREAM) { return false; } PDFObject obj= getDictRef("Type"); return obj != null && obj.getStringValue().equals(match); }
/** * returns true only if this object is a DICTIONARY or a * STREAM, and the "Type" entry in the dictionary matches a * given value. * @param match the expected value for the "Type" key in the * dictionary * @return whether the dictionary is of the expected type */ public boolean isDictType(String match) throws IOException { if (type == INDIRECT) { return dereference().isDictType(match); } else if (type != DICTIONARY && type != STREAM) { return false; } PDFObject obj = getDictRef("Type"); return obj != null && obj.getStringValue().equals(match); }
/** * returns true only if this object is a DICTIONARY or a * STREAM, and the "Type" entry in the dictionary matches a * given value. * @param match the expected value for the "Type" key in the * dictionary * @return whether the dictionary is of the expected type */ public boolean isDictType(String match) throws IOException { if (type == INDIRECT) { return dereference().isDictType(match); } else if (type != DICTIONARY && type != STREAM) { return false; } PDFObject obj= getDictRef("Type"); return obj != null && obj.getStringValue().equals(match); }
/** * Get a CMap, given a PDF object containing one of the following: * a string name of a known CMap * a stream containing a CMap definition */ public static PDFCMap getCMap(PDFObject map) throws IOException { if (map.getType() == PDFObject.NAME) { return getCMap(map.getStringValue()); } else if (map.getType() == PDFObject.STREAM) { return parseCMap(map); } else { throw new IOException("CMap type not Name or Stream!"); } }
/** * Get a CMap, given a PDF object containing one of the following: * a string name of a known CMap * a stream containing a CMap definition */ public static PDFCMap getCMap(PDFObject map) throws IOException { if (map.getType() == PDFObject.NAME) { return getCMap(map.getStringValue()); } else if (map.getType() == PDFObject.STREAM) { return parseCMap(map); } else { throw new IOException("CMap type not Name or Stream!"); } }
/** * Get a CMap, given a PDF object containing one of the following: * a string name of a known CMap * a stream containing a CMap definition */ public static PDFCMap getCMap(PDFObject map) throws IOException { if (map.getType() == PDFObject.NAME) { return getCMap(map.getStringValue()); } else if (map.getType() == PDFObject.STREAM) { return parseCMap(map); } else { throw new IOException("CMap type not Name or Stream!"); } }