QGIS/python/core/layout/qgslayoutexporter.sip.in
Nyall Dawson 2eacc4c4b4 [FEATURE][layouts] Export project metadata in PDF/image exports
Includes project metadata in PDF exports, and supported image
based formats.

Image based metadata support depends on the format and the
Qt library's handling of each particular format (e.g. PNG
outputs are well supported).

Developed for Arpa Piemonte (Dipartimento Tematico Geologia e Dissesto)
within ERIKUS project
2018-03-22 16:13:30 +11:00

373 lines
12 KiB
Plaintext

/************************************************************************
* 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.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutexporter.h"
%End
public:
struct PageExportDetails
{
QString directory;
QString baseName;
QString extension;
int page;
};
QgsLayoutExporter( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutExporter, for the specified ``layout``.
%End
virtual ~QgsLayoutExporter();
QgsLayout *layout() const;
%Docstring
Returns the layout linked to this exporter.
%End
void renderPage( QPainter *painter, int page ) const;
%Docstring
Renders a full page to a destination ``painter``.
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.
.. seealso:: :py:func:`renderRect`
%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`
%End
void renderRegion( QPainter *painter, const QRectF &region ) const;
%Docstring
Renders a ``region`` from the layout to a ``painter``. This method can be used
to render sections of pages rather than full pages.
.. 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`
%End
enum ExportResult
{
Success,
Canceled,
MemoryError,
FileError,
PrintError,
SvgLayerError,
IteratorError,
};
struct ImageExportSettings
{
ImageExportSettings();
%Docstring
Constructor for ImageExportSettings
%End
double dpi;
QSize imageSize;
bool cropToContents;
QgsMargins cropMargins;
QList< int > pages;
bool generateWorldFile;
bool exportMetadata;
QgsLayoutRenderContext::Flags flags;
};
ExportResult exportToImage( const QString &filePath, const QgsLayoutExporter::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. If an error code is returned, errorFile() can be called
to determine the filename for the export which encountered the error.
%End
static ExportResult exportToImage( QgsAbstractLayoutIterator *iterator, const QString &baseFilePath,
const QString &extension, const QgsLayoutExporter::ImageExportSettings &settings,
QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to raster images, with the specified export ``settings``.
The ``baseFilePath`` argument gives a base file path, which is modified by the
iterator to obtain file paths for each iterator feature.
Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be set
to the error description.
%End
struct PdfExportSettings
{
PdfExportSettings();
%Docstring
Constructor for PdfExportSettings
%End
double dpi;
bool rasterizeWholeImage;
bool forceVectorOutput;
bool exportMetadata;
QgsLayoutRenderContext::Flags flags;
};
ExportResult exportToPdf( const QString &filePath, const QgsLayoutExporter::PdfExportSettings &settings );
%Docstring
Exports the layout as a PDF to the a ``filePath``, using the specified export ``settings``.
Returns a result code indicating whether the export was successful or an
error was encountered.
%End
static ExportResult exportToPdf( QgsAbstractLayoutIterator *iterator, const QString &fileName,
const QgsLayoutExporter::PdfExportSettings &settings,
QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to a single PDF file, with the specified export ``settings``.
The ``fileName`` argument gives the destination file name for the output PDF.
Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be set
to the error description.
.. seealso:: :py:func:`exportToPdfs`
%End
static ExportResult exportToPdfs( QgsAbstractLayoutIterator *iterator, const QString &baseFilePath,
const QgsLayoutExporter::PdfExportSettings &settings,
QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to multiple PDF files, with the specified export ``settings``.
The ``baseFilePath`` argument gives a base file path, which is modified by the
iterator to obtain file paths for each iterator feature.
Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be set
to the error description.
.. seealso:: :py:func:`exportToPdf`
%End
struct PrintExportSettings
{
PrintExportSettings();
%Docstring
Constructor for PrintExportSettings
%End
double dpi;
bool rasterizeWholeImage;
QgsLayoutRenderContext::Flags flags;
};
ExportResult print( QPrinter &printer, const QgsLayoutExporter::PrintExportSettings &settings );
%Docstring
Prints the layout to a ``printer``, using the specified export ``settings``.
Returns a result code indicating whether the export was successful or an
error was encountered.
%End
static ExportResult print( QgsAbstractLayoutIterator *iterator, QPrinter &printer,
const QgsLayoutExporter::PrintExportSettings &settings,
QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to a ``printer``, with the specified export ``settings``.
Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be set
to the error description.
%End
struct SvgExportSettings
{
SvgExportSettings();
%Docstring
Constructor for SvgExportSettings
%End
double dpi;
bool forceVectorOutput;
bool cropToContents;
QgsMargins cropMargins;
bool exportAsLayers;
bool exportMetadata;
QgsLayoutRenderContext::Flags flags;
};
ExportResult exportToSvg( const QString &filePath, const QgsLayoutExporter::SvgExportSettings &settings );
%Docstring
Exports the layout as an SVG to the a ``filePath``, using the specified export ``settings``.
Returns a result code indicating whether the export was successful or an
error was encountered.
%End
static ExportResult exportToSvg( QgsAbstractLayoutIterator *iterator, const QString &baseFilePath,
const QgsLayoutExporter::SvgExportSettings &settings,
QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to SVG files, with the specified export ``settings``.
The ``baseFilePath`` argument gives a base file path, which is modified by the
iterator to obtain file paths for each iterator feature.
Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be set
to the error description.
%End
QString errorFile() const;
%Docstring
Returns the file name corresponding to the last error encountered during
an export.
%End
bool georeferenceOutput( const QString &file, QgsLayoutItemMap *referenceMap = 0,
const QRectF &exportRegion = QRectF(), double dpi = -1 ) const;
%Docstring
Georeferences a ``file`` (image of PDF) exported from the layout.
The ``referenceMap`` argument specifies a map item to use for georeferencing. If left as None, the
default layout QgsLayout.referenceMap() will be used.
The ``exportRegion`` argument can be set to a valid rectangle to indicate that only part of the layout was
exported.
Similarly, the ``dpi`` can be set to the actual DPI of exported file, or left as -1 to use the layout's default DPI.
The function will return true if the output was successfully georeferenced.
.. seealso:: :py:func:`computeGeoTransform`
%End
void computeWorldFileParameters( double &a, double &b, double &c, double &d, double &e, double &f, double dpi = -1 ) const;
%Docstring
Compute world file parameters. Assumes the whole page containing the reference map item
will be exported.
The ``dpi`` argument can be set to the actual DPI of exported file, or left as -1 to use the layout's default DPI.
%End
void computeWorldFileParameters( const QRectF &region, double &a, double &b, double &c, double &d, double &e, double &f, double dpi = -1 ) const;
%Docstring
Computes the world file parameters for a specified ``region`` of the layout.
The ``dpi`` argument can be set to the actual DPI of exported file, or left as -1 to use the layout's default DPI.
%End
protected:
virtual QString generateFileName( const PageExportDetails &details ) const;
%Docstring
Generates the file name for a page during export.
Subclasses can override this method to customise page file naming.
%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 *
************************************************************************/