~ubuntu-branches/ubuntu/trusty/pdfposter/trusty-proposed

« back to all changes in this revision

Viewing changes to test/gen-chessboard.py

  • Committer: Package Import Robot
  • Author(s): Elena Grandi, Jakub Wilk, Elena Grandi
  • Date: 2013-05-22 10:03:38 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130522100338-26uo6rmqsurfcfzv
Tags: 0.6.0-1
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Elena Grandi ]
* New upstream release
* Regenerate PDF files from python sources
* Include html documentation
* Updated homepage and author contacts
* debian/control: bump Standards-Version to 3.9.3 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
 
# _*_ coding: UTF-8 _*_
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# Copyright 2008-2013 by Hartmut Goebel <h.goebel@crazy-compilers.com>
 
5
#
 
6
# This program is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
14
# General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
18
#
 
19
"""
 
20
Generate test PDF documents for pdfcrop.
 
21
"""
3
22
 
4
 
"Generate test PDF documents for pdfcrop."
 
23
__author__ = "Hartmut Goebel <h.goebel@crazy-compilers.com>"
 
24
__copyright__ = "Copyright 2008-2013 by Hartmut Goebel <h.goebel@crazy-compilers.com>"
 
25
__licence__ = "GNU General Public License version 3 (GPL v3)"
5
26
 
6
27
from reportlab.lib.units import mm, cm
7
28
from reportlab.lib.colors import black, white, pink, lightblue, blue
9
30
from reportlab.pdfgen.canvas import Canvas
10
31
 
11
32
 
12
 
# not used anymore
13
33
def genTestFile(path, numPages):
14
34
    """Generate a PDF doc with a chess-board laout numbers on each page.
15
35
    Usefull for debugging cropped pages."""
21
41
    for i in range(numPages):
22
42
        canv.setFont("Helvetica", 7*mm)
23
43
        canv.setStrokeColor(black)
24
 
        for x in range(size[0] / stepSize):
25
 
            for y in range(size[1] / stepSize):
 
44
        for x in range(int(size[0] / stepSize)):
 
45
            for y in range(int(size[1] / stepSize)):
26
46
                text = u"%x%x" % (x,y)
27
47
                if (x+y) % 2 == 1:
28
48
                    canv.setFillColor(pink)
39
59
 
40
60
 
41
61
if __name__ == '__main__':
42
 
    genTestFile("chessboard.pdf", 4)
 
62
    import argparse
 
63
    parser = argparse.ArgumentParser()
 
64
    parser.add_argument('-n','--num-pages',
 
65
                        default=1, type=int,
 
66
                        help='number of pages to generate (default: %(default)s)')
 
67
    parser.add_argument('filename',
 
68
                        default="chessboard.pdf",
 
69
                        help='Name of output file (default: %(default)s')
 
70
    args = parser.parse_args()
 
71
    genTestFile(args.filename, args.num_pages)