BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
Hi guys! I have problems with flattening annotations in PDF documents. None of the approaches I've tried so far works. Please see the demo, files, and project attached.
To be noticed: Very often when I try to load the previously saved file (with the help of await this.SfPdfViewerControl.SaveAsync();) that contains any kind of stamp (added with SfPdfViewerControl.AddStamp();) I get a crush with error message exception "An item with the same key has already been added. Key: 1_CustomView1". But I guess this issue is not related to flattened annotations.
I appreciate any help you can provide!
Attachment: flattenAnnotationsIssue_c2e1038a.zip
Hi Roxy,
Natively, we don't have support to flatten annotations from the viewer. From the sample, we were able to see that you are trying to flatten the annotations using our library directly from the Loadedocument that is available in SfPdfViewerControl, but this LoadedDocment is not updated every time annotations are added. You need to save the document and convert it to a loaded document before saving or loading it again in the viewer.
Kindly refer to the following code to flatten and save for reference.
var stream = await this.SfPdfViewerControl.SaveAsync(); PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream); loadedDocument.FlattenAnnotations(); loadedDocument.Save(stream); stream.Position = 0; await StorageItemPickerProvider.Instance.SaveStreamToFile(this.file, stream); |
Regards,
Deepika R
It works, thank you for solution!
Thank you for your reply. I'm glad to hear that the provided solution works for your scenario. We're marking this ticket as closed.
If you have any other questions or concerns, please don't hesitate to contact us.