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


Python QTextDocument.setPageSize方法代码示例

本文整理汇总了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()
开发者ID:rusticmystic,项目名称:kabit_gurdas_bhalla,代码行数:38,代码来源:create_pdf.py

示例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)
开发者ID:rusticmystic,项目名称:demo_sources,代码行数:33,代码来源:kabit_pdf.py


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