From ecd7c7248b9a93163090bfe7512b2a53d8da6d95 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Sun, 16 Aug 2009 18:52:54 +0200 Subject: bugfixes --- spec/simpletext.spec.rb | 1 + spec/smalltext.pdf | Bin 2746 -> 2749 bytes spec/smalltext.py | 2 +- spec/spec_helper.rb | 16 ++++++++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/simpletext.spec.rb b/spec/simpletext.spec.rb index d5911ad4..874ce590 100644 --- a/spec/simpletext.spec.rb +++ b/spec/simpletext.spec.rb @@ -8,5 +8,6 @@ describe "pdf conversion" do pixel_at(97,164).should_be_the_same_as pixel_at(208,256) area_at(215,80,333,156).should_be_plain_colored area_at(46,126,180,158).should_not_be_plain_colored + area_at(38,118,170,152).should_contain_text 'Hello World' end end diff --git a/spec/smalltext.pdf b/spec/smalltext.pdf index d7c7eeb5..7f2323fe 100644 Binary files a/spec/smalltext.pdf and b/spec/smalltext.pdf differ diff --git a/spec/smalltext.py b/spec/smalltext.py index a0ac9dfd..45fa2d78 100644 --- a/spec/smalltext.py +++ b/spec/smalltext.py @@ -10,7 +10,7 @@ PDF_begin_page(p, 612, 200) font = PDF_load_font(p, "Helvetica", "host", "") PDF_setfont(p, font, 6.0) -PDF_set_text_pos(p, 40, 100);PDF_show(p, "|") +PDF_set_text_pos(p, 40, 100);PDF_show(p, "'") PDF_set_text_pos(p, 80, 100);PDF_show(p, "i") PDF_set_text_pos(p, 120, 100);PDF_show(p, "l") PDF_set_text_pos(p, 160, 100);PDF_show(p, "-") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1ee0b39d..cf9c9713 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -91,6 +91,14 @@ class Pixel "(#{@x},#{@y})" end end + +$tempfiles = [] +Kernel.at_exit do + $tempfiles.each do |file| + `rm -f #{file}` + end +end + class DocFile def initialize(filename, page) @filename = filename @@ -99,6 +107,7 @@ class DocFile def convert() return if @swfname @swfname = @filename.gsub(/.pdf$/i,"")+".swf" + $tempfiles += [@swfname] `pdfinfo #{@filename}` =~ /Page size:\s*([0-9]+) x ([0-9]+) pts/ width,height = $1,$2 dpi = (72.0 * 612 / width.to_i).to_i @@ -115,15 +124,14 @@ class DocFile raise ConversionFailed.new(output,@pngname) unless File.exists?(@pngname) @img = Magick::Image.read(@pngname).first ensure - `rm -f #{@swfname}` `rm -f #{@pngname}` end end def get_text(x1,y1,x2,y2) self.convert() - puts "swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}" - puts `swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}` - `swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}` + #puts "swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}" + #puts `swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}` + `swfstrings -x #{x1} -y #{y1} -W #{x2-x1} -H #{y2-y1} #{@swfname}`.chomp end def get_area(x1,y1,x2,y2) self.render() -- cgit v1.2.3