From d41622674b2998e178a53fed02351ba2ae1379b8 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 21 Feb 2024 18:55:52 +0100 Subject: add helper script xmp2rdfxml, and make targets turtle-from-* dotgraph-from-* --- bin/xmp2rdfxml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 bin/xmp2rdfxml (limited to 'bin/xmp2rdfxml') diff --git a/bin/xmp2rdfxml b/bin/xmp2rdfxml new file mode 100755 index 0000000..81011b9 --- /dev/null +++ b/bin/xmp2rdfxml @@ -0,0 +1,25 @@ +#!/usr/bin/perl + +# extract XMP data from PDF file and unwrap as generic RDF/XML + +use v5.36; +use strict; + +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; -- cgit v1.2.3