本文整理汇总了Python中PyQt4.QtGui.QTextDocument.setPageSize方法的典型用法代码示例。如果您正苦于以下问题:Python QTextDocument.setPageSize方法的具体用法?Python QTextDocument.setPageSize怎么用?Python QTextDocument.setPageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTextDocument
的用法示例。
在下文中一共展示了QTextDocument.setPageSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PyQt4.QtGui import QTextDocument [as 别名]
# 或者: from PyQt4.QtGui.QTextDocument import setPageSize [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()
示例2: QTextDocument
# 需要导入模块: from PyQt4.QtGui import QTextDocument [as 别名]
# 或者: from PyQt4.QtGui.QTextDocument import setPageSize [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)