Class PagePng

class ooodev.draw.export.page_png.PagePng(owner)[source]

Bases: LoInstPropsPartial, ExportBase, EventsPartial

Class for exporting current Writer page as a png image.

Parameters:

owner (DrawPage[ComponentT]) –

__init__(owner)[source]

Constructor.

Parameters:
  • lo_inst (LoInst, optional) – Lo instance.

  • owner (DrawPage[Any]) –

add_event_observers(*args)

Adds observers that gets their trigger method called when this class trigger method is called.

Parameters:

args (EventObserver) – One or more observers to add.

Return type:

None

Note

Observers are removed automatically when they are out of scope.

export(fnm, resolution=96)[source]

Exports page as png image.

Parameters:
  • fnm (PathOrStr, optional) – Image file name.

  • resolution (int, optional) – Resolution in dpi. Defaults to 96.

Events:
Return type:

None

Note

On exporting event is Class CancelEventArgsExport. On exported event is Class EventArgsExport. Args event_data is a ExportPngT dictionary.

Image width or height past 4096 pixels seem to not render the correct size when transparency is set to true (default). For a 8.5 in x 11 in document this is a resolution around 423 DPI. It seems when transparency is set to false, the image size is correct for larger images. Unlike exporting png, exporting jpg does not seem to have a limit on the image size.

Page margins are ignored. Any shape that is outside the page margins will not be included in the image.

When page is exported as png, such as an impress slide, any images on the will not be exported if filter translucent=True. For this reason, the default value for translucent is False.

remove_event_observer(observer)

Removes an observer

Parameters:

observer (EventObserver) – One or more observers to add.

Returns:

True if observer has been removed; Otherwise, False.

Return type:

bool

subscribe_event(event_name, callback)

Add an event listener to current instance.

Parameters:
  • event_name (str) – Event Name.

  • callback (EventCallback) – Callback of the event listener.

Return type:

None

subscribe_event_exported(callback)[source]

Add an event listener to current instance that is triggered on export complete.

Parameters:

callback (Callable[[Any, CancelEventArgsExport[ExportPngT]], None]) – Callback of the event listener.

Return type:

None

subscribe_event_exporting(callback)[source]

Add an event listener to current instance that is triggered on exporting.

Parameters:

callback (Callable[[Any, CancelEventArgsExport[ExportPngT]], None]) – Callback of the event listener.

Return type:

None

trigger_event(event_name, event_args)

Trigger an event on current instance.

Parameters:
  • event_name (str) – Event Name.

  • event_args (EventArgsT) – Event Args.

Return type:

None

unsubscribe_event(event_name, callback)

Remove an event listener from current instance.

Parameters:
  • event_name (str) – Event Name.

  • callback (EventCallback) – Callback of the event listener.

Return type:

None

unsubscribe_event_exported(callback)[source]

Remove an event listener from current instance.

Parameters:

callback (Callable[[Any, CancelEventArgsExport[ExportPngT]], None]) – Callback of the event listener.

Return type:

None

unsubscribe_event_exporting(callback)[source]

Remove an event listener from current instance.

Parameters:

callback (Callable[[Any, CancelEventArgsExport[ExportPngT]], None]) – Callback of the event listener.

Return type:

None

property event_observer: EventObserver

Gets/Sets The Event Observer for this instance.

Return type:

EventObserver

property lo_inst: LoInst

Lo Instance

Return type:

LoInst