16 #ifndef QGSLAYOUTEXPORTER_H
17 #define QGSLAYOUTEXPORTER_H
19 #include "qgis_core.h"
87 void renderPage( QPainter *painter,
int page )
const;
107 QImage renderPageToImage(
int page, QSize imageSize = QSize(),
double dpi = -1 )
const;
116 void renderRegion( QPainter *painter,
const QRectF ®ion )
const;
134 QImage renderRegionToImage(
const QRectF ®ion, QSize imageSize = QSize(),
double dpi = -1 )
const;
178 bool cropToContents =
false;
199 bool generateWorldFile =
false;
207 bool exportMetadata =
true;
213 QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
268 bool rasterizeWholeImage =
false;
277 bool forceVectorOutput =
false;
284 bool appendGeoreference =
true;
292 bool exportMetadata =
true;
297 QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
313 bool simplifyGeometries =
true;
326 bool writeGeoPdf =
false;
341 bool exportLayersAsSeperateFiles =
false;
351 bool useIso32000ExtensionFormatGeoreferencing =
true;
362 bool useOgcBestPracticeFormatGeoreferencing =
false;
369 bool includeGeoPdfFeatures =
true;
446 bool rasterizeWholeImage =
false;
451 QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
500 bool forceVectorOutput =
false;
506 bool cropToContents =
false;
519 bool exportAsLayers =
false;
529 bool exportLabelsToSeparateLayers =
true;
537 bool exportMetadata =
true;
542 QgsLayoutRenderContext::Flags flags = QgsLayoutRenderContext::Flags();
558 bool simplifyGeometries =
true;
604 QMap< QString, QgsLabelingResults * > labelingResults();
617 QMap< QString, QgsLabelingResults * > takeLabelingResults();
635 bool georeferenceOutput(
const QString &file,
QgsLayoutItemMap *referenceMap =
nullptr,
636 const QRectF &exportRegion = QRectF(),
double dpi = -1 )
const;
644 void computeWorldFileParameters(
double &a,
double &b,
double &
c,
double &d,
double &e,
double &f,
double dpi = -1 )
const;
651 void computeWorldFileParameters(
const QRectF ®ion,
double &a,
double &b,
double &
c,
double &d,
double &e,
double &f,
double dpi = -1 )
const;
661 static bool requiresRasterization(
const QgsLayout *layout );
670 static bool containsAdvancedEffects(
const QgsLayout *layout );
679 virtual QString generateFileName(
const PageExportDetails &details )
const;
683 QPointer< QgsLayout > mLayout;
685 void captureLabelingResults();
686 QMap< QString, QgsLabelingResults * > mLabelingResults;
688 mutable QString mErrorFileName;
690 QImage createImage(
const ImageExportSettings &settings,
int page, QRectF &bounds,
bool &skipPage )
const;
696 static int firstPageToBeExported(
QgsLayout *layout );
701 static bool saveImage(
const QImage &image,
const QString &imageFilename,
const QString &imageFormat,
QgsProject *projectForMetadata );
716 std::unique_ptr<double[]> computeGeoTransform(
const QgsLayoutItemMap *referenceMap =
nullptr,
const QRectF &exportRegion = QRectF(),
double dpi = -1 )
const;
719 void writeWorldFile(
const QString &fileName,
double a,
double b,
double c,
double d,
double e,
double f )
const;
724 static void preparePrintAsPdf(
QgsLayout *layout, QPrinter &printer,
const QString &filePath );
726 static void preparePrint(
QgsLayout *layout, QPrinter &printer,
bool setFirstPageSize =
false );
731 ExportResult print( QPrinter &printer );
741 ExportResult printPrivate( QPrinter &printer, QPainter &painter,
bool startNewPage =
false,
double dpi = -1,
bool rasterize =
false );
743 static void updatePrinterPageSize(
QgsLayout *layout, QPrinter &printer,
int page );
745 ExportResult renderToLayeredSvg(
const SvgExportSettings &settings,
double width,
double height,
int page,
const QRectF &bounds,
746 const QString &filename,
unsigned int svgLayerId,
const QString &layerName,
747 QDomDocument &svg, QDomNode &svgDocRoot,
bool includeMetadata )
const;
749 void appendMetadataToSvg( QDomDocument &svg )
const;
751 bool georeferenceOutputPrivate(
const QString &file,
QgsLayoutItemMap *referenceMap =
nullptr,
752 const QRectF &exportRegion = QRectF(),
double dpi = -1,
bool includeGeoreference =
true,
bool includeMetadata =
false )
const;
757 friend class TestQgsLayout;
758 friend class TestQgsLayoutExporter;
762 #endif // ! QT_NO_PRINTER
764 #endif //QGSLAYOUTEXPORTER_H