当前位置: 首页>>代码示例>>Python>>正文


Python QPrinter.setOutputFormat方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QPrinter.setOutputFormat方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.setOutputFormat方法的具体用法?Python QPrinter.setOutputFormat怎么用?Python QPrinter.setOutputFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QPrinter的用法示例。


在下文中一共展示了QPrinter.setOutputFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: printProfile

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
    def printProfile(self):
        printer = QPrinter(QPrinter.HighResolution)
        printer.setOutputFormat(QPrinter.PdfFormat)
        printer.setPaperSize(QPrinter.A4)
        printer.setOrientation(QPrinter.Landscape)

        printpreviewdlg = QPrintPreviewDialog()
        printpreviewdlg.paintRequested.connect(self.printRequested)

        printpreviewdlg.exec_()
开发者ID:QGEP,项目名称:qgepplugin,代码行数:12,代码来源:qgepplotsvgwidget.py

示例2: exportPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
    def exportPDF(self, view, file_name, width, height):
        pdf = QPrinter()
        pdf.setOutputFormat(QPrinter.PdfFormat)
        pdf.setPrintRange(QPrinter.AllPages)
        pdf.setOrientation(QPrinter.Portrait)
        pdf.setResolution(QPrinter.HighResolution)
        pdf.setPaperSize(QSizeF(width, height), QPrinter.Point)
        pdf.setFullPage(True)
        pdf.setOutputFileName(file_name)
        view.mainFrame().print_(pdf)

        QApplication.restoreOverrideCursor()
开发者ID:danielfmva,项目名称:ert,代码行数:14,代码来源:export_plot.py

示例3: save_report

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
    def save_report(self):
        """Save report"""
        filename = QFileDialog.getSaveFileName(
            self, "Save Report", self.save_dir,
            "HTML (*.html);;PDF (*.pdf);;Report (*.report)")
        if not filename:
            return QDialog.Rejected

        self.save_dir = os.path.dirname(filename)
        self.saveSettings()
        _, extension = os.path.splitext(filename)
        if extension == ".pdf":
            printer = QPrinter()
            printer.setPageSize(QPrinter.A4)
            printer.setOutputFormat(QPrinter.PdfFormat)
            printer.setOutputFileName(filename)
            self.report_view.print_(printer)
        elif extension == ".report":
            with open(filename, 'wb') as f:
                pickle.dump(self, f)
        else:
            frame = self.report_view.page().currentFrame()
            with open(filename, "w") as f:
                f.write(frame.documentElement().toInnerXml())
        self.report_changed = False
        return QDialog.Accepted
开发者ID:karoema,项目名称:orange3,代码行数:28,代码来源:owreport.py

示例4: plotPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
    def plotPDF(self, width, height, output_file, units = "pixels", _plotting_object = None):

        """Plots the data specified in the current input file as a page in a
        PDF file with the given width and height, writing the output to the
        specified output file. The optional units argument specifies the units
        used to measure the plot size; by default, pixels are used, but "cm",
        "mm" and "in" are also acceptable.
        
        Returns the QPrinter object used to write the file."""

        pdf = QPrinter()
        pdf.setOutputFormat(QPrinter.PdfFormat)
        pdf.setOutputFileName(output_file)
        
        if units == "in":
            width = pdf.logicalDpiX() * width
            height = pdf.logicalDpiY() * height
        elif units == "cm":
            width = pdf.logicalDpiX() * (width / 2.54)
            height = pdf.logicalDpiY() * (height / 2.54)
        elif units == "mm":
            width = pdf.logicalDpiX() * (width / 25.4)
            height = pdf.logicalDpiY() * (height / 25.4)
        elif units != "pixels":
            raise BDianaError, "Unknown units specified to plotPDF: %s" % units

        pdf.setPaperSize(QSizeF(width, height), QPrinter.DevicePixel)
        pdf.setFullPage(True)
        return self._plot(width, height, pdf, _plotting_object)[0]
开发者ID:metno,项目名称:python-diana,代码行数:31,代码来源:bdiana.py

示例5: print_pdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
	def print_pdf(self):
		if self.deck is not None:
			#Setting the printer
			printer = QPrinter(QPrinter.HighResolution)
			printer.setOutputFormat(QPrinter.PdfFormat)
			printer.setOrientation(getattr(QPrinter, "Portrait"))
			printer.setOutputFileName(self.path)
			printer.setPaperSize(getattr(QPrinter, self.paper))
			printer.setFullPage(True)
			guide = self.max_cards()
			printer.setOrientation(getattr(QPrinter, guide["orientation"]))
			print guide, self.card_size
			#Start printing
			with QPainter(printer) as paint:
				ind = 0
				resol = printer.resolution()
				for c in self.deck:
						c.resize(self.card_size[0], self.card_size[1])
						if ind == guide["max"]:
							printer.newPage()
							ind = 0

						col = ind % guide["horizontal"]
						fil = ind // guide["horizontal"]
						print ind, fil, col
						target = QRectF((col)*self.card_size[0]*resol, (fil)*self.card_size[1]*resol,
									self.card_size[0]*resol, self.card_size[1]*resol)

						self.preview_card(c)
						self.scene.render(paint, target=target, source=QRectF(0,0,c.width(),c.height()))
						ind += 1
