CPDF_Dictionary dict; dict.SetNewFor("Type", "Catalog"); CPDF_Object* obj = dict.GetObjectFor("Type"); if (obj && obj->GetType() == PDFOBJ_NAME) { CPDF_Name* name = obj->AsName(); std::cout << "Object found: " << name->GetString() << std::endl; }
CPDF_Dictionary dict; dict.SetNewForThis example shows how GetObjectFor can be used with the PDFNet SDK to work with PDF annotations. We create a new dictionary and add an array to it with the key "Rect". We then create a new annotation object and assign our dictionary to it. We can then call GetObjectFor on the annotation's dictionary to retrieve the "Rect" array, which we can then work with as needed. Package library: PDFNet SDK("Rect"); CPDF_Annot* annot = new CPDF_Annot(&dict); CPDF_Array* rect_array = annot->GetAnnotDict()->GetObjectFor("Rect")->AsArray();