本文整理汇总了Python中PyQt4.QtGui.QPrinter.pageRect方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.pageRect方法的具体用法?Python QPrinter.pageRect怎么用?Python QPrinter.pageRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QPrinter
的用法示例。
在下文中一共展示了QPrinter.pageRect方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_actionFitPage_triggered
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
def on_actionFitPage_triggered(self):
papersize = self._getPaperSize()
printer = QPrinter()
printer.setPaperSize(papersize)
widthInPixels = printer.pageRect().width()
maxColumns = self.songProperties.maxColumns(widthInPixels)
self.widthSpinBox.setValue(maxColumns)
self.scoreScene.reBuild()
示例2: _exportCompositionAsPDF
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
def _exportCompositionAsPDF(self,composition,filePath):
"""
Render the composition as a PDF file.
"""
printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(filePath)
printer.setPaperSize(QSizeF(composition.paperWidth(),composition.paperHeight()),QPrinter.Millimeter)
printer.setFullPage(True)
printer.setColorMode(QPrinter.Color)
printer.setResolution(composition.printResolution())
#Use painter to send output to printer
pdfPainter = QPainter(printer)
paperRectMM = printer.pageRect(QPrinter.Millimeter)
paperRectPixel = printer.pageRect(QPrinter.DevicePixel)
composition.render(pdfPainter,paperRectPixel,paperRectMM)
pdfPainter.end()
示例3: __init__
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
def __init__(self, parent = None, fakeStartup = False, filename = None):
'''
Constructor
'''
self._fakeStartup = fakeStartup
super(DrumBurp, self).__init__(parent)
self._state = None
self._asciiSettings = None
self._printer = None
self.setupUi(self)
self.scoreScene = None
self.paperBox.blockSignals(True)
self.paperBox.clear()
self._knownPageHeights = []
printer = QPrinter()
printer.setOutputFileName("invalid.pdf")
for name in dir(QPrinter):
attr = getattr(QPrinter, name)
if (isinstance(attr, QPrinter.PageSize)
and name != "Custom"):
self.paperBox.addItem(name)
printer.setPaperSize(attr)
self._knownPageHeights.append(printer.pageRect().height())
self._pageHeight = printer.paperRect().height()
self.paperBox.blockSignals(False)
settings = self._makeQSettings()
self.recentFiles = [unicode(fname) for fname in
settings.value("RecentFiles").toStringList()
if os.path.exists(unicode(fname))]
if filename is None:
filename = (None
if len(self.recentFiles) == 0
else self.recentFiles[0])
self.filename = filename
self.addToRecentFiles()
self.updateRecentFiles()
self.songProperties = QDisplayProperties()
# Create scene
self.scoreScene = QScore(self)
self.restoreGeometry(settings.value("Geometry").toByteArray())
self.restoreState(settings.value("MainWindow/State").toByteArray())
self.statusbar.addPermanentWidget(QFrame())
self.availableNotesLabel = QLabel()
self.availableNotesLabel.setMinimumWidth(250)
self.statusbar.addPermanentWidget(self.availableNotesLabel)
self._infoBar = QLabel()
self.statusbar.addPermanentWidget(self._infoBar)
self._initializeState()
self.setSections()
QTimer.singleShot(0, self._startUp)
self.actionCheckOnStartup.setChecked(settings.value("CheckOnStartup").toBool())
示例4: main
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
def main():
app = QApplication(sys.argv)
# Preparing the pdf
doc = QTextDocument()
printer = QPrinter()
printer.setOutputFileName("KabitGurdas.pdf")
printer.setOutputFormat(QPrinter.PdfFormat)
# Setting page size as A5
printer.setPaperSize(QPrinter.A5);
# page margin
printer.setPageMargins(12, 16, 12, 20, QPrinter.Millimeter)
doc.setPageSize(QSizeF(printer.pageRect().size()))
painter = QPainter()
painter.begin( printer )
# Set poem book and get each poem in pdf
book = kb()
for KabitNumber in range(1,676):
# Add text in html to page
doc.setHtml(book.getKabitHTML(KabitNumber))
doc.defaultFont().setPointSize(20)
# A new page
printer.newPage()
# Create a QPainter to draw our content
doc.drawContents(painter)#,printer.pageRect().translated( -printer.pageRect().x(), -printer.pageRect().y() ))
#QTextDocument.drawContents(QPainter, QRectF rect=QRectF())
doc.print_(printer)
# Done.
painter.end()
示例5: MainWindow
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
#.........这里部分代码省略.........
editconds = QAction(QIcon('exit.png'), 'Edit Conditions', self)
editconds.setStatusTip('Edit the conditions of the current reaction')
editconds.triggered.connect(self.editcd)
self.optionsmenu.addAction(editconds)
# About - Version
version = QAction(QIcon('exit.png'), 'Version 1.1', self)
version.setStatusTip('The version of this program you are using')
# Widget of editable reactions
self._ReactionsWindow = ReactionWidget()
self._ReactionsWindow.setGeometry(0, 20, 600, 380)
self._ReactionsWindow.setParent(self)
# Widget of non-editable reaction, for comparison
self._ComparingProfile = ReactionProfile(self._ReactionsWindow.GetCurrentReaction(), True)
self._ComparingProfile.setGeometry(600, 40, 600, 380)
self._ComparingProfile.setParent(self)
self.aboutmenu.addAction(version)
self.show()
# You should call the shownew(), showopen() etc. methods,
# not the new(), open() etc. methods, as a) they do not provide user options;
# b) it may lead to errors; c) the showing methods call them anyway
def editcd(self):
self._ReactionsWindow.EditReaction()
def showopen(self):
fileaddress = QFileDialog.getOpenFileName(self, "Open...", "", "Simulator Files (*.rctn)")
if fileaddress != "":
self.open(fileaddress)
self.setWindowTitle(fileaddress+" - "+self._TITLE)
def open(self, fileaddress):
openfrom = open(fileaddress, "rb")
loadedfile = pickle.load(openfrom)
openfrom.close()
file = open("last.ptr", "w")
file.write(fileaddress)
file.close()
self._ReactionsWindow.SetOpenReactionFile(loadedfile)
self.setWindowTitle(fileaddress+" - "+self._TITLE)
def save(self):
self._ReactionsWindow.save()
def showsaveas(self):
self._ReactionsWindow.showsaveas()
def shownew(self):
self._newfilebox = QMessageBox()
self._newfilebox.setWindowTitle("Save?")
self._newfilebox.setText("Would you like to save this file before opening a new one?")
self._newfilebox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
self._newfilebox.setDefaultButton(QMessageBox.Yes)
if self._newfilebox.exec_() == QMessageBox.Yes:
file = open("last.ptr", "w")
file.write("")
file.close()
self.save()
self.setWindowTitle(self._TITLE)
self._ReactionsWindow.SetOpenReactionFile(ReactionFile())
def showprint(self):
self._printbox = QPrintDialog(self)
if self._printbox.exec_() == QDialog.Accepted:
self.printout()
def printout(self):
# Page width, page height, widget width
pw = self._printer.pageRect().width()
ph = self._printer.pageRect().height()
ww = self._ComparingProfile.width()
painter = QPainter(self._printer)
scale = (ww / pw) * 1.5
painter.scale(scale, scale)
self._ReactionsWindow.currentWidget().render(painter)
painter.translate(0, ph/2)
self._ComparingProfile.render(painter)
painter.translate(pw * 0.6, -ph/2)
painter.scale(0.8, 0.8)
self._ReactionsWindow.currentWidget().PrintGraph(painter, "Concentration")
painter.translate(0, ph*0.25)
self._ReactionsWindow.currentWidget().PrintGraph(painter, "Rate")
painter.translate(0, ph * 0.4)
self._ComparingProfile.PrintGraph(painter, "Concentration")
painter.translate(0, ph * 0.25)
self._ComparingProfile.PrintGraph(painter, "Rate")
painter.end()
# GETTERS AND SETTERS
def GetWindowTitle(self):
return self._TITLE
def SetComparingReaction(self, reaction):
self._ComparingProfile.SetReaction(reaction)
self._ComparingProfile.update()
def GetComparingReaction(self):
return self._ComparingProfile.GetReaction()
示例6: save
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
def save(self, imgName, w=None, h=None, header=None, \
dpi=150, take_region=False):
ext = imgName.split(".")[-1].upper()
root = self.startNode
#aspect_ratio = root.fullRegion.height() / root.fullRegion.width()
aspect_ratio = self.i_height / self.i_width
# auto adjust size
if w is None and h is None and (ext == "PDF" or ext == "PS"):
w = dpi * 6.4
h = w * aspect_ratio
if h>dpi * 11:
h = dpi * 11
w = h / aspect_ratio
elif w is None and h is None:
w = self.i_width
h = self.i_height
elif h is None :
h = w * aspect_ratio
elif w is None:
w = h / aspect_ratio
if ext == "SVG":
svg = QtSvg.QSvgGenerator()
svg.setFileName(imgName)
svg.setSize(QtCore.QSize(w, h))
svg.setViewBox(QtCore.QRect(0, 0, w, h))
#svg.setTitle("SVG Generator Example Drawing")
#svg.setDescription("An SVG drawing created by the SVG Generator")
pp = QtGui.QPainter()
pp.begin(svg)
targetRect = QtCore.QRectF(0, 0, w, h)
self.render(pp, targetRect, self.sceneRect())
pp.end()
elif ext == "PDF" or ext == "PS":
format = QPrinter.PostScriptFormat if ext == "PS" else QPrinter.PdfFormat
printer = QPrinter(QPrinter.HighResolution)
printer.setResolution(dpi)
printer.setOutputFormat(format)
printer.setPageSize(QPrinter.A4)
pageTopLeft = printer.pageRect().topLeft()
paperTopLeft = printer.paperRect().topLeft()
# For PS -> problems with margins
# print paperTopLeft.x(), paperTopLeft.y()
# print pageTopLeft.x(), pageTopLeft.y()
# print printer.paperRect().height(), printer.pageRect().height()
topleft = pageTopLeft - paperTopLeft
printer.setFullPage(True);
printer.setOutputFileName(imgName);
pp = QtGui.QPainter(printer)
if header:
pp.setFont(QtGui.QFont("Verdana",12))
pp.drawText(topleft.x(),20, header)
targetRect = QtCore.QRectF(topleft.x(), 20 + (topleft.y()*2), w, h)
else:
targetRect = QtCore.QRectF(topleft.x(), topleft.y()*2, w, h)
if take_region:
self.selector.setVisible(False)
self.render(pp, targetRect, self.selector.rect())
self.selector.setVisible(True)
else:
self.render(pp, targetRect, self.sceneRect())
pp.end()
return
else:
targetRect = QtCore.QRectF(0, 0, w, h)
ii= QtGui.QImage(w, \
h, \
QtGui.QImage.Format_ARGB32)
pp = QtGui.QPainter(ii)
pp.setRenderHint(QtGui.QPainter.Antialiasing )
pp.setRenderHint(QtGui.QPainter.TextAntialiasing)
pp.setRenderHint(QtGui.QPainter.SmoothPixmapTransform)
if take_region:
self.selector.setVisible(False)
self.render(pp, targetRect, self.selector.rect())
self.selector.setVisible(True)
else:
self.render(pp, targetRect, self.sceneRect())
pp.end()
ii.save(imgName)
示例7: Printer
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
class Printer(BasePrinter):
FONT_NAME = 'Courrier'
def __init__(self, *args, **kwargs):
BasePrinter.__init__(self, *args, **kwargs)
self.page_number = 0
self.printer = QPrinter(QPrinter.HighResolution)
## todo: remove-me
self.printer.setOutputFileName("ufwi_log-page.pdf")
self.printer.setOutputFormat(QPrinter.NativeFormat)
#self.printer.setOrientation(QPrinter.Landscape)
self.printer.setPaperSize(QPrinter.A4)
self.printer.setResolution(100)
def _init_painter(self):
self.painter = QPainter(self.printer)
self.painter.setRenderHint(QPainter.Antialiasing)
self.painter.setBackgroundMode(Qt.OpaqueMode)
self.painter.setBrush(Qt.white)
self.painter.setFont(QFont(self.FONT_NAME, 9))
fillrect = QRect(0, 0, self.printer.pageRect().width(), self.printer.pageRect().height())
self.painter.fillRect(fillrect, self.painter.brush())
self.page_number = 1
self._draw_header()
self._draw_footer()
self.drawCentralTitle(self.title)
if self.logo:
self.painter.drawImage(QPoint(self.width() / 2 - self.logo.width() / 2,
self.height() / 2 + QFontMetrics(self.painter.font()).height() + self.height() / 4 - self.logo.height() / 2),
self.logo)
def _draw_header(self):
if not self.header_enabled:
return
h = -self.headerHeight()
self.drawText(QDateTime.currentDateTime().toString('yyyy-MM-dd hh:mm'), h, Qt.AlignLeft)
h += self.drawText(self.interval_label, h, Qt.AlignRight)
self.drawText(self.title, h, Qt.AlignLeft)
self.drawText(self.enterprise, h, Qt.AlignRight)
self.painter.drawLine(0,
self.headerHeight() - 1,
self.printer.pageRect().width(),
self.headerHeight() - 1)
def _draw_footer(self):
if not self.footer_enabled:
return
self.painter.drawLine(10,
self.printer.pageRect().height() - self.footerHeight(),
self.printer.pageRect().width() - 10,
self.printer.pageRect().height() - self.footerHeight())
h = self.height() + 1
#self.drawText('topleft', h, Qt.AlignLeft)
h += self.drawText(u'© 2008-2010 EdenWall', h, Qt.AlignRight, size=9)
self.drawText(unicode(self.page_number), h, Qt.AlignHCenter)
#self.drawText('bottomright', h, Qt.AlignRight)
def headerHeight(self):
if self.header_enabled:
return 40
else:
return 0
def footerHeight(self):
if self.footer_enabled:
return 40
else:
return 0
def height(self):
return self.printer.pageRect().height() - self.headerHeight() - self.footerHeight()
def width(self):
return self.printer.pageRect().width()
def showDialog(self, parent):
dialog = QPrintDialog(self.printer, parent)
if dialog.exec_() != QPrintDialog.Accepted:
return False
self._init_painter()
return True
def end(self):
self.painter.end()
def newPage(self):
self.printer.newPage()
self.page_number += 1
self._draw_header()
self._draw_footer()
def drawCentralTitle(self, text):
self.painter.setBackgroundMode(Qt.TransparentMode)
#.........这里部分代码省略.........
示例8: export_all_features
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
#.........这里部分代码省略.........
new_ext.setXMinimum(bbox.xMinimum() - delta_width / 2)
new_ext.setXMaximum(bbox.xMaximum() + delta_width / 2)
if VRP_DEBUG is True: QgsMessageLog.logMessage(u'bbox old:{0}'.format(compmap.extent().toString()), DLG_CAPTION)
compmap.setNewExtent(new_ext)
if VRP_DEBUG is True: QgsMessageLog.logMessage(u'bbox new:{0}'.format(compmap.extent().toString()), DLG_CAPTION)
#round up to next 1000
compmap.setNewScale(math.ceil((compmap.scale()/1000.0)) * 1000.0)
if VRP_DEBUG is True: QgsMessageLog.logMessage(u'bbox new (after scale):{0}'.format(compmap.extent().toString()), DLG_CAPTION)
#add ORTHO after new extent -> performance
if not self.ortho is None:
self.ortho_lyr = self.__add_raster_layer(self.ortho, self.lyrname_ortho)
self.__reorder_layers()
self.comp_leg = self.__get_items(QgsComposerLegend)
self.comp_lbl = self.__get_items(QgsComposerLabel)
self.__update_composer_items(self.settings.dkm_gemeinde(self.gem_name)['lyrnamegstk'])
if VRP_DEBUG is True:
QgsMessageLog.logMessage(u'paperWidth:{0} paperHeight:{1}'.format(composition.paperWidth(), composition.paperHeight()), DLG_CAPTION)
printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(self.pdf_map)
printer.setPaperSize(QSizeF(composition.paperWidth(), composition.paperHeight()), QPrinter.Millimeter)
printer.setFullPage(True)
printer.setColorMode(QPrinter.Color)
printer.setResolution(composition.printResolution())
pdf_painter = QPainter(printer)
paper_rect_pixel = printer.pageRect(QPrinter.DevicePixel)
paper_rect_mm = printer.pageRect(QPrinter.Millimeter)
QgsPaintEngineHack.fixEngineFlags(printer.paintEngine())
#DKM only
if len(self.themen) < 1:
composition.render(pdf_painter, paper_rect_pixel, paper_rect_mm)
else:
self.statistics = OrderedDict()
try:
pass
#lyr = QgsVectorLayer('/home/bergw/VoGIS-Raumplanung-Daten/Geodaten/Raumplanung/Flaechenwidmung/Dornbirn/Flaechenwidmungsplan/fwp_flaeche.shp', 'flaeiw', 'ogr')
#lyr.loadNamedStyle('/home/bergw/VoGIS-Raumplanung-Daten/Geodaten/Raumplanung/Flaechenwidmung/Vorarlberg/Flaechenwidmungsplan/fwp_flaeche.qml')
#QgsMapLayerRegistry.instance().addMapLayer(lyr)
except:
QgsMessageLog.logMessage('new lyr:{0}'.format(sys.exc_info()[0]), DLG_CAPTION)
#QgsMapLayerRegistry.instance().addMapLayer(lyr)
cntr = 0
for thema, sub_themen in self.themen.iteritems():
if VRP_DEBUG is True: QgsMessageLog.logMessage('drucke Thema:{0}'.format(thema.name), DLG_CAPTION)
if sub_themen is None:
layers = self.__add_layers(thema)
self.__calculate_statistics(thema, thema, layers)
#no qml -> not visible -> means no map
if self.__at_least_one_visible(layers) is True:
if cntr > 0:
printer.newPage()
self.__reorder_layers()
self.__update_composer_items(thema.name, layers=layers)
composition.renderPage(pdf_painter, 0)
QgsMapLayerRegistry.instance().removeMapLayers([lyr.id() for lyr in layers])
cntr += 1
else:
QgsMapLayerRegistry.instance().removeMapLayers([lyr.id() for lyr in layers])
示例9: QTextDocument
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
Pun = u"punjabi"
Hin = u"hindi"
Tr = u"english"
Ro = u"roman"
# Preparing the pdf
doc = QTextDocument()
printer = QPrinter()
printer.setOutputFileName("KabitGurdas2.pdf")
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setPaperSize(QPrinter.A4)
# page margin
printer.setPageMargins(12, 16, 12, 20, QPrinter.Millimeter)
doc.setPageSize(QSizeF(printer.pageRect().size()))
# We have a database of 675 kabits
KabitRange = range(1, 676)
html = [1] * KabitRange.__len__()
ch = [1] * KabitRange.__len__()
count = 0
painter = QPainter()
painter.begin(printer)
for KabitNumber in KabitRange:
# print KabitNumber
Plist = GetKabitTextList(KabitNumber, Pun)
Elist = GetKabitTextList(KabitNumber, Tr)
示例10: Form
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
class Form(QDialog):
def __init__(self, args=None,parent=None):
super(Form, self).__init__(parent)
self.printer = QPrinter()
self.printer.setPageSize(QPrinter.A4)
self.filename = ''
#File name to convert
lblFileName = QLabel("File Name")
self.txtFileName = QLineEdit()
if len(args) > 1:
self.txtFileName.setText(args[1])
self.filename = args[1]
self.txtFileName.setReadOnly(True)
btnGetFileName = QToolButton()
btnGetFileName.setText("..")
getFileLayout = QHBoxLayout()
getFileLayout.addWidget(lblFileName)
getFileLayout.addWidget(self.txtFileName)
getFileLayout.addWidget(btnGetFileName)
#Code page of file
lblCodePage = QLabel("Code Page")
self.cmbCodePage = QComboBox()
self.cmbCodePage.addItem("dos")
self.cmbCodePage.addItem("windows")
self.cmbCodePage.addItem("utf8")
codePageLayout = QHBoxLayout()
codePageLayout.addStretch()
codePageLayout.addWidget(lblCodePage)
codePageLayout.addWidget(self.cmbCodePage)
#Printer Orientation (Portrait / Landscape)
lblOrientation = QLabel("Orientation")
self.cmbOrientation = QComboBox()
self.cmbOrientation.addItem("portait")
self.cmbOrientation.addItem("landscape")
orientationLayout = QHBoxLayout()
orientationLayout.addStretch()
orientationLayout.addWidget(lblOrientation)
orientationLayout.addWidget(self.cmbOrientation)
#Buttons for save or Just quit
bSave = QPushButton("Go for it")
bQuit = QPushButton("Abort")
buttonLayout = QHBoxLayout()
buttonLayout.addWidget(bQuit)
buttonLayout.addStretch()
buttonLayout.addWidget(bSave)
#Final Layout
layout = QVBoxLayout()
layout.addLayout(getFileLayout)
layout.addLayout(codePageLayout)
layout.addLayout(orientationLayout)
layout.addLayout(buttonLayout)
self.setLayout(layout)
#Connections
self.connect(bSave, SIGNAL("clicked()"),self.printViaQPainter)
self.connect(bQuit, SIGNAL("clicked()"), self.accept)
self.connect(btnGetFileName, SIGNAL("clicked()"),self.getFileName)
self.setWindowTitle("dos/windows text to PDF")
def getFileName(self):
fd = QFileDialog(self)
self.filename = fd.getOpenFileName()
self.txtFileName.setText(self.filename)
def printViaQPainter(self):
from os.path import isfile
if isfile(self.filename):
lines = open(self.filename)
else:
return
a = self.filename.split('.')
s = a[-1]
fname = ''
for i in range(len(a)-1) :
fname += a[i]
fname += '.pdf'
self.printer.setOutputFileName(fname)
self.printer.setOutputFormat(QPrinter.PdfFormat)
if self.cmbOrientation.currentText() == 'landscape':
self.printer.setOrientation(QPrinter.Landscape)
pageRect = self.printer.pageRect()
LeftMargin = 15
biggest = findBiggestLine(self.filename)
bestSize = findBestFontSize(biggest,pageRect)
sansFont = QFont("Courier", bestSize)
sansLineHeight = QFontMetrics(sansFont).height()
painter = QPainter(self.printer)
page = 1
y = 20
cpage = codePage(self.cmbCodePage.currentText())
for line in lines:
painter.save()
painter.setFont(sansFont)
y += sansLineHeight
#.........这里部分代码省略.........
示例11: QPrinter
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import pageRect [as 别名]
compmap.setPreviewMode(QgsComposerMap.Render)
#compmap.updateItem()
#emit compmap.itemChanged();
#compmap.extentChanged();
#compmap.toggleAtlasPreview()
#compmap.setNewScale(compmap.scale()+1)
#c.setPrintResolution(150)
#print c.printResolution()
c.setPrintAsRaster(False)
printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(pdf_out)
printer.setPaperSize(QSizeF(c.paperWidth(), c.paperHeight()), QPrinter.Millimeter)
printer.setFullPage(True)
printer.setColorMode(QPrinter.Color)
printer.setResolution(c.printResolution())
pdfPainter = QPainter(printer)
paperRectMM = printer.pageRect(QPrinter.Millimeter)
paperRectPixel = printer.pageRect(QPrinter.DevicePixel)
QgsPaintEngineHack.fixEngineFlags(printer.paintEngine())
#c.renderPage(pdfPainter, 0)
c.doPrint(printer,pdfPainter)
pdfPainter.end()
subprocess.call(('xdg-open', pdf_out))
print 'FERTIG'