From 5d62a9d366a6efc35d67c4b2581c8442e1dd9394 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Fri, 19 Feb 2010 13:43:57 -0800 Subject: [PATCH] added clip spec --- spec/clip.pdf | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++ spec/clip.py | 46 ++++++++++++++++++++++++++++ spec/clip.spec.rb | 10 ++++++ 3 files changed, 143 insertions(+) create mode 100644 spec/clip.pdf create mode 100644 spec/clip.py create mode 100644 spec/clip.spec.rb diff --git a/spec/clip.pdf b/spec/clip.pdf new file mode 100644 index 0000000..570928e --- /dev/null +++ b/spec/clip.pdf @@ -0,0 +1,87 @@ +%PDF-1.6 +%äãÏÒ +1 0 obj +[/PDF/ImageB/ImageC/ImageI/Text] +endobj +4 0 obj +<> +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 +<> +endobj +7 0 obj +<> +endobj +3 0 obj +<> +endobj +2 0 obj +<> +endobj +8 0 obj +<> +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 +<<5B9C26B0AEF0EC3336ED3CECF52AC9D0>] +>> +startxref +705 +%%EOF diff --git a/spec/clip.py b/spec/clip.py new file mode 100644 index 0000000..6b34ad2 --- /dev/null +++ b/spec/clip.py @@ -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 index 0000000..48b7abf --- /dev/null +++ b/spec/clip.spec.rb @@ -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 -- 1.7.10.4