@@ -196,11 +196,20 @@ bool QgsMapRendererTask::run()
196
196
QPrinter printer;
197
197
printer.setOutputFileName ( component.sourcePdfPath );
198
198
printer.setOutputFormat ( QPrinter::PdfFormat );
199
+ #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
199
200
printer.setOrientation ( QPrinter::Portrait );
200
201
// paper size needs to be given in millimeters in order to be able to set a resolution to pass onto the map renderer
201
202
QSizeF outputSize = mMapSettings .outputSize ();
202
203
printer.setPaperSize ( outputSize * 25.4 / mMapSettings .outputDpi (), QPrinter::Millimeter );
203
204
printer.setPageMargins ( 0 , 0 , 0 , 0 , QPrinter::Millimeter );
205
+ #else
206
+ printer.setPageOrientation ( QPageLayout::Orientation::Portrait );
207
+ // paper size needs to be given in millimeters in order to be able to set a resolution to pass onto the map renderer
208
+ QSizeF outputSize = mMapSettings .outputSize ();
209
+ QPageSize pageSize ( outputSize * 25.4 / mMapSettings .outputDpi (), QPageSize::Unit::Millimeter );
210
+ printer.setPageSize ( pageSize );
211
+ printer.setPageMargins ( QMarginsF ( 0 , 0 , 0 , 0 ) );
212
+ #endif
204
213
printer.setResolution ( mMapSettings .outputDpi () );
205
214
206
215
QPainter p ( &printer );
@@ -472,11 +481,20 @@ void QgsMapRendererTask::prepare()
472
481
mPrinter .reset ( new QPrinter () );
473
482
mPrinter ->setOutputFileName ( mFileName );
474
483
mPrinter ->setOutputFormat ( QPrinter::PdfFormat );
484
+ #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
475
485
mPrinter ->setOrientation ( QPrinter::Portrait );
476
486
// paper size needs to be given in millimeters in order to be able to set a resolution to pass onto the map renderer
477
487
QSizeF outputSize = mMapSettings .outputSize ();
478
488
mPrinter ->setPaperSize ( outputSize * 25.4 / mMapSettings .outputDpi (), QPrinter::Millimeter );
479
489
mPrinter ->setPageMargins ( 0 , 0 , 0 , 0 , QPrinter::Millimeter );
490
+ #else
491
+ mPrinter ->setPageOrientation ( QPageLayout::Orientation::Portrait );
492
+ // paper size needs to be given in millimeters in order to be able to set a resolution to pass onto the map renderer
493
+ QSizeF outputSize = mMapSettings .outputSize ();
494
+ QPageSize pageSize ( outputSize * 25.4 / mMapSettings .outputDpi (), QPageSize::Unit::Millimeter );
495
+ mPrinter ->setPageSize ( pageSize );
496
+ mPrinter ->setPageMargins ( QMarginsF ( 0 , 0 , 0 , 0 ) );
497
+ #endif
480
498
mPrinter ->setResolution ( mMapSettings .outputDpi () );
481
499
482
500
if ( !mForceRaster )
0 commit comments