Consolidating annotations from multiple sources

Hello,


I’m trying to implement a functionality to consolidate annotations from 2 and more pdf files using PdfAnnotationEditor.
I do have a source file Source.pdf, which doesn’t contain any annot’s, and two files with annotations (all 3 files contents are identical, expt. annotations).
For example:
AnnotFile1.pdf contains 1 highlight and 1 “sticky note” annotations;
AnnotFile2.pdf contains 2 highlight annotations;

When I’m trying to import annotations from these 2 files to the source, I do get a resulting file, which contains all highlight annotations, but “sticky note” disappears (the icon and the popup are not visible anymore, though this annotation is still listed in Comments (Acrobat Reader X).
I’ve tried both ways - direct import and import from a xfdf file.
Is it possible some how to get a resulting file with all annotations visible and on their own places?

Thank you!

Hi Aleksandr,

Thank you very much for considering Aspose.

Please share the input PDF files along with the code snippet, which you’re using at your end, with us so we could test the issue over here. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience.
Regards,

Hello Shahzad,

Thank you for your reply.

Attached are files I’m using for my tests.

Code I’m using:

Dim vLicense As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License
vLicense.SetLicense(“Aspose.Total.lic”)

Dim annoType As Enum = {AnnotationType.Text, AnnotationType.HightLight}

Dim fs1 As New FileStream("…\TestFiles\AnnotFile1.xfdf", FileMode.OpenOrCreate)
Dim fs2 As New FileStream("…\TestFiles\AnnotFile2.xfdf", FileMode.OpenOrCreate)

Dim AnnEdit As New Aspose.Pdf.Kit.PdfAnnotationEditor()
AnnEdit.BindPdf("…\TestFiles\AnnotFile1.pdf")
AnnEdit.ExportAnnotationsXfdf(fs1, 1, 1, annoType)

AnnEdit = New Aspose.Pdf.Kit.PdfAnnotationEditor()
AnnEdit.BindPdf("…\TestFiles\AnnotFile2.pdf")
AnnEdit.ExportAnnotationsXfdf(fs2, 1, 1, annoType)

AnnEdit = New Aspose.Pdf.Kit.PdfAnnotationEditor()
AnnEdit.BindPdf("…\TestFiles\Source.pdf")
AnnEdit.ImportAnnotationFromXfdf("…\TestFiles\AnnotFile1.xfdf", annoType)
AnnEdit.ImportAnnotationFromXfdf("…\TestFiles\AnnotFile2.xfdf", annoType)

AnnEdit.Save("…\TestFiles\SourceWithAnn.pdf")

Hi Aleksandr,

I have tested this issue using the files and code snippet you shared, and the latest version of Aspose.Pdf.Kit for .NET; It worked fine at my end and all the annotations are merged properly. Please download Aspose.Pdf.Kit for .NET 5.4.0 and try at your end.

I hope this helps. If you still find any issues or have more questions, please do let us know.
Regards,

Hello Shahzad,

Thank you for you advice, it worked.

What I'm trying to do now is to extract a xml of annotations and store it to a database. Unfortunatelly, when I'm importing that xml back to a source pdf file, PdfAnnotationEditor truncates some of the contents, i.e. rich-text content, attribute "name", etc. Is this how AnnotationEditor imports xfdf or it's a bug? I've tried Pdf.Kit versions 4.5, 5.3 and 5.4.

I've attached two xfdf files - initial, which contains original xml of annotations, and a truncated, which was extracted after I've imported the initial one.

Hi Aleksandr,

Could you please clarify the issue a little bit, so I could look into it in detail? Please share where exactly the issue is occurring. Yo may jot down the steps and mention where the problem occurs. As I understand you go through the following steps:

1. Export annotations to XFDF, and it works fine; however, I don’t see any annotations in the attached source.pdf file.
2. Import annotations back to PDF.
3. Export the annotations again to XFDF, from the file updated in step 2.

Now, I’m not sure whether it fails at step 2 or 3. Could you please share the original PDF file containing annotations. The code snippet which you’re using at your end would be helpful in understanding the problem. Please share some further details.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hello Shahzad,

Thank you for your response.

Attached file AnnotFile1.pdf contains source file with annotations.

Problem occures after I do import and export of the xfdf file. If you compare two xfdf files before and after import you'll see the difference.

Hope that code sample bellow will help to clarify my issue.

Dim vPath As String = "..\..\\TestFiles\ToAspose\"

Dim fs1 As New FileStream(vPath + "InitialXfdf.xfdf", FileMode.OpenOrCreate)

Dim AnnEdit As New Aspose.Pdf.Kit.PdfAnnotationEditor()
AnnEdit.BindPdf(vPath + "AnnotFile1.pdf")
AnnEdit.ExportAnnotationsXfdf(fs1, 1, 1, annoType)

AnnEdit = New Aspose.Pdf.Kit.PdfAnnotationEditor()
AnnEdit.BindPdf(vPath + "Source.pdf")
AnnEdit.ImportAnnotationFromXfdf(vPath + "InitialXfdf.xfdf", annoType)
AnnEdit.Save(vPath + "SourceWithAnn.pdf")

'!!! Now when I'm doing an export Pdf.Kit truncates content of annotations !!!
Dim fs2 As New FileStream(vPath + "TruncatedXfdf.xfdf", FileMode.OpenOrCreate)
AnnEdit = New Aspose.Pdf.Kit.PdfAnnotationEditor()
AnnEdit.BindPdf(vPath + "SourceWithAnn.pdf")
AnnEdit.ExportAnnotationsXfdf(fs2, 1, 1, annoType)

Hi Aleksandr,

I have reproduced this problem at my end and logged it as PDFKITNET-25432 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Hello Shahzad,

Thank you for your fast response.

Could you give me, please, a best gues estimate on when this issue will be released, priority, etc.?

Thank you!

Hi Aleksandr,

As you know, this issue was logged recently, our team still needs to investigate this issue in detail before sharing any estimates. However, I have asked the team to share the ETA of this issue and you’ll be updated via this forum thread as soon as the response is received. Please spare us some time for detailed investigation.

We’re sorry for the inconvenience.
Regards,

Hello Shahzad,

Are there any news on this topic?

Our clients are waiting for a status report. I'd appreciate if you update us with a current status.

Thank you.

Hi Aleksandr,

Our team has looked into this issue and I would like to share with you that the fix for this issue will be available at the end of May 2011. You’ll be notified via this forum thread once this issue is resolved.

We’re sorry for the inconvenience. If you have any further questions, please do let us know.
Regards,

Hello Shahzad,

thank you for the reply.

Unfortunately end of May 2011 is too late for us. Are there any options to speed up the process and publish a hotfix for us?

Thank you.

Hi Aleksandr,

We try our best to resolve the issues as early as possible; however, I’m afraid, we also need to schedule the issues on first come, first serve basis. Nevertheless, I have asked our team to look into this issue once again to see if this can be rescheduled. You’ll be updated with the response accordingly.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hello Shahzad,

thank you for the response.

I'd appreciate if you could answer another question - I've noticed that exported annotations do have a unique GIUD keys in their "name" attribute. Are these keys generated by Acrobat/Reader or it's a feature of Pdf.Kit export to xfdf?

Hi Aleksandr,

These GUID keys are generated when the annotations are created using Adobe Acrobat. Aspose.Pdf.Kit doesn’t create these IDs, however it has no problem processing those annotations.

I hope this helps, If you have any further questions, please do let us know.
Regards,

Hello Shahzad,

thank you for the response.

Some new discoveries with Pdf.Kit.PDFAnnotationEditor (version 5.4):

  • When importing annotations it doubles every "Sticky note" annotation;
  • When exporting annotations it throws an exception "Object reference is not set..." if a full list of annotations types is passed to the ExportAnnotationsXfdf method;

Hi Aleksandr,

Could you please provide the related problematic PDF files, along with the details that where exactly the issues occur? We’ll further investigate the issues at our end and update you accordingly.

We’re sorry for the inconvenience.
Regards,

Hello Shahzad,

for testing you can take files I've uploaded before:

Attachment: Source.pdf
Attachment: AnnotFile1.pdf


Before I do an import I'm exporting annotations to a xfdf. The xml source of that xfdf file looks OK. Then I'm importing created xfdf file to a Source.pdf and PDFAnnotationEditor doubles every single "Sticky note" annotation.

For the export of xfdf I'm using annotation types enum:

Private gAnnoType As [Enum]() = {AnnotationType.Caret, AnnotationType.Circle, AnnotationType.FileAttachment, AnnotationType.FreeText, AnnotationType.Highlight, AnnotationType.Ink, AnnotationType.Line, AnnotationType.Link, AnnotationType.Movie, AnnotationType.Polygon, AnnotationType.PolyLine, AnnotationType.Popup, AnnotationType.PrinterMark, AnnotationType.Screen, AnnotationType.Sound, AnnotationType.Square, AnnotationType.Squiggly, AnnotationType.Stamp, AnnotationType.StrikeOut, AnnotationType.Text, AnnotationType.TrapNet, AnnotationType.Underline, AnnotationType.Watermark, AnnotationType.Widget}

One of these types is causing a crash of ExportAnnotationsXfdf() methond.

Hi Aleksandr,

Thank you very much for sharing further details. We’ll investigate this issue at our end and update you accordingly.

We’re sorry for the inconvenience.
Regards,