save_pdf: add crop marks

Should satisfy #123

Needs some testing on printers but the functionality is there.
This commit is contained in:
Andy Meneely
2016-11-01 12:12:03 -04:00
parent f94f710040
commit 30395aee56
11 changed files with 1731 additions and 526 deletions
+25 -3
View File
@@ -50,9 +50,31 @@ describe Squib::Args::Sheet do
opts = { columns: :infinite }
expect { sheet.load!(opts) }.to raise_error('columns must be an integer')
end
end
context 'crop marks' do
subject(:sheet) { Squib::Args::Sheet.new({}, {}, 4) }
it 'computes crop marks properly' do
opts = {
width: 1000,
height: 1100,
trim: 10,
crop_margin_top: 20,
crop_margin_left: 30,
crop_margin_right: 40,
crop_margin_bottom: 50,
}
expect(sheet.load!(opts).crop_coords(3,4, 300, 400)).to eq(
[ {:x1=>43, :y1=>0, :x2=>43, :y2=>74},
{:x1=>253, :y1=>0, :x2=>253, :y2=>74},
{:x1=>43, :y1=>1100, :x2=>43, :y2=>1026},
{:x1=>253, :y1=>1100, :x2=>253, :y2=>1026},
{:x1=>0, :y1=>34, :x2=>74, :y2=>34},
{:x1=>1000, :y1=>34, :x2=>926, :y2=>34},
{:x1=>0, :y1=>344, :x2=>74, :y2=>344},
{:x1=>1000, :y1=>344, :x2=>926, :y2=>344}]
)
end
end
end
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -45,7 +45,8 @@ describe Squib::Deck, '#save_pdf' do
expect(cxt).to receive(:target).and_return(target)
expect(target).to receive(:finish).once
args = { file: 'foo.pdf', dir: '_out', margin: 75, gap: 5, trim: 37 }
args = { file: 'foo.pdf', dir: '_out', crop_marks: false,
margin: 75, gap: 5, trim: 37 }
deck.save_pdf(args)
end
+2 -1
View File
@@ -48,6 +48,7 @@ describe 'Squib samples' do
saves/_hand.rb
saves/_portrait_landscape.rb
saves/_saves.rb
saves/_save_pdf.rb
saves/_showcase.rb
shapes/_draw_shapes.rb
text_options.rb
@@ -61,7 +62,7 @@ describe 'Squib samples' do
Dir.chdir(File.dirname("#{samples_dir}/#{sample}")) do
load full_sample_path
end
# overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log
overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log
test_file_str = File.open(sample_regression_file(sample), 'r:UTF-8').read
expect(log.string).to eq(test_file_str)
end