test.py

script producing test.pdf - Radim Blazek, 2013-11-30 05:02 AM

Download (530 Bytes)

 
1
import sys
2
from PyQt4.QtCore import *
3
from PyQt4.QtGui import *
4

    
5
app = QApplication(sys.argv)
6

    
7
printer = QPrinter ( QPrinter.HighResolution )
8
printer.setOutputFormat ( QPrinter.PdfFormat )
9
printer.setOutputFileName ( 'test.pdf' )
10

    
11
w = 10
12
h = 10
13
image = QImage( w, h, QImage.Format_ARGB32 )
14
image.fill( qRgba( 255, 255, 255, 255 ) )
15

    
16
for i in range(w):
17
  for j in range(h-i):
18
    image.setPixel( i, j, qRgba( 0, 0, 0, 0 ) )
19

    
20
painter = QPainter ( printer )
21
painter.drawImage ( QRect(3000, 3000, 3000, 3000), image )
22
painter.end()
23

    
24