16 #ifndef QGSLAYOUTEXPORTER_H 17 #define QGSLAYOUTEXPORTER_H 19 #include "qgis_core.h" 80 void renderPage( QPainter *painter,
int page )
const;
100 QImage renderPageToImage(
int page, QSize imageSize = QSize(),
double dpi = -1 )
const;
109 void renderRegion( QPainter *painter,
const QRectF ®ion )
const;
127 QImage renderRegionToImage(
const QRectF ®ion, QSize imageSize = QSize(),
double dpi = -1 )
const;
171 bool cropToContents =
false;
192 bool generateWorldFile =
false;
200 bool exportMetadata =
true;
206 QgsLayoutRenderContext::Flags flags =
nullptr;
254 bool rasterizeWholeImage =
false;
263 bool forceVectorOutput =
false;
271 bool exportMetadata =
true;
276 QgsLayoutRenderContext::Flags flags =
nullptr;
336 bool rasterizeWholeImage =
false;
341 QgsLayoutRenderContext::Flags flags =
nullptr;
383 bool forceVectorOutput =
false;
389 bool cropToContents =
false;
402 bool exportAsLayers =
false;
410 bool exportMetadata =
true;
415 QgsLayoutRenderContext::Flags flags =
nullptr;
463 bool georeferenceOutput(
const QString &file,
QgsLayoutItemMap *referenceMap =
nullptr,
464 const QRectF &exportRegion = QRectF(),
double dpi = -1 )
const;
472 void computeWorldFileParameters(
double &a,
double &b,
double &
c,
double &d,
double &e,
double &f,
double dpi = -1 )
const;
479 void computeWorldFileParameters(
const QRectF ®ion,
double &a,
double &b,
double &c,
double &d,
double &e,
double &f,
double dpi = -1 )
const;
492 QPointer< QgsLayout > mLayout;
494 mutable QString mErrorFileName;
496 QImage createImage(
const ImageExportSettings &settings,
int page, QRectF &bounds,
bool &skipPage )
const;
501 static bool saveImage(
const QImage &image,
const QString &imageFilename,
const QString &imageFormat,
QgsProject *projectForMetadata );
516 std::unique_ptr<double[]> computeGeoTransform(
const QgsLayoutItemMap *referenceMap =
nullptr,
const QRectF &exportRegion = QRectF(),
double dpi = -1 )
const;
519 void writeWorldFile(
const QString &fileName,
double a,
double b,
double c,
double d,
double e,
double f )
const;
524 static void preparePrintAsPdf(
QgsLayout *layout, QPrinter &printer,
const QString &filePath );
526 static void preparePrint(
QgsLayout *layout, QPrinter &printer,
bool setFirstPageSize =
false );
541 ExportResult printPrivate( QPrinter &printer, QPainter &painter,
bool startNewPage =
false,
double dpi = -1,
bool rasterize =
false );
543 static void updatePrinterPageSize(
QgsLayout *layout, QPrinter &printer,
int page );
546 const QString &filename,
int svgLayerId,
const QString &layerName,
547 QDomDocument &svg, QDomNode &svgDocRoot,
bool includeMetadata )
const;
549 void appendMetadataToSvg( QDomDocument &svg )
const;
551 bool georeferenceOutputPrivate(
const QString &file,
QgsLayoutItemMap *referenceMap =
nullptr,
552 const QRectF &exportRegion = QRectF(),
double dpi = -1,
bool includeGeoreference =
true,
bool includeMetadata =
false )
const;
554 friend class TestQgsLayout;
558 #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 cancelation 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.
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.
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.