16 #ifndef QGSLAYOUTEXPORTER_H 
   17 #define QGSLAYOUTEXPORTER_H 
   19 #include "qgis_core.h" 
   86     void renderPage( QPainter *painter, 
int page ) 
const;
 
  106     QImage renderPageToImage( 
int page, QSize imageSize = QSize(), 
double dpi = -1 ) 
const;
 
  115     void renderRegion( QPainter *painter, 
const QRectF ®ion ) 
const;
 
  133     QImage renderRegionToImage( 
const QRectF ®ion, QSize imageSize = QSize(), 
double dpi = -1 ) 
const;
 
  177       bool cropToContents = 
false;
 
  198       bool generateWorldFile = 
false;
 
  206       bool exportMetadata = 
true;
 
  212       QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
 
  267       bool rasterizeWholeImage = 
false;
 
  276       bool forceVectorOutput = 
false;
 
  283       bool appendGeoreference = 
true;
 
  291       bool exportMetadata = 
true;
 
  296       QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
 
  312       bool simplifyGeometries = 
true;
 
  325       bool writeGeoPdf = 
false;
 
  340       bool exportLayersAsSeperateFiles = 
false; 
 
  350       bool useIso32000ExtensionFormatGeoreferencing = 
true;
 
  361       bool useOgcBestPracticeFormatGeoreferencing = 
false;
 
  368       bool includeGeoPdfFeatures = 
true;
 
  445       bool rasterizeWholeImage = 
false;
 
  450       QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
 
  499       bool forceVectorOutput = 
false;
 
  505       bool cropToContents = 
false;
 
  518       bool exportAsLayers = 
false;
 
  528       bool exportLabelsToSeparateLayers = 
true;
 
  536       bool exportMetadata = 
true;
 
  541       QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
 
  557       bool simplifyGeometries = 
true;
 
  603     QMap< QString, QgsLabelingResults * > labelingResults();
 
  616     QMap< QString, QgsLabelingResults * > takeLabelingResults();
 
  634     bool georeferenceOutput( 
const QString &file, 
QgsLayoutItemMap *referenceMap = 
nullptr,
 
  635                              const QRectF &exportRegion = QRectF(), 
double dpi = -1 ) 
const;
 
  643     void computeWorldFileParameters( 
double &a, 
double &b, 
double &
c, 
double &d, 
double &e, 
double &f, 
double dpi = -1 ) 
const;
 
  650     void computeWorldFileParameters( 
const QRectF ®ion, 
double &a, 
double &b, 
double &
c, 
double &d, 
double &e, 
double &f, 
double dpi = -1 ) 
const;
 
  660     static bool requiresRasterization( 
const QgsLayout *layout );
 
  669     static bool containsAdvancedEffects( 
const QgsLayout *layout );
 
  678     virtual QString generateFileName( 
const PageExportDetails &details ) 
const;
 
  682     QPointer< QgsLayout > mLayout;
 
  684     void captureLabelingResults();
 
  685     QMap< QString, QgsLabelingResults * > mLabelingResults;
 
  687     mutable QString mErrorFileName;
 
  689     QImage createImage( 
const ImageExportSettings &settings, 
int page, QRectF &bounds, 
bool &skipPage ) 
const;
 
  695     static int firstPageToBeExported( 
QgsLayout *layout );
 
  700     static bool saveImage( 
const QImage &image, 
const QString &imageFilename, 
const QString &imageFormat, 
QgsProject *projectForMetadata );
 
  715     std::unique_ptr<double[]> computeGeoTransform( 
const QgsLayoutItemMap *referenceMap = 
nullptr, 
const QRectF &exportRegion = QRectF(), 
double dpi = -1 ) 
const;
 
  718     void writeWorldFile( 
const QString &fileName, 
double a, 
double b, 
double c, 
double d, 
double e, 
double f ) 
const;
 
  723     static void preparePrintAsPdf( 
QgsLayout *layout, QPrinter &printer, 
const QString &filePath );
 
  725     static void preparePrint( 
QgsLayout *layout, QPrinter &printer, 
bool setFirstPageSize = 
false );
 
  730     ExportResult print( QPrinter &printer );
 
  740     ExportResult printPrivate( QPrinter &printer, QPainter &painter, 
bool startNewPage = 
false, 
double dpi = -1, 
bool rasterize = 
false );
 
  742     static void updatePrinterPageSize( 
QgsLayout *layout, QPrinter &printer, 
int page );
 
  744     ExportResult renderToLayeredSvg( 
const SvgExportSettings &settings, 
double width, 
double height, 
int page, 
const QRectF &bounds,
 
  745                                      const QString &filename, 
unsigned int svgLayerId, 
const QString &layerName,
 
  746                                      QDomDocument &svg, QDomNode &svgDocRoot, 
bool includeMetadata ) 
const;
 
  748     void appendMetadataToSvg( QDomDocument &svg ) 
const;
 
  750     bool georeferenceOutputPrivate( 
const QString &file, 
QgsLayoutItemMap *referenceMap = 
nullptr,
 
  751                                     const QRectF &exportRegion = QRectF(), 
double dpi = -1, 
bool includeGeoreference = 
true, 
bool includeMetadata = 
false ) 
const;
 
  756     friend class TestQgsLayout;
 
  757     friend class TestQgsLayoutExporter;
 
An abstract base class for QgsLayout based classes which can be exported by QgsLayoutExporter.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Class that stores computed placement from labeling engine.
Handles rendering and exports of layouts to various formats.
ExportResult
Result codes for exporting layouts.
@ Canceled
Export was canceled.
@ MemoryError
Unable to allocate memory required to export.
@ PrintError
Could not start printing to destination device.
@ IteratorError
Error iterating over layout.
@ FileError
Could not write to destination file, likely due to a lock held by another application.
@ Success
Export was successful.
@ SvgLayerError
Could not create layered SVG file.
QString errorFile() const
Returns the file name corresponding to the last error encountered during an export.
Layout graphical items for displaying a map.
Stores information relating to the current rendering settings for a layout.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
The QgsMargins class defines the four margins of a rectangle.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
TextRenderFormat
Options for rendering text.
@ TextFormatAlwaysOutlines
Always render text using path objects (AKA outlines/curves).
This class contains information how to simplify geometries fetched from a vector layer.
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 settings relating to exporting layouts to raster images.
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.
QSize imageSize
Manual size in pixels for output image.
ImageExportSettings()
Constructor for ImageExportSettings.
QVector< qreal > predefinedMapScales
A list of predefined scales to use with the layout.
Contains details of a page being exported by the class.
QString baseName
Base part of filename (i.e. file name without extension or '.')
QString extension
File suffix/extension (without the leading '.')
QString directory
Target folder.
Contains settings relating to exporting layouts to PDF.
QStringList exportThemes
Optional list of map themes to export as GeoPDF layer groups.
QVector< qreal > predefinedMapScales
A list of predefined scales to use with the layout.
PdfExportSettings()
Constructor for PdfExportSettings.
Contains settings relating to printing layouts.
QVector< qreal > predefinedMapScales
A list of predefined scales to use with the layout.
PrintExportSettings()
Constructor for PrintExportSettings.
Contains settings relating to exporting layouts to SVG.
SvgExportSettings()
Constructor for SvgExportSettings.
QVector< qreal > predefinedMapScales
A list of predefined scales to use with the layout.
QgsMargins cropMargins
Crop to content margins, in layout units.
Contains details of a particular export layer relating to a layout item.