Skip to main content

Utilities

The @pdftron/collab-server exports a static Utils object that contains several utility functions you can leverage on the server side of your application.

Below is a list of the utilities:

getXFDFMetaData#

This function accepts an XFDF string and returns a set of metadata about the XFDF.

import CollabServer from '@pdftron/collab-server'
const xfdf = `
<?xml version="1.0" encoding="UTF-8" ?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<annots>
<square
page="0"
rect="14.120,640.680,573.010,782.920"
color="#E44234"
flags="print"
name="3962d1a2-ed4d-a314-6ffb-45127515b4b4"
title="PDFTron"
subject="Rectangle"
date="D:20220114111542-08'00'"
width="11.578096400244052"
creationdate="D:20220114111542-08'00'"
/>
</annots>
</xfdf>
`;
const metadata = CollabServer.Utils.getXFDFMetaData(xfdf);
console.log(metadata);
/*
[
{
type: "Rectangle",
pageNumber: 0,
color?: "#E44234",
properties: {
page: "0",
rect: "14.120,640.680,573.010,782.920",
color: "#E44234",
flags: "print",
name: "3962d1a2-ed4d-a314-6ffb-45127515b4b4",
title: "PDFTron",
subject: "Rectangle",
date: "D:20220114111542-08'00'",
width: "11.578096400244052",
creationdate: "D:20220114111542-08'00'",
}
}
]
*/