Posted on 2010-01-24 22:43:22.067753-08 by binarybits
Manipulating XObjects
Hi, I'm trying to detect black rectangles in PDF files, and I'm having trouble figuring out if CAM::PDF does what I need to do. I'm trying to read a PDF that looks (in relevant part) like this:
/XObject <</Fm1 5 0 R>>
And subsequently...
5 0 obj <</Matrix [1.0 0.0 0.0 1.0 -71.0 -179.48] /Subtype /Form /Length 207 /Resources <</ProcSet [/PDF] >> /FormType 1 /BBox [71.0 179.48 526.605 227.572] /Type /XObject >> stream 0 g 1 0 0 1 0 0 cm 474.7041 205.6601 m 526.1046 205.6601 l 526.1046 227.072 l 474.7041 227.072 l 474.7041 205.6601 l f endstream endobj
I've figured out how to get this far:
my $pdf = CAM::PDF->new($infile); my @properties = $pdf->getPropertyNames($pagenum); my $property = $pdf->getProperty($pagenum, 'Fm1');
But then I'm stuck. When I run this code, I get a list in @properties that includes Fm1, the XObject I want to examine. And $property winds up with a data structure that seems like it might have the data I want in the "StreamData" field. But the data seems to be encoded somehow, and I'm not sure how to extract the contents. I've spent a couple of hours poring through the CAM::PDF documentation and source code and haven't been able to make any progress. Am I missing something? Or is this not something CAM::PDF does? Thanks for a great library!
Direct Responses: 12240 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.