added clip spec
authorMatthias Kramm <kramm@quiss.org>
Fri, 19 Feb 2010 21:43:57 +0000 (13:43 -0800)
committerMatthias Kramm <kramm@quiss.org>
Fri, 19 Feb 2010 21:43:57 +0000 (13:43 -0800)
spec/clip.pdf [new file with mode: 0644]
spec/clip.py [new file with mode: 0644]
spec/clip.spec.rb [new file with mode: 0644]

diff --git a/spec/clip.pdf b/spec/clip.pdf
new file mode 100644 (file)
index 0000000..570928e
--- /dev/null
@@ -0,0 +1,87 @@
+%PDF-1.6
+%äãÏÒ
+1 0 obj
+[/PDF/ImageB/ImageC/ImageI/Text]
+endobj
+4 0 obj
+<</Length 5 0 R
+>>
+stream
+0 0 0 rg
+100 100 m
+300 100 l
+300 300 l
+100 300 l
+100 100 l
+200 200 m
+400 200 l
+400 400 l
+200 400 l
+200 200 l
+S
+0 1 0 rg
+100 100 m
+300 100 l
+300 300 l
+100 300 l
+100 100 l
+W n
+200 200 m
+400 200 l
+400 400 l
+200 400 l
+200 200 l
+f
+
+endstream
+endobj
+5 0 obj
+226
+endobj
+6 0 obj
+<</ProcSet 1 0 R
+>>
+endobj
+7 0 obj
+<</CreationDate (D:20100219134324-08'00')
+/Producer (PDFlib 7.0.4p1 \(Python 2.5/Linux\))
+>>
+endobj
+3 0 obj
+<</Type/Page
+/Parent 2 0 R
+/Contents 4 0 R
+/Resources 6 0 R
+/MediaBox[0 0 800 800]
+>>
+endobj
+2 0 obj
+<</Type/Pages
+/Count 1
+/Kids[ 3 0 R]>>
+endobj
+8 0 obj
+<</Type/Catalog
+/Pages 2 0 R
+>>
+endobj
+xref
+0 9
+0000000000 65535 f 
+0000000015 00000 n 
+0000000604 00000 n 
+0000000503 00000 n 
+0000000063 00000 n 
+0000000341 00000 n 
+0000000360 00000 n 
+0000000395 00000 n 
+0000000658 00000 n 
+trailer
+<</Size 9
+/Root 8 0 R
+/Info 7 0 R
+/ID[<5B9C26B0AEF0EC3336ED3CECF52AC9D0><5B9C26B0AEF0EC3336ED3CECF52AC9D0>]
+>>
+startxref
+705
+%%EOF
diff --git a/spec/clip.py b/spec/clip.py
new file mode 100644 (file)
index 0000000..6b34ad2
--- /dev/null
@@ -0,0 +1,46 @@
+from sys import * 
+from pdflib_py import * 
+p = PDF_new() 
+PDF_open_file(p, "clip.pdf")
+
+PDF_set_parameter(p, "usercoordinates", "true")
+PDF_set_value(p, "compress", 0)
+
+width = 800
+height = 800
+PDF_begin_page(p, width, height)
+
+PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.0, 0.0)
+x1,y1,x2,y2 = 100,100,300,300
+PDF_moveto(p, x1,y1)
+PDF_lineto(p, x2,y1)
+PDF_lineto(p, x2,y2)
+PDF_lineto(p, x1,y2)
+PDF_lineto(p, x1,y1)
+x1,y1,x2,y2 = 200,200,400,400
+PDF_moveto(p, x1,y1)
+PDF_lineto(p, x2,y1)
+PDF_lineto(p, x2,y2)
+PDF_lineto(p, x1,y2)
+PDF_lineto(p, x1,y1)
+PDF_stroke(p)
+
+PDF_setcolor(p, "fill", "rgb", 0.0, 1.0, 0.0, 1.0)
+x1,y1,x2,y2 = 100,100,300,300
+PDF_moveto(p, x1,y1)
+PDF_lineto(p, x2,y1)
+PDF_lineto(p, x2,y2)
+PDF_lineto(p, x1,y2)
+PDF_lineto(p, x1,y1)
+PDF_clip(p)
+x1,y1,x2,y2 = 200,200,400,400
+PDF_moveto(p, x1,y1)
+PDF_lineto(p, x2,y1)
+PDF_lineto(p, x2,y2)
+PDF_lineto(p, x1,y2)
+PDF_lineto(p, x1,y1)
+PDF_fill(p)
+
+PDF_end_page(p)
+PDF_close(p)
+PDF_delete(p);
diff --git a/spec/clip.spec.rb b/spec/clip.spec.rb
new file mode 100644 (file)
index 0000000..48b7abf
--- /dev/null
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "pdf conversion" do
+    convert_file "clip.pdf" do
+        pixel_at(257,354).should_be_of_color 0xffffff
+        pixel_at(194,419).should_be_of_color 0x00ff00
+        pixel_at(116,496).should_be_of_color 0xffffff
+        pixel_at(109,353).should_be_of_color 0xffffff
+    end
+end