开发者ID:Ja-vi,项目名称:pnp,代码行数:33,代码来源:printer.py

示例6: print_to_pdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
    def print_to_pdf(self,
                     path,
                     paper_size    = (8.5, 11.0),
                     paper_margins = (0, 0, 0, 0),
                     paper_units   = QPrinter.Inch,
                     zoom_factor   = 1.0,
                     ):
        """Saves page as a pdf file.

        See qt4 QPrinter documentation for more detailed explanations
        of options.

        :param path: The destination path.
        :param paper_size: A 2-tuple indicating size of page to print to.
        :param paper_margins: A 4-tuple indicating size of each margin.
        :param paper_units: Units for pager_size, pager_margins.
        :param zoom_factor: Scale the output content.
        """
        assert len(paper_size) == 2
        assert len(paper_margins) == 4
        printer = QPrinter(mode = QPrinter.ScreenResolution)
        printer.setOutputFormat(QPrinter.PdfFormat)
        printer.setPaperSize(QtCore.QSizeF(*paper_size), paper_units)
        printer.setPageMargins(*(paper_margins + (paper_units,)))
        printer.setFullPage(True)
        printer.setOutputFileName(path)
        if self.webview is None:
          self.webview = QtWebKit.QWebView()
          self.webview.setPage(self.page)
        self.webview.setZoomFactor(zoom_factor)
        self.webview.print_(printer)
开发者ID:Awesoham,项目名称:Ghost.py,代码行数:33,代码来源:ghost.py

示例7: printPage

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
def printPage(ok):
    printer = QPrinter()
    printer.setOutputFormat(QPrinter.PdfFormat)
    printer.setOrientation(QPrinter.Landscape)
    printer.setPageMargins(0.1,0.1,0.1,0.1, QPrinter.Millimeter)
    printer.setOutputFileName(sys.argv[2])
    view.print_(printer)    
    app.exit()
开发者ID:anjohnson,项目名称:pvDataWWW,代码行数:10,代码来源:qtweb.py

示例8: writePdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
def writePdf(dir_):
    newbody = originHTML.format(**htmlpara)

    printer = QPrinter()
    printer.setOutputFormat(QPrinter.PdfFormat)
    printer.setOutputFileName(dir_+'.pdf')
    printer.setPageSize(QPrinter.A4)
    text = QTextDocument()
    text.setHtml(newbody.decode('utf-8'))
    text.print_(printer)
开发者ID:lidingke,项目名称:fiberGeometry,代码行数:12,代码来源:pdf.py

示例9: __saveAsPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
    def __saveAsPDF( self, fileName ):
        " Saves the flowchart as an PDF file "
        printer = QPrinter()
        printer.setOutputFormat( QPrinter.PdfFormat )
        printer.setPaperSize( QSizeF( self.scene.width(),
                                      self.scene.height() ), QPrinter.Point )
        printer.setFullPage( True )
        printer.setOutputFileName( fileName )

        painter = QPainter( printer )
        self.scene.render( painter )
        painter.end()
        return
开发者ID:fukanchik,项目名称:codimension,代码行数:15,代码来源:flowuiwidget.py

示例10: WebKitPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
class WebKitPDF ( QObject ):

  def __init__ ( self, url, dest ):
    QObject.__init__ ( self )
    self.dest = dest
    self.page = QtWebKit.QWebPage ( self )
    self.mainFrame = self.page.mainFrame()
    self.mainFrame.load ( QUrl ( url ) )

    # Settings
    # Disable the scrollbars
    self.mainFrame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
    self.mainFrame.setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)

    self.connect ( self.page,
             SIGNAL ( "loadProgress(int)" ),
             self.loadProgress )

    self.connect ( self.page,
             SIGNAL ( "loadFinished(bool)" ),
             self.renderPDF )



  def loadProgress ( self, progress ):
    print "Progress: ", progress


  def renderPDF ( self, status ):
    print "Load finished with status: ", status
    print "Rendering PDF ..."

    contentsSize = self.mainFrame.contentsSize()
    contentsSize.setWidth(1280)
    self.page.setViewportSize ( contentsSize )

    self.printer = QPrinter ( QPrinter.PrinterResolution )
    #self.printer = QPrinter ( QPrinter.ScreenResolution )
    self.printer.setOutputFormat ( QPrinter.PdfFormat )
    #self.printer.setPaperSize ( QPrinter.A4 )
    self.printer.setFullPage( True )
    self.printer.setPaperSize ( QSizeF( contentsSize ), QPrinter.DevicePixel )
    self.printer.setOrientation ( QPrinter.Portrait )
    self.printer.setOutputFileName ( self.dest )

    self.painter = QPainter ( self.printer )
    self.painter.setRenderHint ( QPainter.Antialiasing )
    self.mainFrame.render ( self.painter )
    self.painter.end()
    app = QtGui.QApplication.instance()
    app.exit ( 0 )
开发者ID:kholidfu,项目名称:htmlkepdf,代码行数:53,代码来源:gistfile2.py

