# Clarification on Exporting and Importing Annotations in PDF.js Express Plus: API Usage and Limits

**URL:** <https://pdfjs.community/t/clarification-on-exporting-and-importing-annotations-in-pdf-js-express-plus-api-usage-and-limits/3537>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [December 3, 2024, 7:05pm UTC](https://pdfjs.community/t/clarification-on-exporting-and-importing-annotations-in-pdf-js-express-plus-api-usage-and-limits/3537 "2024-12-03T19:05:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashokkumar.kunchala](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@ashokkumar.kunchala](https://pdfjs.community/u/ashokkumar.kunchala)\
**Post date:** [December 3, 2024, 7:05pm UTC](https://pdfjs.community/t/clarification-on-exporting-and-importing-annotations-in-pdf-js-express-plus-api-usage-and-limits/3537/1 "2024-12-03T19:05:05Z")

</div>

### **Which product are you using?**

PDF.js Express Plus

### **PDF.js Express Version**

8.7.2

### **Detailed description of issue**

I am using PDF.js Express Plus version 8.7.2 with the annotation feature enabled. My goal is to:

1. **Save annotations** drawn on the viewer to a database.
2. **Load annotations** back into the document from the database when revisiting the document.

I am using the following code for importing and exporting annotations:

#### **Loading Annotations from Database:**

javascript

Copy code

```javascript
// After the document is loaded, we load the annotations from the database
instance.Core.documentViewer.addEventListener('documentLoaded', async () => {
  const xfdfString = await loadXFDF(docId);
  await instance.Core.annotationManager.importAnnotations(xfdfString);
});

```

#### **Saving Annotations to Database:**

javascript

Copy code

```javascript
// When the "save" button is clicked, we export 
// the annotations and save them to the database
saveButton.onclick = async () => {
  const xfdfString = await instance.Core.annotationManager.exportAnnotations();
  await saveToDatabase(docId, xfdfString);
};

```

### **Questions:**

1. **Are `exportAnnotations` and `importAnnotations` API-dependent calls, or are they strictly handled on the client side?**  
Specifically, do they require API usage credits, or are they independent of API limits?
2. **Is there a limit on the size or complexity of annotations when using `exportAnnotations` and `importAnnotations`?**  
Will exporting a large number of annotations or importing a large XFDF string impact the viewer’s performance or cause any issues?
3. **Are there any recommended best practices for handling large XFDF strings when saving to and loading from the database?**

### **Expected behaviour**

- The annotations should export as an XFDF string without any API limitations or size restrictions and should load back correctly into the viewer without performance degradation.

### **Does your issue happen with every document, or just one?**

This is a general question, applicable to any document.

### **Link to document**

N/A

### **Code snippet**

Provided above.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [December 3, 2024, 9:00pm UTC](https://pdfjs.community/t/clarification-on-exporting-and-importing-annotations-in-pdf-js-express-plus-api-usage-and-limits/3537/3 "2024-12-03T21:00:44Z")

</div>

Hi there,

1. **Are `exportAnnotations` and `importAnnotations` API-dependent calls, or are they strictly handled on the client side?**  
Specifically, do they require API usage credits, or are they independent of API limits?

This is handled on the client side and does not use API usage credits.

1. **Is there a limit on the size or complexity of annotations when using `exportAnnotations` and `importAnnotations`?**  
Will exporting a large number of annotations or importing a large XFDF string impact the viewer’s performance or cause any issues?

This will depend on the annotation size and the number of annotations. You can test various documents on our demo page to get a general idea of the performance speed:

> **[PDF.js Viewer Demo | PDF.js Express](https://pdfjs.express/demo)**
>
> Try the PDF.js Express Viewer demo: 26 out-of-the-box annotations, PDF form filling, e-signatures, UI customization, light/dark themes & more.

You might want to also consider Apryse WebViewer as an alternative if performance is important for you:

> **[Apryse WebViewer Demo: JavaScript PDF Viewer Demo](https://showcase.apryse.com/)**
>
> WebViewer is a powerful JavaScript Document SDK that enables your application with more than 100+ pre-built features from viewing to collaborating, document manipulation, redaction and more. WebViewer works in all frameworks and browsers. In...

> **[Apryse SDK Feature Chart](https://apryse.com/feature-chart)**
>
> Apryse

1. **Are there any recommended best practices for handling large XFDF strings when saving to and loading from the database?**

What you have above is generally the recommend way:

> **[Importing and exporting annotations | Documentation](https://pdfjs.express/documentation/annotation/import-export)**

However, if there are large amounts of annotations, you may want to parse them partially at a time. You can break down the number of annotations and import them slowly instead of all at once.

Best regards,  
Kevin

---

<div class="post-metadata">

**Author:** ![ashokkumar.kunchala](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@ashokkumar.kunchala](https://pdfjs.community/u/ashokkumar.kunchala)\
**Post date:** [December 12, 2024, 8:14am UTC](https://pdfjs.community/t/clarification-on-exporting-and-importing-annotations-in-pdf-js-express-plus-api-usage-and-limits/3537/4 "2024-12-12T08:14:25Z")

</div>

Thanks Kevin for the support and prompt response
