diff options
author | Matthias Kramm <kramm@quiss.org> | 2009-08-21 21:15:37 +0200 |
---|---|---|
committer | Matthias Kramm <kramm@quiss.org> | 2009-08-21 21:15:37 +0200 |
commit | ad60d7e0a361c58fc9872753cfb872c3cc54b82f (patch) | |
tree | 4e35cdb973d4f30f82f13570bb900380b368df0e /spec | |
parent | 886a79f1f7573aff476e7053637292c46f3c1471 (diff) |
added test+fix for transparency group stacking
Diffstat (limited to 'spec')
-rw-r--r-- | spec/transpstack.pdf | 90 | ||||
-rw-r--r-- | spec/transpstack.py | 58 | ||||
-rw-r--r-- | spec/transpstack.spec.rb | 13 |
3 files changed, 161 insertions, 0 deletions
diff --git a/spec/transpstack.pdf b/spec/transpstack.pdf new file mode 100644 index 00000000..f0682c60 --- /dev/null +++ b/spec/transpstack.pdf @@ -0,0 +1,90 @@ +%PDF-1.4 +%ê~ +1 0 obj << +/Type /Catalog +/Pages 4 0 R +>> endobj +2 0 obj << +/Contents 3 0 R +/Parent 4 0 R +/Type /Page +/Resources 7 0 R +/MediaBox [0 0 612 100] +>> endobj +3 0 obj << +/Length 107 +>> stream +q + +1.0 0.0 0.0 rg + +0 40 m 612 40 l 612 60 l 0 60 l 0 40 l f +q /gs0 gs 1.0 0 0 1.0 0 0 cm /mygroup Do Q + +Qendstream +endobj +4 0 obj << +/Kids [2 0 R] +/Type /Pages +/Count 1 +>> endobj +5 0 obj << +/Length 337 +/Type /XObject +/BBox [0 0 100 100] +/Group << +/K true +/CS /DeviceRGB +/S /Transparency +/I true +>> +/Subtype /Form +>> stream + +0.0 1.0 0.0 rg +0.0 0.0 0.0 RG +10 10 m 70 10 l 70 70 l 10 70 l 10 10 l f +10 10 m 70 10 l 70 70 l 10 70 l 10 10 l s +0.0 0.0 1.0 rg +0.0 0.0 0.0 RG +30 30 m 90 30 l 90 90 l 30 90 l 30 30 l f +30 30 m 90 30 l 90 90 l 30 90 l 30 30 l s +1.0 0 0 1.0 1000 1000 cm q +1.0 0 0 1.0 1000 1000 cm q +1.0 0 0 1.0 1000 1000 cm q +1.0 0 0 1.0 1000 1000 cm q +endstream +endobj +6 0 obj << +/CA 1.0 +/ca 1.0 +/Type /ExtGState +/BM /Normal +>> endobj +7 0 obj << +/XObject << +/mygroup 5 0 R +>> +/Type /Resources +/ExtGState << +/gs0 6 0 R +>> +>> endobj +xref +0 8 +0000000000 65535 f +0000000013 00000 n +0000000062 00000 n +0000000166 00000 n +0000000323 00000 n +0000000380 00000 n +0000000878 00000 n +0000000944 00000 n +trailer +<< +/Size 8 +/Root 1 0 R +>> +startxref +1040 +%%EOF
\ No newline at end of file diff --git a/spec/transpstack.py b/spec/transpstack.py new file mode 100644 index 00000000..6bc151c5 --- /dev/null +++ b/spec/transpstack.py @@ -0,0 +1,58 @@ +#!/usr/bin/python +import sys +sys.path += ["../scripts/"] +import pdf + +# a test for transparency groups: +# form xobjects used for doing transparency groups can do savestate (q) +# without ever needing to do a corresponding restorestate (Q) because +# their content stream is self-contained. +# +# Test that this doesn't confuse the pdf reader. + +file = pdf.PDF() + +page = file.add_page(612,100) + +group1 = file.create_object("/XObject", "/Form") +group1.stream = """ +0.0 1.0 0.0 rg +0.0 0.0 0.0 RG +10 10 m 70 10 l 70 70 l 10 70 l 10 10 l f +10 10 m 70 10 l 70 70 l 10 70 l 10 10 l s +0.0 0.0 1.0 rg +0.0 0.0 0.0 RG +30 30 m 90 30 l 90 90 l 30 90 l 30 30 l f +30 30 m 90 30 l 90 90 l 30 90 l 30 30 l s +1.0 0 0 1.0 1000 1000 cm q +1.0 0 0 1.0 1000 1000 cm q +1.0 0 0 1.0 1000 1000 cm q +1.0 0 0 1.0 1000 1000 cm q +""" +isolated = "true" +knockout = "true" +group1["/Group"] = pdf.PDFDict({"/S": "/Transparency", "/CS": "/DeviceRGB", "/I": isolated, "/K": knockout}) +group1["/BBox"] = pdf.PDFArray([0, 0, 100, 100]) + +gs = file.create_object("/ExtGState") +gs["/BM"] = "/Normal" +gs["/CA"] = "1.0" # stroke alpha +gs["/ca"] = "1.0" # fill alpha + +resources = file.create_object("/Resources") +resources["/XObject"] = pdf.PDFDict({"/mygroup": group1}) +resources["/ExtGState"] = pdf.PDFDict({"/gs0": gs}) + +page.header["/Resources"] = resources + +page.stream = """q + +1.0 0.0 0.0 rg + +0 40 m 612 40 l 612 60 l 0 60 l 0 40 l f +q /gs0 gs 1.0 0 0 1.0 0 0 cm /mygroup Do Q + +Q""" + +file.write("transpstack.pdf") + diff --git a/spec/transpstack.spec.rb b/spec/transpstack.spec.rb new file mode 100644 index 00000000..8f6226f2 --- /dev/null +++ b/spec/transpstack.spec.rb @@ -0,0 +1,13 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe "pdf conversion" do + convert_file "transpstack.pdf" do + pixel_at(15,15).should_be_of_color 0xffffff + pixel_at(4,50).should_be_of_color 0xff0000 + pixel_at(21,52).should_be_of_color 0x00ff00 + pixel_at(49,51).should_be_of_color 0x0000ff + pixel_at(80,49).should_be_of_color 0x0000ff + pixel_at(23,77).should_be_of_color 0x00ff00 + pixel_at(70,20).should_be_of_color 0x0000ff + end +end |