void QgsComposition::beginPrintAsPDF( QPrinter& printer, const QString& file ) { printer.setOutputFormat( QPrinter::PdfFormat ); printer.setOutputFileName( file ); printer.setPaperSize( QSizeF( paperWidth(), paperHeight() ), QPrinter::Millimeter ); QgsPaintEngineHack::fixEngineFlags( printer.paintEngine() ); }
QImage QgsComposition::printPageAsRaster( int page ) { //print out via QImage, code copied from on_mActionExportAsImage_activated int width = ( int )( printResolution() * paperWidth() / 25.4 ); int height = ( int )( printResolution() * paperHeight() / 25.4 ); QImage image( QSize( width, height ), QImage::Format_ARGB32 ); if ( !image.isNull() ) { image.setDotsPerMeterX( printResolution() / 25.4 * 1000 ); image.setDotsPerMeterY( printResolution() / 25.4 * 1000 ); image.fill( 0 ); QPainter imagePainter( &image ); renderPage( &imagePainter, page ); } return image; }