Extracting new/modified/deleted annotations as an "XFDF diff"

In the WebViewer documentation, I see the following entry that indicates it is possible to extract just the changes to the annotations for the current document, in an XFDF command format:

Exporting modified annotations as XML command to server

// Inside AnnotationPanel.js, create an AJAX request to the server, with the data being the command
// string returned by AnnotationManager.GetAnnotCommand(). Note that server_url and doc_id
// are read in as the document is initially loaded

if (readerControl.server_url == null) {
console.warn(“Not configured for server-side annotation saving.”);
return;
}
var am = readerControl.docViewer.GetAnnotationManager();
var xfdfString = am.GetAnnotCommand();

etc…

Which I can then run through this code:
$server_dir = “C:/wamp/www/server/”;
$xfdf_doc = FDFDoc::CreateFromXFDF($server_dir . $filename);
$xfdf_doc->MergeAnnots($command);
$xfdf_doc->SaveAsXFDF($server_dir . $filename);

To update the “server” copy of the document’s annotations.

Is there equivalent functionality in PDFNet?

Thanks,

Mike

Full WebViewer doc link, for reference.
http://www.pdftron.com/webviewer/demo/doc/WebViewer_Developer_Guide.html

You can extract annotations from PDF as XFDF with PDFDoc.FDFExtract() as shown in FDF sample project (http://www.pdftron.com/pdfnet/samplecode.html#FDF

Unfortunately PDFNet currently doesn’t have a GetAnnotCommand() option. You could implement it on your end by tracking which annotations are newly added, which ones are deleted, or modified… then generating XFDF string.

Another option may be to save & send full XFDF, then do a XML diff on the server side.

[](http://www.pdftron.com/pdfnet/docs/PDFNetJava/pdftron/FDF/FDFDoc.html)




On Tuesday, April 8, 2014 2:11:35 PM UTC-7, Mike Ruthven wrote:

In the WebViewer documentation, I see the following entry that indicates it is possible to extract just the changes to the annotations for the current document, in an XFDF command format:

Exporting modified annotations as XML command to server

// Inside AnnotationPanel.js, create an AJAX request to the server, with the data being the command
// string returned by AnnotationManager.GetAnnotCommand(). Note that server_url and doc_id
// are read in as the document is initially loaded

if (readerControl.server_url == null) {
console.warn(“Not configured for server-side annotation saving.”);
return;
}
var am = readerControl.docViewer.GetAnnotationManager();
var xfdfString = am.GetAnnotCommand();

etc…

Which I can then run through this code:
$server_dir = “C:/wamp/www/server/”;
$xfdf_doc = FDFDoc::CreateFromXFDF($server_dir . $filename);
$xfdf_doc->MergeAnnots($command);
$xfdf_doc->SaveAsXFDF($server_dir . $filename);

To update the “server” copy of the document’s annotations.

Is there equivalent functionality in PDFNet?

Thanks,

Mike

Full WebViewer doc link, for reference.
http://www.pdftron.com/webviewer/demo/doc/WebViewer_Developer_Guide.html

Thanks for the quick reply. I had considered the two solutions you suggest already, but when I saw the GetAnnotCommand method I thought I might be able to do it completely off-the-shelf. If I copy the command structure from the WebViewer example, so that I could theoretically send diffs back and forth from the server, can I pass that to FDFDoc.mergeAnnots(String command) on all the PDFNet implementations (Android, iOS, WinRT, etc), and have things work?

Thanks,

Mike