Skip to contents

Wraps FPDFFormObj_CountObjects + FPDFFormObj_GetObject to enumerate the page objects contained in a Form XObject. The returned objects participate in the regular pdfium_obj API - you can call pdf_obj_type(), pdf_obj_bounds(), pdf_obj_matrix(), and (per object type) pdf_path_segments() / pdf_image_info() / pdf_text_content() on each one. Nesting is recursive: a Form XObject may itself contain other Form XObjects, and the returned pdfium_objs of type "form" can be passed back into pdf_form_objects().

Usage

pdf_form_objects(form)

Arguments

form

A pdfium_obj of type "form", typically obtained by filtering pdf_page_objects() (or another pdf_form_objects() call) on type == "form".

Value

A list of pdfium_objs, one per nested page object. Empty list when the form has no children.

Details

Each returned object carries a parent_form slot pointing back at form, used by the print/format methods to show the containment path ("obj 2 of form 1 on page 1"). Its lifetime is bound to the form handle: the nested objects are refused, like form itself, once form's page or document is closed, once the annotation whose appearance stream holds form (pdf_annot_objects()) is deleted, and once form is deleted with pdf_obj_delete(), removed from its own form with pdf_form_obj_remove_object() or moved into an annotation with pdf_annot_append_object(). After such a move, read the objects again through pdf_annot_objects() and then pdf_form_objects().

See also

pdf_page_objects() for the top-level enumeration, pdf_obj_matrix() for the form's own transformation matrix.

Examples

fixture <- system.file("extdata", "fixtures", "form_xobject.pdf",
  package = "pdfium"
)
if (nzchar(fixture)) {
  doc <- pdf_doc_open(fixture)
  page <- pdf_page_load(doc, 1L)
  forms <- Filter(function(o) o$type == "form", pdf_page_objects(page))
  if (length(forms) > 0L) {
    nested <- pdf_form_objects(forms[[1L]])
    length(nested)
  }
  pdf_page_close(page)
  pdf_doc_close(doc)
}