public void parse(PRStream stream, PdfDictionary resources) throws IOException {
baos = new ByteArrayOutputStream();
properties = resources.getAsDict(PdfName.PROPERTIES);
xobj = new HashSet<PdfName>();
PdfDictionary xobjects = resources.getAsDict(PdfName.XOBJECT);
PRStream xobject;
PdfDictionary oc;
PdfString ocname;
if (xobjects != null) {
// remove XObject (form or image) that belong to an OCG that needs to be removed
for (PdfName name : xobjects.getKeys()) {
xobject = (PRStream)xobjects.getAsStream(name);
oc = xobject.getAsDict(PdfName.OC);
if (oc != null) {
ocname = oc.getAsString(PdfName.NAME);
if (ocname != null && ocgs.contains(ocname.toString())) {
xobj.add(name);
}