QGIS/python/core/layout/qgslayoutexporter.sip

170 lines
5.3 KiB
Plaintext
Raw Normal View History

2017-10-16 14:03:57 +10:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutexporter.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsLayoutExporter
{
%Docstring
Handles rendering and exports of layouts to various formats.
2017-12-15 10:36:55 -04:00
2017-10-16 14:03:57 +10:00
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutexporter.h"
%End
public:
QgsLayoutExporter( QgsLayout *layout );
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsLayoutExporter, for the specified ``layout``.
2017-10-16 14:03:57 +10:00
%End
void renderPage( QPainter *painter, int page ) const;
2017-10-16 14:03:57 +10:00
%Docstring
2017-12-15 10:36:55 -04:00
Renders a full page to a destination ``painter``.
2017-10-16 14:03:57 +10:00
2017-12-15 10:36:55 -04:00
The ``page`` argument specifies the page number to render. Page numbers
are 0 based, such that the first page in a layout is page 0.
2017-10-16 14:03:57 +10:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`renderRect()`
2017-10-16 14:03:57 +10:00
%End
QImage renderPageToImage( int page, QSize imageSize = QSize(), double dpi = 0 ) const;
%Docstring
Renders a full page to an image.
The ``page`` argument specifies the page number to render. Page numbers
are 0 based, such that the first page in a layout is page 0.
The optional ``imageSize`` parameter can specify the target image size, in pixels.
It is the caller's responsibility to ensure that the ratio of the target image size
matches the ratio of the corresponding layout page size.
The ``dpi`` parameter is an optional dpi override. Set to 0 to use the default layout print
resolution. This parameter has no effect if ``imageSize`` is specified.
Returns the rendered image, or a null QImage if the image does not fit into available memory.
.. seealso:: :py:func:`renderPage()`
.. seealso:: :py:func:`renderRegionToImage()`
:rtype: QImage
%End
void renderRegion( QPainter *painter, const QRectF &region ) const;
2017-10-16 14:03:57 +10:00
%Docstring
2017-12-15 10:36:55 -04:00
Renders a ``region`` from the layout to a ``painter``. This method can be used
to render sections of pages rather than full pages.
2017-10-16 14:03:57 +10:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`renderPage()`
.. seealso:: :py:func:`renderRegionToImage()`
%End
QImage renderRegionToImage( const QRectF &region, QSize imageSize = QSize(), double dpi = 0 ) const;
%Docstring
Renders a ``region`` of the layout to an image. This method can be used to render
sections of pages rather than full pages.
The optional ``imageSize`` parameter can specify the target image size, in pixels.
It is the caller's responsibility to ensure that the ratio of the target image size
matches the ratio of the specified region of the layout.
The ``dpi`` parameter is an optional dpi override. Set to 0 to use the default layout print
resolution. This parameter has no effect if ``imageSize`` is specified.
Returns the rendered image, or a null QImage if the image does not fit into available memory.
.. seealso:: :py:func:`renderRegion()`
.. seealso:: :py:func:`renderPageToImage()`
:rtype: QImage
%End
enum ExportResult
{
Success,
MemoryError,
FileError,
};
struct ImageExportSettings
{
double dpi;
%Docstring
Resolution to export layout at
%End
QSize imageSize;
%Docstring
Manual size in pixels for output image. If imageSize is not
set then it will be automatically calculated based on the
output dpi and layout size.
If cropToContents is true then imageSize has no effect.
Be careful when specifying manual sizes if pages in the layout
have differing sizes! It's likely not going to give a reasonable
output in this case, and the automatic dpi-based image size should be
used instead.
%End
bool cropToContents;
%Docstring
Set to true if image should be cropped so only parts of the layout
containing items are exported.
%End
QgsMargins cropMargins;
%Docstring
Crop to content margins, in pixels. These margins will be added
to the bounds of the exported layout if cropToContents is true.
%End
QList< int > pages;
%Docstring
List of specific pages to export, or an empty list to
export all pages.
Page numbers are 0 index based, so the first page in the
layout corresponds to page 0.
%End
bool generateWorldFile;
%Docstring
Set to true to generate an external world file alonside
exported images.
%End
};
ExportResult exportToImage( const QString &filePath, const ImageExportSettings &settings );
%Docstring
Exports the layout to the a ``filePath``, using the specified export ``settings``.
If the layout is a multi-page layout, then filenames for each page will automatically
be generated by appending "_1", "_2", etc to the image file's base name.
Returns a result code indicating whether the export was successful or an
error was encountered.
:rtype: ExportResult
2017-10-16 14:03:57 +10:00
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutexporter.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/