Skip to content
Permalink
Browse files
Use millimeters when declaring QPrinter page size
(This is needed to allow to set a resolution with the printer used
by the map renderer)
  • Loading branch information
nirvn committed May 14, 2017
1 parent f8f7d60 commit a4b7af7fad45980bef96705d39f3b798eac2cb59
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/app/qgisapp.cpp
@@ -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 );
}

0 comments on commit a4b7af7

Please sign in to comment.