/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfDictionary</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolvedto a direct object. * If it is a <CODE>PdfDictionary</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfDictionary</CODE> object, * or <CODE>null</CODE> */ public PdfDictionary getAsDict(final int idx) { PdfDictionary dict = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isDictionary()) dict = (PdfDictionary) orig; return dict; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfArray</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfArray</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfArray</CODE> object, * or <CODE>null</CODE> */ public PdfArray getAsArray(final int idx) { PdfArray array = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isArray()) array = (PdfArray) orig; return array; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfString</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfString</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfString</CODE> object, * or <CODE>null</CODE> */ public PdfString getAsString(final int idx) { PdfString string = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isString()) string = (PdfString) orig; return string; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfBoolean</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfBoolean</CODE>, it is cast down and returned as * such. Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfBoolean</CODE> object, * or <CODE>null</CODE> */ public PdfBoolean getAsBoolean(final int idx) { PdfBoolean bool = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isBoolean()) bool = (PdfBoolean) orig; return bool; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfString</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfString</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfString</CODE> object, * or <CODE>null</CODE> */ public PdfString getAsString(final int idx) { PdfString string = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isString()) string = (PdfString) orig; return string; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfBoolean</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfBoolean</CODE>, it is cast down and returned as * such. Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfBoolean</CODE> object, * or <CODE>null</CODE> */ public PdfBoolean getAsBoolean(final int idx) { PdfBoolean bool = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isBoolean()) bool = (PdfBoolean) orig; return bool; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfName</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfName</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfName</CODE> object, * or <CODE>null</CODE> */ public PdfName getAsName(final int idx) { PdfName name = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isName()) name = (PdfName) orig; return name; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfStream</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfStream</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfStream</CODE> object, * or <CODE>null</CODE> */ public PdfStream getAsStream(final int idx) { PdfStream stream = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isStream()) stream = (PdfStream) orig; return stream; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfDictionary</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolvedto a direct object. * If it is a <CODE>PdfDictionary</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfDictionary</CODE> object, * or <CODE>null</CODE> */ public PdfDictionary getAsDict(final int idx) { PdfDictionary dict = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isDictionary()) dict = (PdfDictionary) orig; return dict; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfStream</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfStream</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfStream</CODE> object, * or <CODE>null</CODE> */ public PdfStream getAsStream(final int idx) { PdfStream stream = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isStream()) stream = (PdfStream) orig; return stream; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfNumber</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfNumber</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfNumber</CODE> object, * or <CODE>null</CODE> */ public PdfNumber getAsNumber(final int idx) { PdfNumber number = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isNumber()) number = (PdfNumber) orig; return number; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfNumber</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfNumber</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfNumber</CODE> object, * or <CODE>null</CODE> */ public PdfNumber getAsNumber(final int idx) { PdfNumber number = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isNumber()) number = (PdfNumber) orig; return number; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfName</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfName</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfName</CODE> object, * or <CODE>null</CODE> */ public PdfName getAsName(final int idx) { PdfName name = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isName()) name = (PdfName) orig; return name; }
/** * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfArray</CODE>, * resolving indirect references. * * The object corresponding to the specified index is retrieved and * resolved to a direct object. * If it is a <CODE>PdfArray</CODE>, it is cast down and returned as such. * Otherwise <CODE>null</CODE> is returned. * * @param idx The index of the <CODE>PdfObject</CODE> to be returned * @return the corresponding <CODE>PdfArray</CODE> object, * or <CODE>null</CODE> */ public PdfArray getAsArray(final int idx) { PdfArray array = null; PdfObject orig = getDirectObject(idx); if (orig != null && orig.isArray()) array = (PdfArray) orig; return array; }
/** * If the child of a structured element is an array, we need to loop over * the elements. * * @param k * the child array to inspect */ public void inspectChildArray(PdfArray k) throws IOException { if (k == null) return; for (int i = 0; i < k.size(); i++) { inspectChild(k.getDirectObject(i)); } }
/** * If the child of a structured element is an array, we need to loop over * the elements. * * @param k * the child array to inspect */ public void inspectChildArray(PdfArray k) throws IOException { if (k == null) return; for (int i = 0; i < k.size(); i++) { inspectChild(k.getDirectObject(i)); } }
PdfArray ar = (PdfArray)xfa; for (int k = 1; k < ar.size(); k += 2) { PdfObject ob = ar.getDirectObject(k); if (ob instanceof PRStream) { byte[] b = PdfReader.getStreamBytes((PRStream)ob);
private String[] getListOption(String fieldName, int idx) { Item fd = getFieldItem(fieldName); if (fd == null) return null; PdfArray ar = fd.getMerged(0).getAsArray(PdfName.OPT); if (ar == null) return null; String[] ret = new String[ar.size()]; for (int k = 0; k < ar.size(); ++k) { PdfObject obj = ar.getDirectObject( k ); try { if (obj.isArray()) { obj = ((PdfArray)obj).getDirectObject(idx); } if (obj.isString()) ret[k] = ((PdfString)obj).toUnicodeString(); else ret[k] = obj.toString(); } catch (Exception e) { ret[k] = ""; } } return ret; }
private String[] getListOption(String fieldName, int idx) { Item fd = getFieldItem(fieldName); if (fd == null) return null; PdfArray ar = fd.getMerged(0).getAsArray(PdfName.OPT); if (ar == null) return null; String[] ret = new String[ar.size()]; for (int k = 0; k < ar.size(); ++k) { PdfObject obj = ar.getDirectObject( k ); try { if (obj.isArray()) { obj = ((PdfArray)obj).getDirectObject(idx); } if (obj.isString()) ret[k] = ((PdfString)obj).toUnicodeString(); else ret[k] = obj.toString(); } catch (Exception e) { ret[k] = ""; } } return ret; }
for (int i = 0; i < pdfArray.size(); i++) { PdfFileSpecification pdfFileSpecification = new PdfFileSpecification(); pdfFileSpecification.putAll((PdfDictionary) pdfArray.getDirectObject(i)); attachments.add(pdfFileSpecification);