lib/mork/sheet_pdf.rb in mork-0.13.2 vs lib/mork/sheet_pdf.rb in mork-0.14.0
- old
+ new
@@ -5,11 +5,11 @@
# Generating response sheets as PDF files.
# See the README file for usage
class SheetPDF < Prawn::Document
include Extensions
- def initialize(content, layout=nil)
+ def initialize(content, layout=nil, duplex=false)
@content =
case content
when Array; content
when Hash; [content]
when String
@@ -22,10 +22,11 @@
when String, Hash; GridPDF.new layout
when Mork::GridPDF; layout
else raise ArgumentError, 'Invalid initialization parameter'
end
super my_page_params
+ @duplex = duplex
process
end
# Saving the PDF file to disk
#
@@ -63,20 +64,23 @@
barcode(content[:barcode] || 0)
header(content[:header] || [])
unless equal_choice_number?
questions_and_choices ch_len[i]
end
+ start_new_page if @duplex
end
end
def make_repeaters
+ pages = @duplex ? :odd : :all
+
if equal_choice_number?
- repeat(:all) do
+ repeat(pages) do
questions_and_choices ch_len.first
end
end
- repeat(:all) do
+ repeat(pages) do
calibration_cell_repeater
registration_mark_repeater
end
end