Extract annotations from FDFDoc

WebViewer version: 11.3.0

Please give a brief summary of your issue:
Is it possible to extract annotations directly from the FDFDoc.
I have created the FDFDoc as shown below using the xfdf file stream:

var xfdfString = new StreamReader(xfdfStream).ReadToEnd();
using (var xfdfDocument = new FDFDoc(FDFDoc.CreateFromXFDF(xfdfString)))

Instead of using the PdfDoc to retrieve the annotations, I would like to know if it is possible to extract annotations directly from the FDFDoc, as the XFDF file already contains all the annotations.

Could you please confirm if this is feasible?

Regards,
Zaid

1 Like

Hello, I'm AiRon, an automated tech support bot 🤖
While you wait for one of our customer support representatives, I can help you with your question.


Yes, it is possible to work with annotations directly from an FDFDoc in Apryse's PDF software APIs. The FDFDoc object allows you to interact with form data, including annotations, without needing to merge it into a PDFDoc first.


Some things you can try:

  • Use the FDFDoc object to parse and manipulate annotations directly from the XFDF data.

  • Access the annotations in the FDFDoc using methods designed for reading and exporting annotation data.

  • Consider exporting the annotations to a format that suits your needs, such as XFDF, if further processing is required.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

Hi there,

The FDFDoc is generated from a XFDF file or XFDF string:

You can re-generate the original XFDF file or string via APIs such as saveAsXFDFAsString, saveAsXFDFAsStringWithOptions and saveAsXFDFWithOptions
https://sdk.apryse.com/api/web/Core.PDFNet.FDFDoc.html#saveAsXFDFAsString__anchor

But this would be the same as the input file used to generate the FDFDoc.

Best regards,
Kevin

1 Like

Hi,
The current approach we are using to extract comments involves accessing annotations from each page via the PDFDoc object.
Specifically, we are utilizing the PDFDoc to retrieve the annotations.
Instead of this method, is it possible to directly use the FDFDoc generated from the XFDF stream to access annotations, without needing to merge it with the PDFDoc?

Below code snippet shows the approach we are using:
using (var pdfDocument = new PDFDoc(filePath))
{
if (pdfDocument.IsEncrypted())
return Array.Empty();
var xfdfString = new StreamReader(xfdfStream).ReadToEnd();
using (var xfdfDocument = new FDFDoc(FDFDoc.CreateFromXFDF(xfdfString)))
{
pdfDocument.FDFUpdate(xfdfDocument);
var pageCount = pdfDocument.GetPageCount();
for (var pageIndex = 1; pageIndex <= pageCount; pageIndex++)
{
var page = pdfDocument.GetPage(pageIndex);
var annotationCount = page.GetNumAnnots();
for (var annotationIndex = 0; annotationIndex < annotationCount; annotationIndex++)
{
var annotation = page.GetAnnot(annotationIndex);
}
}
}
}

1 Like

Thank you for the response,

Unfortunately you cannot extract the annotation objects from the FDFDoc object. The available methods in the Web SDK can be seen in our API page:
https://sdk.apryse.com/api/web/Core.PDFNet.FDFDoc.html#main

best regards,
Kevin

1 Like