We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to merge annotations with the PDF on serverside?


I have a Angular web app which loads the PDF viewer where the user adds the annotations to the PDF file and exports the annotations to a flat file.

In my usecase, at later point of time, the system should merge the original PDF file with the annotations from the exported annotations file on server side without loading the PDF and annotations file again on front-end.

We use Angular as front-end and Asp.net core 6.0 as back-end. 

Please suggest.


8 Replies 1 reply marked as answer

CK Chinnamunia Karthik Chinna Thambi Syncfusion Team November 21, 2022 09:37 AM

You can use the download option in the PDF Viewer to merge the PDF file with the imported annotations. We have shared the documentation link for your reference.

Documentation: https://ej2.syncfusion.com/angular/documentation/pdfviewer/download/


Kindly let us know if this helps your requirement.

SR Sriraman November 21, 2022 09:28 PM

I know there is a download button in the UI to download the PDF with annotations. As per my requirement, I need to accomplish this task via server side where user does not require any interaction. As mentioned in my original post, I would like to merge the annotations with the PDF on serverside (on .net core web api itself).

Let me know.


SK Sinthiya Kalimuthu Syncfusion Team November 22, 2022 08:43 AM

You can merge the annotation while loading the document. We have shared the sample for your reference. Refer to it and revert to us if you have any concerns about it.

Sample - https://stackblitz.com/edit/angular-p2ejpy-wnt2df?file=app.component.ts,angular.json

Web Service - https://www.syncfusion.com/downloads/support/directtrac/general/7z/Web_Service983755123.7z

Code snippet :

Steps to run the above mentioned sample:

• Run the web services

• Copy the URL produced by the web service project

• In the stack blitz sample, paste the URL in the service URL field.

• Now run the stack blitz and test the reported issue


Sinthiya K

SR Sriraman replied to Sinthiya Kalimuthu November 24, 2022 11:33 AM

Hi Sinthiya,

Thanks for your reply. As mentioned in my original post, in my use case, I need to generate the PDF embedded with annotations via backend (no front-end UI involved while generating the pdf).

IJ Irfana Jaffer Sadhik Syncfusion Team November 25, 2022 05:22 AM

We have attached a sample to add annotations to the pdf document without involving any UI. Please try this on your end and let us know the result.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NetCoreSample-829543986

Follow the below links for more information,



If this does not satisfy your requirement, we request you to share more details on this. so that we can assist further in this.

SR Sriraman November 25, 2022 06:58 AM

My usecase is like this:

  1. I have a dashboard in my UI where the job details are displayed.
  2. User1 clicks a button which opens a page with PDF viewer.
  3. User1 adds annotation to that PDF file using PDF viewer as needed.
  4. User1 clicks the save button in our UI which saves the annotation as xfdf file in the backend.
  5. User2 again visit that job details page and clicks a button which opens a page with PDF viewer.
  6. Now the PDF file is loaded with annotations (created by user 1)
  7. User 2 reviews the annotations added by user 1 and approves the changes or adds additional annotation.
  8. backend time triggered job is getting executed once an hour should send a PDF with embedded annotations via email to certain users.
I am looking for solution for the last point where no user is involved. No UI is accessed. It has access to PDF file and xfdf file. It should embed the annotations with the PDF and send it via email to certain users.

Let me know in case of any queries.

IJ Irfana Jaffer Sadhik Syncfusion Team November 28, 2022 08:32 AM

On further analyzing your requirement we can able to know that your requirement is to import annotations to the pdf document, save it and add any additional annotations if needed to the existing pdf document and wants to send the resultant pdf to the email.

We have created and attached a sample to import annotations to the PDF document and to share the resultant PDF to the mail without any UI involved. Please try this on your end and let us know whether it satisfies your requirement or not.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NetCoreSample-153425936

Please follow the below links for more information,




Marked as answer

SR Sriraman November 28, 2022 10:00 PM

That is what I am looking for. This is what my final piece of code (.net 6).

using Syncfusion.Pdf.Parsing;

string documentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "input.pdf");
string xfdfPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "input.xfdf");
string outFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "out.pdf");
using MemoryStream pdfStream = new(File.ReadAllBytes(documentPath));
using PdfLoadedDocument loadedDocument = new(pdfStream);
using MemoryStream xfdfStream = new(File.ReadAllBytes(xfdfPath));
loadedDocument.ImportAnnotations(xfdfStream, AnnotationDataFormat.XFdf);
MemoryStream loadedPdfStream = new();
File.WriteAllBytes(outFile, loadedPdfStream.ToArray());

Thank you :)

Live Chat Icon For mobile
Up arrow icon