use strict; use warnings; use feature 'say'; use CAM::PDF; use XML::LibXML; my $doc = CAM::PDF-> new( 'test.pdf' ) or die; $doc-> cacheObjects; while ( my ( $k, $v ) = each %{ $doc-> { objcache }}) { next unless $v-> { value }{ type } eq 'dictionary' and $v-> { value }{ value }{ StreamData }; my $str = $doc-> decodeOne( $v-> { value }, 0 ); my $dom = eval { XML::LibXML-> load_xml( string => $str )}; next unless $dom; # Process expected XML, skip possible others (Adobe XMP, etc.) # ... }