File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -370,6 +370,7 @@ void MainWindow::print_action() {
370
370
QRectF paint_rect = layout.paintRect (QPageLayout::Point );
371
371
QSize pointsize = pagesize.sizePoints ();
372
372
qreal ratio = scene_rect.width () / scene_rect.height ();
373
+ // Cut off the excess
373
374
if (paint_rect.height () * ratio > paint_rect.width ()) {
374
375
pointsize.setHeight (
375
376
pointsize.height () - paint_rect.height () + paint_rect.width () / ratio);
@@ -383,6 +384,12 @@ void MainWindow::print_action() {
383
384
}
384
385
385
386
QPainter painter (&printer);
387
+ // scale to fit paint size
388
+ QRectF paint_rect = printer.pageLayout ().paintRect (QPageLayout::Millimeter);
389
+ double xscale = paint_rect.width () / scene_as_vector.widthMM ();
390
+ double yscale = paint_rect.height () / scene_as_vector.heightMM ();
391
+ double scale = qMin (xscale, yscale);
392
+ painter.scale (scale, scale);
386
393
painter.drawPicture (0 , 0 , scene_as_vector);
387
394
painter.end ();
388
395
}
You can’t perform that action at this time.
0 commit comments