code: def print_preview(self):
          
          from qtpy.QtPrintSupport import QPrintPreviewDialog
  
          editor = self.get_current_editor()
          printer = Printer(mode=QPrinter.HighResolution,
                            header_font=self.get_plugin_font('printer_header'))
          preview = QPrintPreviewDialog(printer, self)
          preview.setWindowFlags(Qt.Window)
          preview.paintRequested.connect(lambda printer: editor.print_(printer))
          self.redirect_stdio.emit(False)
          preview.exec_()
          self.redirect_stdio.emit(True)
docs: Print preview for current file