Hello,
In the PdfLoadedAnnotationCollection class there are 2 indexers, one based on the annotations' index number and the other on it's text. The comment of this text indexer suggests it's based on the name of the annotation. In my opinion it would make more sense to get an annotation based on it's name which is a GUID.
I want to be able to get an annotation based on it's name (guid), can you add a method to fetch the annotation based on it's name?
Hi Wouter,
We recommend you to create the annotation with Guid name and then get the annotation using this API, https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Parsing.PdfLoadedAnnotationCollection.html#Syncfusion_Pdf_Parsing_PdfLoadedAnnotationCollection_Item_System_String_
Note: We have two APIs to get the annotation by using their index and their name.
Regards,
Surya V
Hello Surya,
The annotations are not created from code, but with the toolbar from the PdfViewer control.
Each annotation that is created this way already has a GUID name:
Where is the documentation of the other API that can be used to get annotations? The documentation you linked to is from the API that I'm using already. But as you can see in the screenshot below, there are 5 annotations. When I get the annotation with name 826af3a2-87e9-4c2d-a8c0-56f985a428f7 it returns the last annotation in the collection, not the one I requested:
Hi Wouter,
We have created a sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WpfPDFViewer-1938665148 to get the annotation from the loaded annotation in the PDF document by using Guid name. Kindly refer to the below UG link for more details about getting and setting the annotation name,
Kindly try the attached sample and let us know the result.
Regards,
Surya V
Hello Surya,
If I try to run the provided sample I get:
It starts without the package, but crashes as soon as the PDF is loaded.
Hi Wouter,
We suspect that the reported issue is due to a mismatch of assembly references. We request you to refer to the same product version of Syncfusion assemblies across different projects (dependent ones).
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WpfPDFViewerRevamp387119797
Kindly try the above sample and let us know if you have any concerns about this.
Regards,
Surya V
Hi Surya,
This sample compiles and runs without errors, thanks.
The sample selects the annotation in the viewer, it does not return the annotation object in code (it returns a bool, true if the annotation with the given name is found and selected). I'm looking for a way to get the object in code.
This is the reason I was using the indexer on the LoadedAnnotationCollection. The comments suggest that it returns the annotation based on it's name:
Can you share a sample that stores the annotation
Hi Wouter,
We have fixed the reported issue “Invalid annotation is returned when trying get loaded annotation using its name”. Since our 2022 volume 1 release rolled out yesterday, we do not have weekly NuGet release today. However, we have created a patch for this fix that can be downloaded from the following location. We will include the fix in our upcoming weekly NuGet release.
Recommended approach - exe will perform automatic configuration
Please find the patch setup from the below location: https://syncfusion.com/Installs/support/patch/20.1.0.47/1418186/F173683/SyncfusionPatch_20.1.0.47_1418186_4052022121019400_F173683.exe
Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment
Please find the patch assemblies alone from below location: https://syncfusion.com/Installs/support/patch/20.1.0.47/1418186/F173683/SyncfusionPatch_20.1.0.47_1418186_4052022121019400_F173683.zip
Assembly Version: 20.1.0.47
Installation Directions:
This patch should replace the files “Syncfusion.Pdf.Base.dll, Syncfusion.PdfViewer.WPF.dll” under the following folder.
$system drive: \Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.6
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\9.3.0.61\precompiledassemblies\9.3.0.61\4.0
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location, or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.
Note:
You can change how you receive bug fixes by navigating to the following link and updating your preferences.
https://www.syncfusion.com/support/directtrac/patches
Disclaimer: Please note that we have created this patch for version 20.1.0.47 specifically to resolve the following issue reported in this Forum. 173683
If you have received other patches for the same version for other products, please apply all patches in the order received. This fix will be included in our 2022 Volume 1 SP-1 release which will be available in May 2022.
Please find the feedback link below,
Regards,
Divya