Skip to content

380623: Updated UG documentation for Import and Export annotation #3769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
layout: post
title: Import Export Annotation in EJ2 ASP.NET MVC PDF Viewer | Syncfusion
description: Learn how to Import Export Annotation in ASP.NET MVC PDF Viewer component of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: Import Export Annotation Object
publishingplatform: ##Platform_Name##
documentation: ug
---


# Import and Export annotation

The PDF Viewer library allows you to import annotations from objects or streams instead of loading it as a file. To import such annotation objects, the PDF Viewer control must export the PDF annotations as objects using the [**ExportAnnotationsAsObject()**](https://ej2.syncfusion.com/documentation/api/pdfviewer/#exportannotationsasobject) method. Only the annotations objects that are exported from the PDF Viewer can be imported.

The following steps are used to import and export annotations in various formats such as objects, JSON, and XFDF.

**Step 1:** Follow the steps provided in the [link](https://ej2.syncfusion.com/aspnetmvc/documentation/pdfviewer/getting-started/) to create a simple PDF Viewer sample.

**Step 2:** Use the following code snippet to perform import and export annotation.

```html
<button type="button" onclick="exportAsJson()">Export Annotation As Json</button>
<button type="button" onclick="exportAsXfdf()">Export Annotation As Xfdf</button>
<button type="button" onclick="exportAnnotation()">Export Annotation</button>
<button type="button" onclick="importAnnotation()">Import Annotation</button>

<script>
var exportObject;
//Export annotation as Json
function exportAsJson() {
var viewer = document.getElementById('pdfViewer').ej2_instances[0];
viewer.exportAnnotation('Json');
}
//Export annotation as Xfdf
function exportAsXfdf() {
var viewer = document.getElementById('pdfViewer').ej2_instances[0];
viewer.exportAnnotation('Xfdf');
}
//Export annotation as object.
function exportAnnotation() {
var viewer = document.getElementById('pdfViewer').ej2_instances[0];
viewer.exportAnnotationsAsObject().then(function (value) {
exportObject = value
});
}
//Import annotation that are exported as object.
function importAnnotation() {
var viewer = document.getElementById('pdfViewer').ej2_instances[0];
viewer.importAnnotation(JSON.parse(exportObject));
}
</script>
```

[View sample in GitHub](https://github.com/SyncfusionExamples/mvc-pdf-viewer-examples/tree/master/How%20to)
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
layout: post
title: Import Export Annotation Object in ##Platform_Name## Pdfviewer Component
title: Import Export Annotation in ##Platform_Name## Pdfviewer Component | Syncfusion
description: Learn here all about Import Export Annotation Object in Syncfusion ##Platform_Name## Pdfviewer component of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: Import Export Annotation Object
publishingplatform: ##Platform_Name##
documentation: ug
---

# Import and Export annotation as object
# Import and Export annotation

The PDF Viewer library allows you to import annotations from objects or streams instead of loading it as a file. To import such annotation objects, the PDF Viewer control must export the PDF annotations as objects using the [**ExportAnnotationsAsObject()**](https://ej2.syncfusion.com/documentation/api/pdfviewer/#exportannotationsasobject) method. Only the annotations objects that are exported from the PDF Viewer can be imported.

The following steps are used to import and export annotation as object.
The following steps are used to import and export annotations in various formats such as objects, JSON, and XFDF.

**Step 1:** Follow the steps provided in the [link](https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/getting-started/) to create a simple PDF Viewer sample.

Expand All @@ -26,6 +26,8 @@ The following steps are used to import and export annotation as object.
ViewData["Title"] = "Home page";
}

<button type="button" onclick="exportAsJson()">Export Annoatation As Json</button>
<button type="button" onclick="exportAsXfdf()">Export Annoatation As Xfdf</button>
<button type="button" onclick="exportAnnotation()">Export Annoatation</button>
<button type="button" onclick="importAnnotation()">Import Annoatation</button>

Expand All @@ -38,7 +40,17 @@ The following steps are used to import and export annotation as object.

<script type ="text/javascript">

var exportObject;
var exportObject;
//Export annotation as Json
function exportAsJson(){
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.exportAnnotation('Json');
}
//Export annotation as Xfdf
function exportAsXfdf(){
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.exportAnnotation('Xfdf');
}
//Export annotation as object.
function exportAnnotation() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
Expand All @@ -62,6 +74,8 @@ The following steps are used to import and export annotation as object.
ViewData["Title"] = "Home page";
}

<button type="button" onclick="exportAsJson()">Export Annoatation As Json</button>
<button type="button" onclick="exportAsXfdf()">Export Annoatation As Xfdf</button>
<button type="button" onclick="exportAnnotation()">Export Annoatation</button>
<button type="button" onclick="importAnnotation()">Import Annoatation</button>

Expand All @@ -75,7 +89,17 @@ The following steps are used to import and export annotation as object.

<script type ="text/javascript">

var exportObject;
var exportObject;
//Export annotation as Json
function exportAsJson(){
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.exportAnnotation('Json');
}
//Export annotation as Xfdf
function exportAsXfdf(){
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.exportAnnotation('Xfdf');
}
//Export annotation as object.
function exportAnnotation() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
Expand Down
2 changes: 1 addition & 1 deletion ej2-asp-core-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@
<li><a href="/ej2-asp-core/pdfviewer/how-to/display-document-without-downloading">Display document without downloading</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/show-bookmark">Show Bookmark</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/load-documents">Load the PDF documents dynamically</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/import-export-annotation-object">Import and Export annotation as object</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/import-export-annotation">Import and Export annotation</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/authorization-token">Include the Authorization token</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/open-thumbnail">Open Thumbnail pane programmatically</a></li>
<li><a href="/ej2-asp-core/pdfviewer/how-to/resolve-pdfium-issue">Resolve the Pdfium issue</a></li>
Expand Down
2 changes: 1 addition & 1 deletion ej2-asp-mvc-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/load-the-document">Load the PDF document</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/show-notification-dialog">Show the notification dialog in UI When form fields are empty</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/load-documents">Load the PDF documents dynamically</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/import-export-annotation-object">Import and Export annotation as object</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/import-export-annotation">Import and Export annotation</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/open-thumbnail">Open Thumbnail pane programmatically</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/redirect-to-home-page">Redirect to a home page after submitting PDF forms</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/how-to/resolve-pdfium-issue">Resolve the Pdfium issue</a></li>
Expand Down