示例11: init_print

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
 def init_print(self, linenos=True, style="default"):
     app = QApplication(sys.argv)  # noqa
     doc = QTextDocument()
     doc.setHtml(
         self.highlight_file(linenos=linenos, style=style)
     )
     printer = QPrinter()
     printer.setOutputFileName(self.pdf_file)
     printer.setOutputFormat(QPrinter.PdfFormat)
     page_size_dict = {"a2": QPrinter.A2, "a3": QPrinter.A3, "a4": QPrinter.A4}
     printer.setPageSize(page_size_dict.get(self.size.lower(), QPrinter.A4))
     printer.setPageMargins(15, 15, 15, 15, QPrinter.Millimeter)
     doc.print_(printer)
     logging.info("PDF created at %s" % (self.pdf_file))
开发者ID:et0803,项目名称:code2pdf,代码行数:16,代码来源:code2pdf.py

示例12: writePdfabs

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
def writePdfabs(dir_):
    updates = PDF_PARAMETER
    htmlpara.update(updates)
    newbody = originHTML.format(**htmlpara)
    # with open('t.html', 'wb') as f:
    #     f.write(newbody)
    #     f.close()
    printer = QPrinter()
    printer.setOutputFormat(QPrinter.PdfFormat)
    printer.setOutputFileName(dir_)
    printer.setPageSize(QPrinter.A4)
    text = QTextDocument()
    text.setHtml(newbody.decode('utf-8'))
    text.print_(printer)
开发者ID:lidingke,项目名称:fiberGeometry,代码行数:16,代码来源:pdf.py

示例13: render_pdf

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
 def render_pdf(self, page, fileName, paperSize=None):
     """Renders the page into a pdf
     :param page: The webpage that we want to render
     :param fileName: The path where we want to save the pdf.
         For example /home/user/mypdf.pdf
     :param paperSize: An PaperSize object that will be used
         to render the webpage
     """
     mainFrame = page.currentFrame()
     
     printer = QPrinter()
     printer.setOutputFormat(QPrinter.PdfFormat)
     printer.setOutputFileName(fileName)
     printer.setResolution(self._get_default_dpi())
     
     if paperSize is None:
         ps = mainFrame.contentsSize()
         paperSize = PaperSize(width=ps.width(),
                 height=ps.width(),
                 margin=(0, 0, 0, 0),
                 orientation=None,
                 page_type=None)
         
     
     if paperSize.page_type is not None:
         if paperSize.orientation.lower() == "landscape":
             orientation = QPrinter.Landscape
         else:
             orientation = QPrinter.Portrait
         printer.setOrientation(orientation)
         
         printer.setPaperSize(QPrinter.A4) # Fallback
         for f in self.PAGE_TYPE:
             if paperSize.page_type.lower() == f[0].lower():
                 printer.setPaperSize(f[1])
                 break
     else:
         sizePt = QSizeF(paperSize.width, 
                         paperSize.height)
         printer.setPaperSize(sizePt, QPrinter.Point)
        
     printer.setPageMargins(paperSize.margin[0],
                            paperSize.margin[1],
                            paperSize.margin[2],
                            paperSize.margin[3],
                            QPrinter.Point)
     mainFrame.print_(printer)
开发者ID:a1939228,项目名称:Ghost.py,代码行数:49,代码来源:pdf.py

示例14: print_grid

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
	def print_grid(self):
		if self.deck is not None:
			#Setting the printer
			printer = QPrinter(QPrinter.HighResolution)
			printer.setOutputFormat(QPrinter.PdfFormat)
			printer.setOrientation(getattr(QPrinter, self.orientation))
			printer.setOutputFileName(self.path)
			printer.setPaperSize(getattr(QPrinter, self.paper))
			#Start printing
			with QPainter(printer) as paint:
				first = True
				for c in self.deck:
					if not first:
						printer.newPage()
					first = False
					self.preview_card(c)
					self.scene.render(paint)
开发者ID:Ja-vi,项目名称:pnp,代码行数:19,代码来源:printer.py

示例15: __outPDF

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setOutputFormat [as 别名]
 def __outPDF(self):
     """
     To save the profile as pdf file
     """
     fileName = QFileDialog.getSaveFileName(
         self.__iface.mainWindow(), QCoreApplication.translate("VDLTools", "Save As"),
         QCoreApplication.translate("VDLTools", "Profile.pdf"),"Portable Document Format (*.pdf)")
     if fileName is not None:
         if self.__lib == 'Qwt5':
             printer = QPrinter()
             printer.setCreator(QCoreApplication.translate("VDLTools", "QGIS Profile Plugin"))
             printer.setOutputFileName(fileName)
             printer.setOutputFormat(QPrinter.PdfFormat)
             printer.setOrientation(QPrinter.Landscape)
             self.__plotWdg.print_(printer)
         elif self.__lib == 'Matplotlib':
             self.__plotWdg.figure.savefig(str(fileName))
开发者ID:gusthiot,项目名称:VDLTools,代码行数:19,代码来源:profile_dock_widget.py


注:本文中的PyQt4.QtGui.QPrinter.setOutputFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。