Use millimeters when declaring QPrinter page size

(This is needed to allow to set a resolution with the printer used
by the map renderer)
This commit is contained in:
Mathieu Pellerin 2017-05-15 06:23:29 +07:00 committed by GitHub
parent f8f7d60cf0
commit a4b7af7fad

View File

@ -5883,8 +5883,10 @@ void QgisApp::saveMapAsPdf()
printer->setOutputFileName( fileName );
printer->setOutputFormat( QPrinter::PdfFormat );
printer->setOrientation( QPrinter::Portrait );
printer->setPaperSize( dlg.size(), QPrinter::DevicePixel );
printer->setPageMargins( 0, 0, 0, 0, QPrinter::DevicePixel );
// paper size needs to be given in millimeters in order to be able to set a resolution to pass onto the map renderer
printer->setPaperSize( dlg.size() * 25.4 / dlg.dpi(), QPrinter::Millimeter );
printer->setPageMargins( 0, 0, 0, 0, QPrinter::Millimeter );
printer->setResolution( dlg.dpi() );
QPainter *p = new QPainter();
QImage *image = nullptr;
@ -5907,7 +5909,6 @@ void QgisApp::saveMapAsPdf()
}
else
{
printer->setResolution( dlg.dpi() );
p->begin( printer );
}