diff --git a/generate_pdf.py b/generate_pdf.py index 2edd3e2..cd4288f 100755 --- a/generate_pdf.py +++ b/generate_pdf.py @@ -23,6 +23,11 @@ help='File where the field data is stored. ' + 'This must be a python script with an array called "data" ' + 'of Field entries.') +parser.add_argument( + '--collate', + choices=['on', 'off'], + default='on', + help='Turns collatating on or off. Default is on.') args = parser.parse_args() @@ -44,5 +49,5 @@ # If everything went well, proceed to generate the PDF st = Scantron(args.output, spacing=0.3*inch) st.set_box_sizes(box_size=0.2*inch, box_spacing=0.3*inch) -st.populate(data, matches=args.num_matches) +st.populate(data, matches=args.num_matches, collate=args.collate) st.save() diff --git a/scantron.py b/scantron.py index ecbed28..e97d8ac 100755 --- a/scantron.py +++ b/scantron.py @@ -140,12 +140,19 @@ def add_sheet(self, data, match=1, position=1): self.draw_boolean(field.label) - def populate(self, data, matches=1): - for match in range(1, matches + 1): + def populate(self, data, matches=1, collate='on'): + if collate == 'on': + for match in range(1, matches + 1): + for position in range(1, 7): + self.add_sheet(data, match, position) + self._canvas.showPage() + self._reset_values() + else: for position in range(1, 7): - self.add_sheet(data, match, position) - self._canvas.showPage() - self._reset_values() + for match in range(1, matches + 1): + self.add_sheet(data, match, position) + self._canvas.showPage() + self._reset_values() def save(self):