#!/usr/bin/perl # extract XMP data from PDF file and unwrap as generic RDF/XML use v5.36; use PDF::API2; my $xml = PDF::API2->open( $ARGV[0] )->xml_metadata(); # strip noise $xml =~ s,^PDF version of requested feature [^<]*,,; # replace whitespace and surrounding XMP boilerplate with XML boilerplate $xml =~ s,\s*<\?xpacket [^>]+>\s*,,; $xml =~ s,]+>,,; # strip trailing boilerplate $xml =~ s,\s*,,; $xml =~ s,\s*<\?xpacket [^>]+>,,; say $xml; 1;