Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hand-rolled tiled pattern failing miserably - please help!

12 views
Skip to first unread message

Chris Shearer Cooper

unread,
Sep 30, 2010, 9:38:54 AM9/30/10
to
For reasons too painful to list here, I am manually writing some code
to create a tiled pattern inside a PDF file. I'm following the
example in the PDF reference, but when I load the resulting PDF into
Adobe Reader, my pattern doesn't appear and when I start scrolling
inside of Adobe Reader, everything goes white. Clearly I've done
something horribly, terribly wrong.

For now, my pattern is just trying to draw a line:
59 0 obj
<<
/Type /Pattern /PatternType 1 /PaintType 1 /TilingType 2 /BBox [0 0
100 100] /XStep 100 /YStep 100 /Resources 58 0 R /Length 57
>>
stream
0.2 0.2 0.8 rg 0.2 0.8 0.2 RG 5 w 1 J 0 0 m 100 100 l S
endstream
endobj

The pattern doesn't need any resources:
58 0 obj
<<
>>
endobj

The pattern appears inside the page's resources object:
2 0 obj
<<
/ProcSet [/PDF/Text/ImageC/ImageB]
/Font <<
/F0 8 0 R
/F1 11 0 R
>>
/XObject <<
/img0 31 0 R
/img1 32 0 R
>>
/Pattern <<
/P1 59 0 R
>>
/ExtGState << /SRCAND << /Type /ExtGState /BM /Darken >> /SSMULT << /
Type /ExtGState /BM /Multiply >> /SSDIFF << /Type /ExtGState /BM /
Difference >> /SRCPAINT << /Type /ExtGState /BM /Lighten >> >>
>>
endobj

And I draw it like this:
q
0.0 G
1.0 1.0 0.0 rg
0.0 0.0 1.0 RG
/Pattern cs
/P1 scn
/P1 SCN
148.00 -148.00 20.00 -20.00 re B
Q

When I load this into Adobe Acrobat, it says "Invalid ColorSpace".

Any suggestions? I've been looking at every byte in my PDF streams,
comparing them against the example in the PDF reference and the
descriptions of the PDF operators, and everything looks correct to me,
but clearly it ain't.

Any help appreciated!

Thanks,
Chris

Scott Bryce

unread,
Sep 30, 2010, 10:01:02 AM9/30/10
to
On 9/30/2010 7:38 AM, Chris Shearer Cooper wrote:
> When I load this into Adobe Acrobat, it says "Invalid ColorSpace".

I have not worked with patterns, but from a quick glance at your code, I
think I see the problem.

The default colorspace is grayscale. You seem to be trying to define RGB
colors in the grayscale colorspace. I don't see anywhere where you
define a different colorspace (unless I am missing something. I only
work in grayscale.)

Chris Shearer Cooper

unread,
Sep 30, 2010, 11:12:25 AM9/30/10
to

I found the problem ... I was doing a "stroke and fill" (B) but my
pattern apparently only knows how to fill. When I replaced the 'B'
with an 'f' it started working.

Chris

0 new messages