16 #ifndef QGSLAYOUTEXPORTER_H 17 #define QGSLAYOUTEXPORTER_H 19 #include "qgis_core.h" 81 void renderPage( QPainter *painter,
int page )
const;
101 QImage renderPageToImage(
int page, QSize imageSize = QSize(),
double dpi = -1 )
const;
110 void renderRegion( QPainter *painter,
const QRectF ®ion )
const;
128 QImage renderRegionToImage(
const QRectF ®ion, QSize imageSize = QSize(),
double dpi = -1 )
const;
172 bool cropToContents =
false;
193 bool generateWorldFile =
false;
201 bool exportMetadata =
true;
207 QgsLayoutRenderContext::Flags flags =
nullptr;
255 bool rasterizeWholeImage =
false;
264 bool forceVectorOutput =
false;
272 bool exportMetadata =
true;
277 QgsLayoutRenderContext::Flags flags =
nullptr;
345 bool rasterizeWholeImage =
false;
350 QgsLayoutRenderContext::Flags flags =
nullptr;
392 bool forceVectorOutput =
false;
398 bool cropToContents =
false;
411 bool exportAsLayers =
false;
419 bool exportMetadata =
true;
424 QgsLayoutRenderContext::Flags flags =
nullptr;
480 bool georeferenceOutput(
const QString &file,
QgsLayoutItemMap *referenceMap =
nullptr,
481 const QRectF &exportRegion = QRectF(),
double dpi = -1 )
const;
489 void computeWorldFileParameters(
double &a,
double &b,
double &
c,
double &d,
double &e,
double &f,
double dpi = -1 )
const;
496 void computeWorldFileParameters(
const QRectF ®ion,
double &a,
double &b,
double &c,
double &d,
double &e,
double &f,
double dpi = -1 )
const;
509 QPointer< QgsLayout > mLayout;
511 mutable QString mErrorFileName;
513 QImage createImage(
const ImageExportSettings &settings,
int page, QRectF &bounds,
bool &skipPage )
const;
519 static int firstPageToBeExported(
QgsLayout *layout );
524 static bool saveImage(
const QImage &image,
const QString &imageFilename,
const QString &imageFormat,
QgsProject *projectForMetadata );
539 std::unique_ptr<double[]> computeGeoTransform(
const QgsLayoutItemMap *referenceMap =
nullptr,
const QRectF &exportRegion = QRectF(),
double dpi = -1 )
const;
542 void writeWorldFile(
const QString &fileName,
double a,
double b,
double c,
double d,
double e,
double f )
const;
547 static void preparePrintAsPdf(
QgsLayout *layout, QPrinter &printer,
const QString &filePath );
549 static void preparePrint(
QgsLayout *layout, QPrinter &printer,
bool setFirstPageSize =
false );
564 ExportResult printPrivate( QPrinter &printer, QPainter &painter,
bool startNewPage =
false,
double dpi = -1,
bool rasterize =
false );
566 static void updatePrinterPageSize(
QgsLayout *layout, QPrinter &printer,
int page );
569 const QString &filename,
int svgLayerId,
const QString &layerName,
570 QDomDocument &svg, QDomNode &svgDocRoot,
bool includeMetadata )
const;
572 void appendMetadataToSvg( QDomDocument &svg )
const;
574 bool georeferenceOutputPrivate(
const QString &file,
QgsLayoutItemMap *referenceMap =
nullptr,
575 const QRectF &exportRegion = QRectF(),
double dpi = -1,
bool includeGeoreference =
true,
bool includeMetadata =
false )
const;
577 friend class TestQgsLayout;
581 #endif //QGSLAYOUTEXPORTER_H
Contains settings relating to printing layouts.
QgsMargins cropMargins
Crop to content margins, in layout units.
Unable to allocate memory required to export.
Could not write to destination file, likely due to a lock held by another application.
QString errorFile() const
Returns the file name corresponding to the last error encountered during an export.
QgsMargins cropMargins
Crop to content margins, in pixels.
QList< int > pages
List of specific pages to export, or an empty list to export all pages.
QString directory
Target folder.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Contains details of a page being exported by the class.
QSize imageSize
Manual size in pixels for output image.
Layout graphical items for displaying a map.
An abstract base class for QgsLayout based classes which can be exported by QgsLayoutExporter.
Always render text using path objects (AKA outlines/curves).
QString extension
File suffix/extension (without the leading '.')
Reads and writes project states.
QString baseName
Base part of filename (i.e. file name without extension or '.')
Could not create layered SVG file.
ImageExportSettings()
Constructor for ImageExportSettings.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
TextRenderFormat
Options for rendering text.
PrintExportSettings()
Constructor for PrintExportSettings.
PdfExportSettings()
Constructor for PdfExportSettings.
SvgExportSettings()
Constructor for SvgExportSettings.
Handles rendering and exports of layouts to various formats.
Contains settings relating to exporting layouts to PDF.
Contains settings relating to exporting layouts to raster images.
Stores information relating to the current rendering settings for a layout.
Could not start printing to destination device.
Contains settings relating to exporting layouts to SVG.
The QgsMargins class defines the four margins of a rectangle.
ExportResult
Result codes for exporting layouts.
Error iterating over layout.