Reputation: 2350
I want to read XMP data from PDFs in JavaScript:
const { exiftool } = require('exiftool-vendored');
const fs = require('fs');
async function extractXMPData(filename) {
try {
const buffer = await exiftool.extractBinaryTagToBuffer('XMP', filename);
console.log(buffer.toString());
} catch (error) {
console.error('Error reading XMP data:', error);
}
// Close the exiftool instance to free resources
await exiftool.end();
}
const filename = process.argv[2];
extractXMPData(filename);
That fails with "Error reading XMP data: Error: XMP not found".
If I extract the XMP data on the command-line with exiftool -b -XMP /path/to/file.pdf
, the XMP data is extracted. Also when I write the data to a file with JavaScript:
await exiftool.extractBinaryTag('XMP', filename, 'out.xpacket');
Is this a bug in exiftool-vendored
or am I doing something wrong?
Upvotes: 0
Views: 32