pdftools_toolbox.pdf.navigation.fit_rectangle_destination

Classes

FitRectangleDestination(handle)

A destination that fits a specified area of a page into the viewport.

class pdftools_toolbox.pdf.navigation.fit_rectangle_destination.FitRectangleDestination(handle)[source]

Bases: DirectDestination

A destination that fits a specified area of a page into the viewport.

Note: Many PDF viewers support different viewing modes like “fit page” or “fit width”. A pdftools_toolbox.pdf.navigation.fit_rectangle_destination.FitRectangleDestination will change the current viewing mode to standard mode in those viewers, i.e. deactivate any special mode like “fit page” or “fit width”.

Changing the viewing mode is usually not very well received by users and thus a pdftools_toolbox.pdf.navigation.location_zoom_destination.LocationZoomDestination should be preferred in most cases.

static create(target_document: Document, page: Page, rectangle: Rectangle) FitRectangleDestination | None[source]

Create a new FitRectangleDestination

The returned object is not yet used on any page, but it is associated with the given target document.

Parameters:
Returns:

The newly created destination object.

Return type:

Optional[pdftools_toolbox.pdf.navigation.fit_rectangle_destination.FitRectangleDestination]

Raises:
  • ValueError – if the targetDocument argument has already been closed

  • ValueError – if the targetDocument argument is read-only

  • ValueError – if the targetDocument`differs from the document associated with `page

  • ValueError – If the document associated with the page argument has already been closed

property rectangle: Rectangle

The rectangle that is displayed in the viewport.

Returns:

pdftools_toolbox.geometry.real.rectangle.Rectangle

Raises:
  • StateError – the object has already been closed.

  • StateError – the associated document has already been closed.