def to_dictionary_object(self, pdf: Pdf, create_new: bool = False) -> Dictionary: """Creates a ``Dictionary`` object from this outline node's data, or updates the existing object. Page numbers are resolved to a page reference on the input ``Pdf`` object. Arguments: pdf: PDF document object. create_new: If set to ``True``, creates a new object instead of modifying an existing one in-place. """ if create_new or self.obj is None: self.obj = obj = pdf.make_indirect(Dictionary()) else: obj = self.obj obj.Title = self.title if self.destination is not None: if isinstance(self.destination, int): self.destination = make_page_destination( pdf, self.destination, self.page_location, **self.page_location_kwargs, ) obj.Dest = self.destination if Name.A in obj: del obj.A elif self.action is not None: obj.A = self.action if Name.Dest in obj: del obj.Dest return obj
def test_block_make_indirect_page(graph: Pdf): with pytest.raises(TypeError, match='implicitly'): graph.make_indirect(graph.pages[0]) assert isinstance(graph.make_indirect(graph.pages[0].obj), Object)