Skip to content

Commit

Permalink
Use millimeters when declaring QPrinter page size
Browse files Browse the repository at this point in the history
(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 a4b7af7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -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;
Expand All @@ -5907,7 +5909,6 @@ void QgisApp::saveMapAsPdf()
}
else
{
printer->setResolution( dlg.dpi() );
p->begin( printer );
}

Expand Down

0 comments on commit a4b7af7

Please sign in to comment.