See Programmatic Export Using Python for an example of usage.

Exporter class

class api.Exporter(iface=None, settingsPath=None)

A convenient class to export the scenes to web programmatically

__init__(iface=None, settingsPath=None)


  • iface (QgisInterface) – If specified, mapSettings attribute is initialized with the map settings of the map canvas. The iface.legendInterface() is used to export vector layers in the same order as the legend.
  • settingsPath (unicode) – Path to an existing settings file (.qto3settings).
export(htmlPath, openBrowser=False)

Do export.

  • htmlPath (unicode) – Output HTML file path.
  • openBrowser (bool) – If True, open the exported page using default web browser.

Exporter.NO_ERROR if success. Otherwise returns error message.

Return type:

None or unicode.

setExtent(center, width, height, rotation=0)

Set map extent to export settings.

This is a convenience method to set map extent to export settings. Map settings should be set before this method is called.

  • center (QgsPoint) – Center of the map extent in the map CRS.
  • width (float) – Width of the map extent in unit of the map CRS.
  • height (float) – Height of the map extent in unit of the map CRS.
  • rotation (float) – Rotation in degrees. Requires QGIS version 2.8 or later.

Set map settings to export settings.

Map settings is used to define base extent of the export and render a map canvas image.

Parameters:mapSettings (QgsMapSettings) – Map settings to be set.