From 98caa66dc7bb7a304b7b9d4d95d8d0849cefec01 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Thu, 13 Aug 2009 20:59:12 +0200 Subject: [PATCH] testsuite: added first five tests --- lib/pdf/pdf.cc | 4 +- spec/circularfill.pdf | 265 +++++++++++++++++++++++++++++++++ spec/circularfill.spec.rb | 29 ++++ spec/edit_spec.py | 104 ++++++++++--- spec/gradients.pdf | 361 +++++++++++++++++++++++++++++++++++++++++++++ spec/gradients.py | 114 ++++++++++++++ spec/gradients.spec.rb | 34 +++++ spec/layers.pdf | 147 ++++++++++++++++++ spec/layers.py | 41 +++++ spec/layers.spec.rb | 26 ++++ spec/pattern.pdf | Bin 0 -> 1552 bytes spec/pattern.py | 41 +++++ spec/pattern.spec.rb | 8 + spec/simpletext.pdf | Bin 0 -> 1465 bytes spec/simpletext.spec.rb | 12 ++ src/swfbytes.1 | 26 ++++ src/swfrender.c | 2 +- 17 files changed, 1189 insertions(+), 25 deletions(-) create mode 100644 spec/circularfill.pdf create mode 100644 spec/circularfill.spec.rb mode change 100644 => 100755 spec/edit_spec.py create mode 100644 spec/gradients.pdf create mode 100644 spec/gradients.py create mode 100644 spec/gradients.spec.rb create mode 100644 spec/layers.pdf create mode 100644 spec/layers.py create mode 100644 spec/layers.spec.rb create mode 100644 spec/pattern.pdf create mode 100644 spec/pattern.py create mode 100644 spec/pattern.spec.rb create mode 100644 spec/simpletext.pdf create mode 100644 spec/simpletext.spec.rb create mode 100644 src/swfbytes.1 diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index a0d9c6a..3e6a594 100644 --- a/lib/pdf/pdf.cc +++ b/lib/pdf/pdf.cc @@ -1,3 +1,5 @@ +#include +#include #include "../gfxdevice.h" #include "../gfxsource.h" #include "../devices/rescale.h" @@ -447,7 +449,7 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) i->filename = strdup(filename); char*x = 0; - if((x = strchr(filename, '|'))) { + if((x = strchr((char*)filename, '|'))) { *x = 0; userPassword = x+1; } diff --git a/spec/circularfill.pdf b/spec/circularfill.pdf new file mode 100644 index 0000000..63172e2 --- /dev/null +++ b/spec/circularfill.pdf @@ -0,0 +1,265 @@ +%PDF-1.6 +%äãÏÒ +1 0 obj +[/PDF/ImageB/ImageC/ImageI/Text] +endobj +4 0 obj +<> +stream +BT +/F0 18 Tf +18 TL +0 0 Td +(\(0/0\))Tj +50 0 Td +(\(50/0\))Tj +50 0 Td +(\(100/0\))Tj +50 0 Td +(\(150/0\))Tj +50 0 Td +(\(200/0\))Tj +50 0 Td +(\(250/0\))Tj +50 0 Td +(\(300/0\))Tj +50 0 Td +(\(350/0\))Tj +50 0 Td +(\(400/0\))Tj +50 0 Td +(\(450/0\))Tj +50 0 Td +(\(500/0\))Tj +50 0 Td +(\(550/0\))Tj +50 0 Td +(\(600/0\))Tj +50 0 Td +(\(650/0\))Tj +50 0 Td +(\(700/0\))Tj +50 0 Td +(\(750/0\))Tj +50 0 Td +(\(800/0\))Tj +50 0 Td +(\(850/0\))Tj +50 0 Td +(\(900/0\))Tj +50 0 Td +(\(950/0\))Tj +-950 50 Td +(\(0/50\))Tj +0 50 Td +(\(0/100\))Tj +0 50 Td +(\(0/150\))Tj +0 50 Td +(\(0/200\))Tj +0 50 Td +(\(0/250\))Tj +0 50 Td +(\(0/300\))Tj +0 50 Td +(\(0/350\))Tj +0 50 Td +(\(0/400\))Tj +0 50 Td +(\(0/450\))Tj +0 50 Td +(\(0/500\))Tj +0 50 Td +(\(0/550\))Tj +0 50 Td +(\(0/600\))Tj +0 50 Td +(\(0/650\))Tj +0 50 Td +(\(0/700\))Tj +0 50 Td +(\(0/750\))Tj +1 0 0 rg +0 0 0 RG +ET +100 150 m +500 150 l +500 550 l +100 550 l +100 150 l +300 350 m +700 350 l +700 750 l +300 750 l +300 350 l +200 250 m +200 450 l +600 450 l +600 250 l +200 250 l +250 300 m +250 500 l +650 500 l +650 300 l +250 300 l +f +100 150 m +500 150 l +500 550 l +100 550 l +100 150 l +300 350 m +700 350 l +700 750 l +300 750 l +300 350 l +200 250 m +200 450 l +600 450 l +600 250 l +200 250 l +250 300 m +250 500 l +650 500 l +650 300 l +250 300 l +S + +endstream +endobj +5 0 obj +1212 +endobj +7 0 obj +<> +>> +endobj +8 0 obj +<> +endobj +6 0 obj +<> +endobj +10 0 obj +<> +endobj +9 0 obj +<> +endobj +3 0 obj +<> +endobj +2 0 obj +<> +endobj +11 0 obj +<> +endobj +xref +0 12 +0000000000 65535 f +0000000015 00000 n +0000003442 00000 n +0000003340 00000 n +0000000063 00000 n +0000001327 00000 n +0000001593 00000 n +0000001347 00000 n +0000001402 00000 n +0000003149 00000 n +0000002764 00000 n +0000003496 00000 n +trailer +<] +>> +startxref +3544 +%%EOF diff --git a/spec/circularfill.spec.rb b/spec/circularfill.spec.rb new file mode 100644 index 0000000..5d15d2d --- /dev/null +++ b/spec/circularfill.spec.rb @@ -0,0 +1,29 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe "pdf conversion" do + convert_file "circularfill.pdf" do + pixel_at(194,224).should_be_of_color 0xffffff + pixel_at(169,225).should_be_of_color 0xff0000 + pixel_at(138,225).should_be_of_color 0xffffff + pixel_at(72,162).should_be_of_color 0xff0000 + pixel_at(195,132).should_be_of_color 0xff0000 + pixel_at(69,132).should_be_of_color 0xffffff + pixel_at(310,289).should_be_of_color 0xff0000 + pixel_at(287,200).should_be_of_color 0xff0000 + pixel_at(309,161).should_be_of_color 0xff0000 + pixel_at(287,161).should_be_of_color 0xff0000 + pixel_at(109,336).should_be_of_color 0xff0000 + pixel_at(310,306).should_be_of_color 0xff0000 + pixel_at(282,340).should_be_of_color 0xff0000 + pixel_at(409,252).should_be_of_color 0xff0000 + pixel_at(139,310).should_be_of_color 0xffffff + pixel_at(312,343).should_be_of_color 0xffffff + pixel_at(311,248).should_be_of_color 0xff0000 + pixel_at(102,228).should_be_of_color 0xff0000 + pixel_at(374,281).should_be_of_color 0xff0000 + pixel_at(167,281).should_be_of_color 0xff0000 + pixel_at(409,285).should_be_of_color 0xffffff + pixel_at(166,190).should_be_of_color 0xffffff + pixel_at(138,191).should_be_of_color 0xff0000 + end +end diff --git a/spec/edit_spec.py b/spec/edit_spec.py old mode 100644 new mode 100755 index dec96ef..ba6448d --- a/spec/edit_spec.py +++ b/spec/edit_spec.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python import wx import wx.lib.scrolledpanel as scrolled import os @@ -16,6 +17,8 @@ class Check: return "pixel at (%d,%d)" % (self.x,self.y) def right(self): return "" + def verifies(self, model): + return True class PixelColorCheck(Check): def __init__(self, x,y, color): @@ -23,6 +26,10 @@ class PixelColorCheck(Check): self.color = color def right(self): return "is of color 0x%06x" % self.color + def verifies(self, model): + p = model.getPixel(self.x,self.y) + val = p[0]<<16 | p[1]<<8 | p[2] + return val == self.color class TwoPixelCheck(Check): def __init__(self, x,y, x2,y2): @@ -55,6 +62,8 @@ class AreaNotPlain(AreaCheck): checktypes = [PixelColorCheck,PixelBrighterThan,PixelDarkerThan,PixelEqualTo,AreaPlain,AreaNotPlain] +global TESTMODE + def convert_to_ppm(pdf): print pdf f = os.popen("pdfinfo "+pdf, "rb") @@ -62,13 +71,21 @@ def convert_to_ppm(pdf): f.close() width,heigth = re.compile(r"Page size:\s*([0-9]+) x ([0-9]+) pts").findall(info)[0] dpi = int(72.0 * 612 / int(width)) - os.system("pdftoppm -r "+str(dpi)+" -f 1 -l 1 "+pdf+" test") + if TESTMODE: + os.system("pdf2swf -s zoom="+str(dpi)+" -p1 "+pdf+" -o test.swf") + os.system("swfrender --legacy test.swf -o test.png") + os.unlink("test.swf") + return "test.png" + else: + os.system("pdftoppm -r "+str(dpi)+" -f 1 -l 1 "+pdf+" test") return "test-000001.ppm" + class Model: - def __init__(self, filename, checks): - self.filename = filename - self.imgfilename = convert_to_ppm(filename) + def __init__(self, specfile, docfile, checks): + self.specfile = specfile + self.docfile = docfile + self.imgfilename = convert_to_ppm(self.docfile) self.bitmap = wx.Bitmap(self.imgfilename) self.image = wx.ImageFromBitmap(self.bitmap) self.width = self.bitmap.GetWidth() @@ -78,6 +95,13 @@ class Model: self.appendListeners = [] self.drawModeListeners = [] self.drawmode = PixelColorCheck + + def close(self): + try: os.unlink(self.imgfilename) + except: pass + + def getPixel(self,x,y): + return (self.image.GetRed(x,y), self.image.GetGreen(x,y), self.image.GetBlue(x,y)) def setdrawmode(self, mode): self.drawmode = mode @@ -102,7 +126,18 @@ class Model: @staticmethod def load(filename): - path = os.path.splitext(filename)[0]+".rb" + # convenience, allow to do "edit_spec.py file.pdf" + p,ext = os.path.splitext(filename) + if ext!=".rb": + path = p+".rb" + if not os.path.isfile(path): + path = p+".spec.rb" + if not os.path.isfile(path): + print "No file %s found, creating new..." % path + return Model(path, filename, []) + else: + path = filename + fi = open(path, "rb") r_file = re.compile(r"^convert_file \"([^\"]*)\"") r_pixelcolor = re.compile(r"^pixel_at\(([0-9]+),([0-9]+)\).should_be_of_color (0x[0-9a-fA-F]+)") @@ -127,7 +162,7 @@ class Model: if filename: raise Exception("can't load multi-file specs (in line %d)" % (nr+1)) filename = m.group(1); - model = Model(filename, []) + model = Model(path, filename, []) continue m = r_pixelcolor.match(line) if m: model.append(PixelColorCheck(int(m.group(1)),int(m.group(2)),int(m.group(3),16)));continue @@ -152,10 +187,10 @@ class Model: return model def save(self): - path = os.path.splitext(self.filename)[0]+".rb" + path = self.specfile fi = open(path, "wb") fi.write("require File.dirname(__FILE__) + '/spec_helper'\n\ndescribe \"pdf conversion\" do\n") - fi.write(" convert_file \"%s\" do\n" % self.filename) + fi.write(" convert_file \"%s\" do\n" % self.docfile) for check in self.checks: c = check.__class__ if c == PixelColorCheck: @@ -201,7 +236,7 @@ class ZoomWindow(wx.Window): for xx in range(15): x = self.x+xx-8 if 0<=x> +stream +0 0 0 rg + +endstream +endobj +5 0 obj +9 +endobj +6 0 obj +<>>> +endobj +7 0 obj +<> +stream + +endstream +endobj +8 0 obj +0 +endobj +9 0 obj +<> +endobj +10 0 obj +<> +stream +/Pattern cs/P0 scn +0 0 m +80 80 80 240 0 320 c +80 240 240 240 320 320 c +240 240 240 80 320 0 c +240 80 80 80 0 0 c +f +0 0 m +80 80 80 240 0 320 c +80 240 240 240 320 320 c +240 240 240 80 320 0 c +240 80 80 80 0 0 c +S +0 0 0.4 rg + +endstream +endobj +11 0 obj +222 +endobj +12 0 obj +<>>> +endobj +13 0 obj +<> +stream + +endstream +endobj +14 0 obj +0 +endobj +15 0 obj +<> +endobj +16 0 obj +<> +stream +/Pattern cs/P1 scn +200 0 m +280 80 280 240 200 320 c +280 240 440 240 520 320 c +440 240 440 80 520 0 c +440 80 280 80 200 0 c +f +200 0 m +280 80 280 240 200 320 c +280 240 440 240 520 320 c +440 240 440 80 520 0 c +440 80 280 80 200 0 c +S +0 0 0.4 rg + +endstream +endobj +17 0 obj +242 +endobj +18 0 obj +<>>> +endobj +19 0 obj +<> +stream + +endstream +endobj +20 0 obj +0 +endobj +21 0 obj +<> +endobj +22 0 obj +<> +stream +/Pattern cs/P2 scn +580 80 m +580 640 l +660 640 l +660 80 l +580 80 l +f +580 80 m +580 640 l +660 640 l +660 80 l +580 80 l +S +0 0 0.4 rg + +endstream +endobj +23 0 obj +128 +endobj +24 0 obj +<>>> +endobj +25 0 obj +<> +stream + +endstream +endobj +26 0 obj +0 +endobj +27 0 obj +<> +endobj +28 0 obj +<> +stream +/Pattern cs/P3 scn +680 80 m +680 640 l +760 640 l +760 80 l +680 80 l +f +680 80 m +680 640 l +760 640 l +760 80 l +680 80 l +S +0 0 0.4 rg + +endstream +endobj +29 0 obj +128 +endobj +30 0 obj +<>>> +endobj +31 0 obj +<> +stream + +endstream +endobj +32 0 obj +0 +endobj +33 0 obj +<> +endobj +34 0 obj +<> +stream +/Pattern cs/P4 scn +130 380 m +130 460 l +450 460 l +450 380 l +130 380 l +f +130 380 m +130 460 l +450 460 l +450 380 l +130 380 l +S + +endstream +endobj +35 0 obj +123 +endobj +36 0 obj +[ 4 0 R 7 0 R 10 0 R 13 0 R 16 0 R 19 0 R 22 0 R 25 0 R 28 0 R 31 0 R 34 0 R] +endobj +37 0 obj +<> +/Shading<> +>> +endobj +38 0 obj +<> +endobj +3 0 obj +<> +endobj +2 0 obj +<> +endobj +39 0 obj +<> +endobj +xref +0 40 +0000000000 65535 f +0000000015 00000 n +0000003386 00000 n +0000003282 00000 n +0000000063 00000 n +0000000124 00000 n +0000000141 00000 n +0000000317 00000 n +0000000369 00000 n +0000000386 00000 n +0000000436 00000 n +0000000712 00000 n +0000000732 00000 n +0000000903 00000 n +0000000957 00000 n +0000000975 00000 n +0000001027 00000 n +0000001323 00000 n +0000001343 00000 n +0000001522 00000 n +0000001576 00000 n +0000001594 00000 n +0000001646 00000 n +0000001828 00000 n +0000001848 00000 n +0000002020 00000 n +0000002074 00000 n +0000002092 00000 n +0000002144 00000 n +0000002326 00000 n +0000002346 00000 n +0000002519 00000 n +0000002573 00000 n +0000002591 00000 n +0000002643 00000 n +0000002820 00000 n +0000002840 00000 n +0000002934 00000 n +0000003109 00000 n +0000003440 00000 n +trailer +<] +>> +startxref +3488 +%%EOF diff --git a/spec/gradients.py b/spec/gradients.py new file mode 100644 index 0000000..2e439e7 --- /dev/null +++ b/spec/gradients.py @@ -0,0 +1,114 @@ +from sys import * +from pdflib_py import * +p = PDF_new() +PDF_open_file(p, "gradients.pdf") + +PDF_set_parameter(p, "usercoordinates", "true") +PDF_set_value(p, "compress", 0) + +PDF_set_info(p, "Author", "pdflib") +PDF_set_info(p, "Creator", "pdflib_py") +PDF_set_info(p, "Title", "gradients") + +width = 1024 +height = 800 +PDF_begin_page(p, width, height) + +type,x,params = "radial",0,"r0=0 r1=320" +y = 0 +PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.0, 1.0) +shading = PDF_shading(p, type, 160+x,160+y, 160+x, 160+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial +pattern = PDF_shading_pattern(p,shading,"") +PDF_setcolor(p, "fill", "pattern", pattern,0,0,0) +PDF_moveto(p, x,y) +PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320) +PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320) +PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y) +PDF_curveto(p, x+240, y+80, x+80, y+80, x, y) +PDF_fill(p) +PDF_moveto(p, x,y) +PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320) +PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320) +PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y) +PDF_curveto(p, x+240, y+80, x+80, y+80, x, y) +PDF_stroke(p) + +type,x,params = "axial",200,"" +y = 0 +PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0) +shading = PDF_shading(p, type, 0+x,0+y, 320+x,320+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial +pattern = PDF_shading_pattern(p,shading,"") +PDF_setcolor(p, "fill", "pattern", pattern,0,0,0) +PDF_moveto(p, x,y) +PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320) +PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320) +PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y) +PDF_curveto(p, x+240, y+80, x+80, y+80, x, y) +PDF_fill(p) +PDF_moveto(p, x,y) +PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320) +PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320) +PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y) +PDF_curveto(p, x+240, y+80, x+80, y+80, x, y) +PDF_stroke(p) + +type,x,params = "radial",500,"r0=0 r1=220" +y = 0 +PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0) +shading = PDF_shading(p, type, 120+x, 340+y, 120+x, 340+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial +pattern = PDF_shading_pattern(p,shading,"") +PDF_setcolor(p, "fill", "pattern", pattern,0,0,0) +PDF_moveto(p, x+80, y+80) +PDF_lineto(p, x+80, y+640) +PDF_lineto(p, x+160, y+640) +PDF_lineto(p, x+160, y+80) +PDF_lineto(p, x+80, y+80) +PDF_fill(p) +PDF_moveto(p, x+80, y+80) +PDF_lineto(p, x+80, y+640) +PDF_lineto(p, x+160, y+640) +PDF_lineto(p, x+160, y+80) +PDF_lineto(p, x+80, y+80) +PDF_stroke(p) + +type,x,params = "axial",600,"" +y = 0 +PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0) +shading = PDF_shading(p, type, 80+x, 80+y, 80+x, 640+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial +pattern = PDF_shading_pattern(p,shading,"") +PDF_setcolor(p, "fill", "pattern", pattern,0,0,0) +PDF_moveto(p, x+80, y+80) +PDF_lineto(p, x+80, y+640) +PDF_lineto(p, x+160, y+640) +PDF_lineto(p, x+160, y+80) +PDF_lineto(p, x+80, y+80) +PDF_fill(p) +PDF_moveto(p, x+80, y+80) +PDF_lineto(p, x+80, y+640) +PDF_lineto(p, x+160, y+640) +PDF_lineto(p, x+160, y+80) +PDF_lineto(p, x+80, y+80) +PDF_stroke(p) + +type,x,params = "axial",50,"" +y = 300 +PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0) +shading = PDF_shading(p, type, 80+x, 80+y, 400+x, 80+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial +pattern = PDF_shading_pattern(p,shading,"") +PDF_setcolor(p, "fill", "pattern", pattern,0,0,0) +PDF_moveto(p, x+80, y+80) +PDF_lineto(p, x+80, y+160) +PDF_lineto(p, x+400, y+160) +PDF_lineto(p, x+400, y+80) +PDF_lineto(p, x+80, y+80) +PDF_fill(p) +PDF_moveto(p, x+80, y+80) +PDF_lineto(p, x+80, y+160) +PDF_lineto(p, x+400, y+160) +PDF_lineto(p, x+400, y+80) +PDF_lineto(p, x+80, y+80) +PDF_stroke(p) + +PDF_end_page(p) +PDF_close(p) +PDF_delete(p); diff --git a/spec/gradients.spec.rb b/spec/gradients.spec.rb new file mode 100644 index 0000000..62aebbb --- /dev/null +++ b/spec/gradients.spec.rb @@ -0,0 +1,34 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe "pdf conversion" do + convert_file "gradients.pdf" do + pixel_at(269,324).should_be_brighter_than pixel_at(155,438) + pixel_at(261,388).should_be_brighter_than pixel_at(209,434) + pixel_at(195,329).should_be_brighter_than pixel_at(164,367) + pixel_at(33,318).should_be_brighter_than pixel_at(92,381) + pixel_at(168,310).should_be_brighter_than pixel_at(108,381) + pixel_at(166,455).should_be_brighter_than pixel_at(109,401) + pixel_at(25,454).should_be_brighter_than pixel_at(89,396) + pixel_at(258,210).should_be_brighter_than pixel_at(90,215) + pixel_at(259,225).should_be_brighter_than pixel_at(95,227) + pixel_at(257,240).should_be_brighter_than pixel_at(102,240) + pixel_at(359,121).should_be_brighter_than pixel_at(360,270) + pixel_at(383,119).should_be_brighter_than pixel_at(385,181) + pixel_at(373,167).should_be_brighter_than pixel_at(373,239) + pixel_at(355,409).should_be_brighter_than pixel_at(356,349) + pixel_at(370,377).should_be_brighter_than pixel_at(369,316) + pixel_at(382,333).should_be_brighter_than pixel_at(383,286) + pixel_at(422,115).should_be_brighter_than pixel_at(422,411) + pixel_at(437,190).should_be_brighter_than pixel_at(436,318) + pixel_at(447,276).should_be_brighter_than pixel_at(446,413) + pixel_at(413,101).should_be_the_same_as pixel_at(448,101) + pixel_at(412,166).should_be_the_same_as pixel_at(449,166) + pixel_at(412,246).should_be_the_same_as pixel_at(450,246) + pixel_at(413,332).should_be_the_same_as pixel_at(450,332) + pixel_at(414,400).should_be_the_same_as pixel_at(451,400) + pixel_at(87,245).should_be_the_same_as pixel_at(87,212) + pixel_at(143,245).should_be_the_same_as pixel_at(143,209) + pixel_at(189,246).should_be_the_same_as pixel_at(189,210) + pixel_at(236,244).should_be_the_same_as pixel_at(236,208) + end +end diff --git a/spec/layers.pdf b/spec/layers.pdf new file mode 100644 index 0000000..877a1f3 --- /dev/null +++ b/spec/layers.pdf @@ -0,0 +1,147 @@ +%PDF-1.6 +%äãÏÒ +1 0 obj +[/PDF/ImageB/ImageC/ImageI/Text] +endobj +4 0 obj +<> +stream +xœUŽÍ +Â0„ïó{ԓkmü96E½xÒ}­ -…ÐÇw'QAÉ·3Ìf¢aqPÙªXÞ'¨,ý½bǔÆAìöJs{P÷s>Âí'öæ‚Ê€  ¨ô¸ PѾ +cÓ« R÷ê]†>Æ@ëÙêÀ¯”¹h¨}[U*5¥ÈúSðoj9y­7…Õ+× +endstream +endobj +5 0 obj +136 +endobj +7 0 obj +<> +>> +endobj +8 0 obj +<> +endobj +6 0 obj +<> +endobj +10 0 obj +<> +endobj +9 0 obj +<> +endobj +3 0 obj +<> +endobj +2 0 obj +<> +endobj +11 0 obj +<> +endobj +xref +0 12 +0000000000 65535 f +0000000015 00000 n +0000002308 00000 n +0000002207 00000 n +0000000063 00000 n +0000000271 00000 n +0000000460 00000 n +0000000290 00000 n +0000000345 00000 n +0000002016 00000 n +0000001631 00000 n +0000002362 00000 n +trailer +<] +>> +startxref +2410 +%%EOF diff --git a/spec/layers.py b/spec/layers.py new file mode 100644 index 0000000..30ba5bf --- /dev/null +++ b/spec/layers.py @@ -0,0 +1,41 @@ +from sys import * +from pdflib_py import * + +p = PDF_new() +PDF_open_file(p, "layers.pdf") + +PDF_set_parameter(p, "usercoordinates", "true") +PDF_begin_page(p, 500, 200) + +font = PDF_load_font(p, "Helvetica-Bold", "host", "") +PDF_setfont(p, font, 80.0) +PDF_set_text_pos(p, 0, 10) +PDF_show(p, "Bottom Text") + +PDF_setrgbcolor_stroke(p, 0, 1.0, 1.0) +PDF_setlinewidth(p, 10) +PDF_moveto(p, 0, 0) +PDF_lineto(p, 500, 100) +PDF_stroke(p) +PDF_moveto(p, 0, 100) +PDF_lineto(p, 500, 0) +PDF_stroke(p) + +PDF_setrgbcolor_fill(p, 0, 0, 1.0) +PDF_moveto(p, 350, 25) +PDF_lineto(p, 490, 25) +PDF_lineto(p, 490, 75) +PDF_lineto(p, 350, 75) +PDF_lineto(p, 350, 25) +PDF_fill(p) + +PDF_setrgbcolor_fill(p, 1, 1, 0) +PDF_set_text_pos(p, 400, 20);PDF_show(p, "A") +PDF_set_text_pos(p, 400, 80);PDF_show(p, "B") +PDF_set_text_pos(p, 400, 140);PDF_show(p, "C") + + +PDF_end_page(p) + +PDF_close(p) +PDF_delete(p); diff --git a/spec/layers.spec.rb b/spec/layers.spec.rb new file mode 100644 index 0000000..2594835 --- /dev/null +++ b/spec/layers.spec.rb @@ -0,0 +1,26 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe "pdf conversion" do + convert_file "layers.pdf" do + pixel_at(67,134).should_be_of_color 0x00ffff + pixel_at(299,182).should_be_of_color 0x00ffff + pixel_at(144,215).should_be_of_color 0x00ffff + pixel_at(206,203).should_be_of_color 0x00ffff + pixel_at(243,196).should_be_of_color 0x00ffff + pixel_at(270,190).should_be_of_color 0x00ffff + pixel_at(114,220).should_be_of_color 0x00ffff + pixel_at(406,161).should_be_of_color 0x00ffff + pixel_at(398,201).should_be_of_color 0x00ffff + pixel_at(438,211).should_be_of_color 0x0000ff + pixel_at(499,216).should_be_of_color 0xffff00 + pixel_at(498,223).should_be_of_color 0x00ffff + pixel_at(515,175).should_be_of_color 0xffff00 + pixel_at(458,185).should_be_of_color 0x0000ff + pixel_at(541,138).should_be_of_color 0xffff00 + pixel_at(433,158).should_be_of_color 0x0000ff + area_at(431,155,485,212).should_be_plain_colored + pixel_at(103,184).should_be_of_color 0x000000 + pixel_at(505,84).should_be_of_color 0xffff00 + pixel_at(314,149).should_be_of_color 0xffffff + end +end diff --git a/spec/pattern.pdf b/spec/pattern.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ddd9b9d736a676c7b7290f37acf4b3a69dc5e4c2 GIT binary patch literal 1552 zcma)6&ubGw6i$tT4EA6>3v&r=(eBRv%&vxl*(4eoX_|zpBmuX{G+jw|!)BtXCojc| z1<^|ndJ*v-5cHz=-YohLh^_ip2)^0uCNU}0z3k36@6G$(_rBRgF_T-81RW)gkG_0G z5+>N&cz~)R;9`E;ZqfAMWer|=u|oT-j;Pz@acUT!N{I#Pw%8Wd04X6c=d>C1#a!EF zG(#I+lcMEi)MY-kw^9FduR9g$zfPngP+K2$wpLF zA5|^d4C=U*oesqk5{tIuvS1-2vEsBHw-s%r(_X(yAXCL^9f^0#jCQb!#Cy?4iFUo7 z-=JNb9P|)&WDHjS(b2(Ad5x?c%)G!KX7(>%c)RyKwg2hjb2awTsl~3(pwH9I@xys@ ziWxP>i*p1dE&5)gOc~}=DRKQmMa)r1$Wh{roi6*gNBa6LVVxW*Pw)SU#dm)kr-b;q z_-;+Ov{J^erq26~qM|m=i1wO(H4b z_Ebxv<+VM(+_4)J_ACWU!&YIG!DM+3!F=L@0wWQmG4EMmE9Uulp)*JlIy;L<3{b~& zGvGnIkhvxkViH4AWFi@|bcM+Cgv>)6$lUBTD5Qhw+s+0qIFOJOh#+?iTw5saur1HU zvY-j7Sa954zqYtIHjaQaR|Ia&puU))51j@r-Ava}B+{4&+>#L5qTH}Pbs6RY!uTxD zWw7kxKv4ijo(x0;~DB`k0u} zC5zH5o7ruz#R<0HMhy6k;`=_`L;&4 zp$-9@G{?zM)NWqU&8ta{#nhZ2q59U(pZo9bk^`ZJW`sE)ZA2O}H6kO8G%+F;J>3_m zT1C0ZL^4Lx4>`KLc;mI`m)8B})!ld1?#B)Eb7KQ-mb(uheG0>Cba`D5%kMW|c0X@+ z@7(+P;G0c3zduiIQ&|$+ThQ5A(rIP7cO(q96rZ+DLV(VxJjDkRE(8vBJlx%CokMtqUB`Dkav;@Y+AWt?_}UU| z;ZV@=`I(p%hse?7)L6?x43S!r3tKgLCeqi!$X>Et(`g@(x`K8{HN@dUiMb5cUJbi& zyot52$P20VR4x}bBC#9{L?%>E|7zqezusdrFiJ*UA=Gg8TOmSP}dXj<8*iJeChoUc&nx1wj z*gWL8;=8L!Y@F4W+9Wy5w4Oi`7?OS2&pX&sX`d|jf!S!Q*P_HEsUBK-aDUEj=|9b& z-xM>3Xz}2HbC2TzE-(iBY9Fi$EDT{i*RV!XvA#-b#Mp5 file.hexdump +.PP +.B swfbytes file.hexdump + +.SH DESCRIPTION +With this tool and a text editor, you can perform some basic +editing operations on SWF files. + +.SH OPTIONS +.TP +\fB\-h\fR, \fB\-\-help\fR + Print help and exit +.TP +\fB\-v\fR, \fB\-\-verbose\fR + Be more verbose +.TP +\fB\-V\fR, \fB\-\-version\fR + Print program version and exit +.SH AUTHOR + +Matthias Kramm diff --git a/src/swfrender.c b/src/swfrender.c index 8ac81d5..0dcee51 100644 --- a/src/swfrender.c +++ b/src/swfrender.c @@ -128,7 +128,7 @@ int main(int argn, char*argv[]) fi = open(filename, O_RDONLY|O_BINARY); if (fi<=0) { fprintf(stderr,"Couldn't open %s\n", filename); - perror(argv[1]); + perror(filename); exit(1); } if(swf_ReadSWF(fi,&swf)<0) { -- 1.7.10.4