UI Customization

================

The Embed API provides a number of options for customizing the user interface and user interactions with the PDF. Features which are enabled by default can be explicitly disabled. Optional configurations include controls for:

Options for Customising User Interface using undo-redo, annotation tools, navigation, zoom etc

You can control various options provided by PDF Embed API and customize the PDF viewer as per your requirements.

Initialize the AdobeDC.View object with your client ID and then invoke the previewFile API on AdobeDC.View object. The previewFile API reads the variable values and toggles features on and off accordingly.

In the example below, the embed mode is set as FULL_WINDOW and the download PDF option is disabled from the overflow menu in the top bar in full window embed mode with showDownloadPDF set to false. The PDF zoom control options are disabled with showZoomControl set to false.

Example

<div id="adobe-dc-view"></div>
<script src="https://acrobatservices.adobe.com/view-sdk/viewer.js"></script>
<script type="text/javascript">
// Store the UI options in a constant
const previewConfig = {
   embedMode: "FULL_WINDOW",
   showDownloadPDF: false,
   showZoomControl: false
}

document.addEventListener("adobe_dc_view_sdk.ready", function () {
   var adobeDCView = new AdobeDC.View({clientId: "<YOUR_CLIENT_ID>", divId: "adobe-dc-view"});
   // Consume previewConfig here. . .
   adobeDCView.previewFile({
      content:{location: {url: "https://acrobatservices.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
      metaData:{fileName: "Bodea Brochure.pdf"}
   }, previewConfig);
});
</script>

Configuration options for AdobeDC.View object

This table lists down the various configurations which can be passed while initializing the AdobeDC.View object. <br/>

Variable
Default
Description
clientId
None
You'll need a client ID to use the Adobe PDF Embed API. To get one, click HERE.
divId
"adobe-dc-view"
The div ID where your PDF will render.
locale
"en-US"
You can select another language by passing the locale code variable. For more details, see the section Language support.
reportSuiteId
None
Pass the report suite ID to collect PDF analytics in Adobe Analytics. For more details, see the section Adobe analytics.
measurementId
None
Pass the measurement ID to collect PDF analytics in Google Analytics. For more details, see the section Google Analytics.
sendAutoPDFAnalytics
true
Use this configuration to disable PDF analytics collection in Adobe Analytics or Google Analytics. For more details, see the section Control analytics collection.

Configuration options for previewFile API

This table lists down the various preview configurations which can be passed to the previewFile API to customize the PDF viewer. <br/>

Variable
Default
Description
showZoomControl
true
Set this to false to hide the zoom-in and zoom-out options available in the right-hand panel. This configuration will work for full window and lightbox embed modes.
showAnnotationTools
true
If true, tools such as add text, sticky note, highlight, and so on appear in the quick tools menu on the left-hand side in full window embed mode. For more details, see Comments and Markup.
showFullScreen
true
By default, the full screen toggle appears in the bottom toolbar in sized container embed mode. Set this to false to hide the full screen toggle.
defaultViewMode
""
This variable takes a string value of "FIT_WIDTH", "FIT_PAGE", "TWO_COLUMN" or "TWO_COLUMN_FIT_PAGE". <br/> 1. FIT_WIDTH: Expands the page horizontally to the full width of the document pane. <br/> 2. FIT_PAGE: Displays the entire page in the current view pane. <br/> 3. TWO_COLUMN: Displays two pages of the PDF side by side in the current view pane. <br/> 4. TWO_COLUMN_FIT_PAGE: Displays two pages of the PDF side by side where the entire two pages are displayed in the current view pane. Note that end users can also toggle the view mode via the Fit Width, Fit Page or Two-Column button on the right-hand panel. <br/><br/>In addition to these, there are two other view modes which are supported only in mobile browsers: <br/> 1. CONTINUOUS: This mode displays all the document pages one after the other and users can easily navigate through the pages by scrolling up or down. <br/> 2. SINGLE_PAGE: This mode displays only a single document page at a time and doesn’t show any adjoining page. Users can use the swipe gesture to navigate to other pages which will be displayed one at a time.
enableFormFilling
true
If true, form filling is enabled and users can edit fields in full window embed mode.
showDownloadPDF
true
If true, PDF can be downloaded in all embed modes. Set this to false to disable PDF download.
showPrintPDF
true
If true, PDF can be printed in all embed modes. Set this to false to disable PDF printing.
exitPDFViewerType
"CLOSE"
The top bar in lightbox embed mode contains the close button by default to close the PDF preview which can be configured to Back button by setting exitPDFViewerType to "RETURN".
showThumbnails
true
Page thumbnails are available by default in full window and lightbox embed modes. Set this to false if you want to hide the thumbnails from the right-hand panel.
showBookmarks
true
PDF bookmarks are available by default in full window and lightbox embed modes. Set this to false if you want to hide the bookmarks from the right-hand panel.
enableLinearization
false
Set this to true to enable PDF linearization. For more details, see the section PDF linearization.
enableAnnotationAPIs
false
Set this to true to add, update and delete PDF annotations programmatically in full window embed mode. For more details, see the section Annotations API overview.
includePDFAnnotations
false
This configuration is used with enableAnnotationAPIs to access existing PDF annotations. For more details, see the section Annotations API overview.
enableSearchAPIs
false
Set this to true to perform search operation in the PDF programmatically. For more details, see the section Search APIs.
showDisabledSaveButton
false
Set this to true to show the save button in disabled state even when there are no changes to be saved to the PDF.
focusOnRendering
Varies according to embed mode
With this configuration, website developers have the flexibility to control if the PDF should take focus when it is rendered. For more details, see the section Focus on PDF rendering.
showFullScreenViewButton
true
Set this to false to hide the full-screen option available in the right-hand panel. This configuration will work for full window and lightbox embed modes.

Annotations

For details, see Comments and Markup.

Callbacks & workflows

The PDF Embed API supports workflow customization via callbacks. By registering callbacks with specified parameters, website developers can control workflows related to saving files, user profiles, user settings, and so on.

Every callback requires the following three parameters:

You can only register one callback per type; for example, you can register one callback for save and one for status.

AdobeDC.View exposes registerCallback, so the code looks something like:

adobeDCView.registerCallback(
  <Callback Type>,
  <Function>,
  options
);

The second parameter is a function which returns a promise which either resolves or fails with a response object consisting of code and data. This promise should resolve in the case of successful execution, and it should be rejected in the case of an error. Pass the relevant code along with the promises:

return new Promise((resolve, reject) => {
 /* Success
  resolve({
      code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
      data: {...}
  }); */

 /* Failure
  reject({
      code: AdobeDC.View.Enum.ApiResponseCode.FAIL,
      data: {...}
  }); */
}

User Profiles

The user profile callback allows the user to specify user profile details such as first name, last name, and email address. By default, if you do not register a user profile callback, the user name is displayed as "Guest" in the comments panel.

User being referred to as guest

When the callback is registered, user annotations are associated with the corresponding username.

User being referred with correct username

User profile callback signature

const profile = {
  userProfile: {
      name: <name of user>,
      firstName: <first name>,
      lastName: <last name>,
      email: <user email>
  }
};

adobeDCView.registerCallback(
   AdobeDC.View.Enum.CallbackType.GET_USER_PROFILE_API,
   function() {
      return new Promise((resolve, reject) => {
         resolve({
            code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
            data: profile
         });
      });
   },
{});

User settings

Users can update the color of an annotation by clicking on the PDF annotation and changing the color from the toolbar. The updated color is applied to all new annotations of that type added to the PDF. Also, when any annotation tool is selected for the first time, there is a coach mark displayed to educate users about the annotation tool which goes away after a few seconds.

data-slots=text
Previously, the default implementation of these user preferences was that the browser used to remember the updated annotation color and also whether the coach mark for a selected annotation tool has been displayed or not. This was achieved by storing this data in the local storage of the PDF Embed API domain. This is now deprecated and PDF Embed API does not store this data.

By default, these preferences are lost when the PDF reloads. As a result, the updated annotation color is not remembered (default annotation color will be applied in this case) and users will see annotation tool coach marks again when the PDF reloads.

Website developers can improve this experience by registering the user setting callbacks. There are two callbacks involved:

Developers can provide their own implementation using these callbacks and save the user preferences wherever they like.

User settings callback signature

adobeDCView.registerCallback(
   AdobeDC.View.Enum.CallbackType.SET_USER_SETTING_API,
   function(setting) {
      /* Add your custom implementation here to save the user setting */
      ...
      ...
      return new Promise((resolve, reject) => {
         resolve({
            code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS
         });
      });
   },
{});


adobeDCView.registerCallback(
   AdobeDC.View.Enum.CallbackType.GET_USER_SETTING_API,
   function() {
      /* Fetch the user setting */
      return new Promise((resolve, reject) => {
         resolve({
            code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
            data: {
               setting: <USER_STORED_SETTING>
            }
         });
      });
   },
{});

Find the working code sample here under /More Samples/Save User Preferences/. In this code sample, the user setting callbacks are used to save the user preferences in the local storage of the website domain. Using this implementation, the browser remembers the updated annotation color and also shows the coach mark only once for every annotation tool in the current browser.

This is only an example and it is up to the website developer how they do the actual implementation of saving the user preferences.

Save a PDF

The Save button on the top bar is not visible unless the PDF is modified: it only becomes active after PDF modification (there are changes to actually save). For example, when showAnnotationTools is true, users can add an annotation or comment, and you can provide them with the option to save the modified PDF to a local or networked location.

data-slots=text
A user cannot add comments or edit PDF files that are secure, protected, or read-only. The annotation tools as well as the save button are hidden for such files.

Note that while the Save button is hidden by default, you can show the button even when there are no changes to save by setting showDisabledSaveButton to true and passing it as a preview configuration to the previewFile API. In this case, the save button appears in disabled state until the PDF is modified.

{
  showDisabledSaveButton: <Boolean, default=false>,
}

Save callback

This callback allows users to save the updated PDF buffer which can then be stored in an external file storage system.

Users can trigger the save functionality by either clicking on the Save or Download button manually or by pressing Ctrl+S on the keyboard. You should register the callback to receive the modified file content when the user initiates the save.

To control the save callback behavior, you can pass the following options:

The second callback parameter is a JavaScript function returning a Promise which either resolves or fails with a response object containing code and data. The function parameters include:

Save callback signature

const saveOptions = {
   autoSaveFrequency: <Number, default=0>,
   enableFocusPolling: <Boolean, default=false>,
   showSaveButton: <Boolean, default=true>
}

adobeDCView.registerCallback(
   AdobeDC.View.Enum.CallbackType.SAVE_API,
   function(metaData, content, options) {
      /* Add your custom save implementation here...and based on that resolve or reject response in given format */
      return new Promise((resolve, reject) => {
         resolve({
            code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
            data: {
               /* Updated file metadata after successful save operation */
               metaData: <File MetaData>
            }
         });
      });
   },
   saveOptions
);

The website developer can write their own save implementation in this function and should send the response object with the appropriate code and data in the following format:

Generic Error Message

<br/>

In this scenario, the current user sees a popup with two options:

File Modified message

Save callback

/* Options to control save behavior */
const saveOptions = {
   autoSaveFrequency: <Number, default=0>,
   enableFocusPolling: <Boolean, default=false>,
   showSaveButton: <Boolean, default=true>
}

/* Register save callback */
adobeDCView.registerCallback(
   AdobeDC.View.Enum.CallbackType.SAVE_API,
   function(metaData, content, options) {
      /* Write down your own save implementation here... and based on that resolve or reject response in given format */
      /* Save callback success case */
      return new Promise((resolve, reject) => {
         resolve({
            code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
            data: {
              metaData: Object.assign(metaData, {fileName: <UPDATED_FILE_NAME>})
            }
         });
      });

     /* Save callback failure case */
     /* return new Promise((resolve, reject) => {
           reject({
              code: AdobeDC.View.Enum.ApiResponseCode.FAIL,
              data: {
                 <Optional>
              }
           });
        }); */

     /* Save callback file modified case */
     /* return new Promise((resolve, reject) => {
           resolve({
              code: AdobeDC.View.Enum.ApiResponseCode.FILE_MODIFIED,
              data: {
                 modifiedBy: {
                   name: <Username of the user who modified the file>,
                   mail: <Email of the user who modified the file>,
                 }
              }
           });
        }); */
   },
   saveOptions);

Status callback

The status callback allows you to poll the status of the file to check whether the currently open file is changed by another user or not. This file status polling occurs after a fixed interval of time defined in the filePollFrequency option. Use both the save and status callbacks together to achieve the complete save experience including auto-save and file status polling.

data-slots=text
While you can specify additional options to control the status callback, both autoSaveFrequency and enableFocusPolling are deprecated for the status callback. Developers are advised to use these options with the save callback.

Status callback signature

const statusOptions = {
   filePollFrequency: <Number, default=10>,
   keepPolling: <Boolean, default=false>
};

adobeDCView.registerCallback(
   AdobeDC.View.Enum.CallbackType.STATUS_API,
   function(metaData) {
      /* Resolve or reject response in given format */
      return new Promise((resolve, reject) => {
         resolve({
            code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
            data: {
               <Optional>
            }
          });
       });
    },
    statusOptions
);

The second parameter of the callback is a JavaScript function returning a Promise which either resolves or fails with a response object containing a code and data. metaData is the only function parameter, and it refers to the file information. The response code in the Promise can take either SUCCESS or FILE_MODIFIED:

SUCCESS: Use the response code SUCCESS to denote successful file polling and that the file has no changes made by another user. Response data is optional here.

FILE_MODIFIED: Use the response code FILE_MODIFIED to capture the case of conflicting updates made by another user in a file sharing scenario. Response data will contain the name and email of the other user modifying the same file. Note the following:

Get Latest Version message <br/>

Conflict On Save message

Status callback

const statusOptions = {
       filePollFrequency: <Number, default=10>,
       keepPolling: <Boolean, default=false>
    };

    adobeDCView.registerCallback(
       AdobeDC.View.Enum.CallbackType.STATUS_API,
       function(metaData) {
          /* Resolve or reject response in given format */
          /* Status callback success case */
          return new Promise((resolve, reject) => {
             resolve({
                code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
             });
          });

          /* Status callback file modified case */
          /* return new Promise((resolve, reject) => {
                resolve({
                   code: AdobeDC.View.Enum.ApiResponseCode.FILE_MODIFIED,
                   data: {
                      modifiedBy: {
                         name: <Username of the user who modified the file>,
                         mail: <Email of the user who modified the file>,
                      }
                   }
                });
             }); */
       },
       statusOptions
    );

Viewer API

The PDF Embed API provides a number of viewer APIs for customizing the user interface and user interactions with the PDF. These APIs can be used to perform UI customizations programmatically at run-time.

GetAPIs Interface

The getAPIs interface allows you to invoke any of the viewer APIs as follows:

<html>
<head>
 <title>Adobe Acrobat Services PDF Embed API Sample</title>
 <meta charset="utf-8"/>
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
 <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body style="margin: 0px">
 <div id="adobe-dc-view"></div>
 <script src="https://acrobatservices.adobe.com/view-sdk/viewer.js"></script>
 <script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function()
    {
        var adobeDCView = new AdobeDC.View({clientId: "<YOUR_CLIENT_ID>", divId: "adobe-dc-view"});
        var previewFilePromise = adobeDCView.previewFile({
         content:   {location: {url: "https://acrobatservices.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
           metaData:  {fileName: "Bodea Brochure.pdf"}
     });

     previewFilePromise.then(adobeViewer => {
     adobeViewer.getAPIs().then(apis => {
          // All viewer APIs can be invoked here
      });
    });
  });
 </script>
</body>
</html>

Zoom APIs

These APIs can be used to perform zoom operations on the PDF programmatically. These APIs are supported in all embed modes except in-line embed mode.

getZoomLimits

This API returns the minimum and maximum allowed zoom levels of the PDF.

Input parameters

N/A

API output

Returns a Promise which,

API signature
	
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getZoomAPIs().getZoomLimits()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

zoomIn

This API zooms in on the PDF and magnifies the PDF view to the next zoom level. The magnified zoom level will never exceed the maximum zoom level of the PDF.

Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getZoomAPIs().zoomOut()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

zoomOut

This API zooms out of the PDF and reduces the PDF view to the previous zoom level. The reduced zoom level will never be less than the minimum zoom level of the PDF.

Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getZoomAPIs().zoomOut()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

setZoomLevel

This API accepts a float value as input and sets the zoom level of the PDF to that value. The input must lie between the minimum and maximum allowed zoom levels of the PDF.

If the input passed is less than the minimum zoom level, then the minimum zoom level is applied to the PDF. Similarly, if the input passed is greater than the maximum zoom level, then the maximum zoom level is applied.

Input parameters

<ZOOM_LEVEL: Float>

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getZoomAPIs().setZoomLevel(<ZOOM_LEVEL>)
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

Search APIs

This API can be used to search for a term in the PDF programmatically. This API is supported in all embed modes.

In order to enable search APIs, the configuration variable enableSearchAPIs should be set to true and passed as a preview configuration to the previewFile API.

<html>
<head>
 <title>Adobe Acrobat Services PDF Embed API Sample</title>
 <meta charset="utf-8"/>
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
 <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body style="margin: 0px">
 <div id="adobe-dc-view"></div>
 <script src="https://acrobatservices.adobe.com/view-sdk/viewer.js"></script>
 <script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function()
    {
        var adobeDCView = new AdobeDC.View({clientId: "<YOUR_CLIENT_ID>", divId: "adobe-dc-view"});
        var previewFilePromise = adobeDCView.previewFile({
           content:   {location: {url: "https://acrobatservices.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
           metaData:  {fileName: "Bodea Brochure.pdf"}
       }, { enableSearchAPIs: true });

       previewFilePromise.then(adobeViewer => {
          adobeViewer.getAPIs().then(apis => {
              // All viewer APIs can be invoked here
          });
       });
  });
 </script>
</body>
</html>
data-slots=text
The document search option is not available in UI when search APIs are enabled.

The search API takes a search term of String value as input and searches for that term in the entire document. The first occurrence of the search term is highlighted in the PDF, starting from the current page in view.

Input parameters

<SEARCH_STRING: String>

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.search(<SEARCH_STRING>)
                        .then(searchObject => console.log(searchObject))
                        .catch(error => console.log(error));
        });
});

onResultsUpdate

Users can register a callback function and pass as an input to the onResultsUpdate() function. This callback function will be triggered every time a search operation takes place through the search API and the search result is highlighted in the PDF. The callback function will receive important information about the current search result in the form of a JSON. The JSON will include information such as current page number, current search result index, total number of search results and status.

{
    currentResult: {
        pageNumber: Integer,  // Current page number in view
        index: Integer,       // Index of the current highlighted search result
    },
    totalResults: Integer,   // Total number of search results found till the time callback function is executed
    status: String           // Status of search result till the time callback function is executed. Values can be "IN_PROGRESS" or "COMPLETED".
}
Input parameters

N/A

API output

Returns a Promise which,

API signature
function callbackFunction(searchResult) {
        console.log("Current search result: ", searchResult);
}

previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.search(<SEARCH_STRING>).then(searchObject => {
                        searchObject.onResultsUpdate(callbackFunction)
                                .then(result => console.log(result))
                                .catch(error => console.log(error));
                })
                .catch(error => console.log(error));
        });
});

next

This function will highlight and navigate to the next search result in the PDF.

Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.search(<SEARCH_STRING>).then(searchObject => {
                        searchObject.next()
                                .then(result => console.log(result))
                                .catch(error => console.log(error));
                })
                .catch(error => console.log(error));
        });
});

previous

This function will highlight and navigate to the previous search result in the PDF.

Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.search(<SEARCH_STRING>).then(searchObject => {
                        searchObject.previous()
                                .then(result => console.log(result))
                                .catch(error => console.log(error));
                })
                .catch(error => console.log(error));
        });
});

clear

This function will cancel the ongoing search operation and clear the search results.

Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.search(<SEARCH_STRING>).then(searchObject => {
                        searchObject.clear()
                                .then(result => console.log(result))
                                .catch(error => console.log(error));
                })
                .catch(error => console.log(error));
        });
});
data-slots=text
Find the working code sample for search and zoom APIs here under /More Samples/Viewer APIs/Search and Zoom APIs

Bookmark APIs

These APIs programmatically access existing PDF bookmarks. Note that only the Full Window embed mode supports these APIs.

getBookmarks

This API returns the list of existing PDF bookmarks Each bookmark item in this list is represented as a JSON containing important information such as ID, title and the list of nested bookmarks residing under this bookmark.

{
    id: Number      // Unique identifier of the bookmark
    title: String,  // Title of the bookmark
    children: [ CHILD_BOOKMARK_1, CHILD_BOOKMARK_2, ... ]     // List of nested bookmarks which exists under this bookmark
}
Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getBookmarkAPIs().getBookmarks()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

openBookmark

This API accepts a bookmark ID as input and navigates to that particular PDF bookmark.

Input parameters

<BOOKMARK_ID>

API output

Returns a Promise which,

API signature
const bookmark_ID = <BOOKMARK_ID>;

previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getBookmarkAPIs().openBookmark(bookmark_ID)
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});
data-slots=text
Find the working code sample here under /More Samples/Viewer APIs/Bookmark APIs

Attachment APIs

These APIs access the existing attachments in the PDF programmatically.

getAttachments

This API returns the list of existing attachments in the PDF. Each attachment item in this list is represented as a JSON containing important information such as name, mime type, description, creation date and modified date.

{
    name: String         // Name of the attachment file
    description: String, // Description of the attachment
    mimeType: String     // Mime type of the attachment file
    created: Date        // Date when the attachment was created
    modified: Date       // Date when the attachment was modified
}
Input parameters

N/A

API output

Returns a Promise which,

API signature
	
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getAttachmentAPIs().getAttachments()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

getAttachmentBuffer

This API accepts the name of an attachment as input and returns the ArrayBuffer of the attachment content.

Input parameters

<ATTACHMENT_NAME: String>

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getAttachmentAPIs().getAttachmentBuffer(<ATTACHMENT_NAME>)
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});
data-slots=text
Find the working code sample here under /More Samples/Viewer APIs/Attachment APIs

getPDFMetadata

This API returns basic information about the PDF fetched from the PDF dictionary; for example, the PDF's number of pages and title.

Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getPDFMetadata()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

getXMPMetadata

XMP (Extensible Metadata Platform) is a technology developed by Adobe which provides a common XML framework to store metadata in digital documents. XMP Metadata includes information about the document and its contents, such as the author's name, keywords, and copyright information.

getXMPMetadata checks the PDF for XMP metadata and returns it if present. The API accepts two optional input parameters.

Input parameters

(fields = [<field1>, <field2>, ...], includeRawStream = <Boolean>)

API output

Returns a Promise which,

API signature
	
const fields = ["dc:title", "dc:creator", "xmp:CreateDate"];
const includeRawStream = true;
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getXMPMetadata(fields, includeRawStream)
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

getSelectedContent

If a user selects any content in the viewer, then the selected content can be fetched using this API. This API currently only works with text selection.

Input parameters

N/A

API output

Returns a Promise which,

API signature
	
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getSelectedContent()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
        });
});

setCursor

This API sets the page cursor to any cursor style, such as help, wait, crosshair, etc.

Input parameters

A string denoting the cursor style: <Cursor_Type>

API output

N/A

API signature
	
const cursor_type = <Cursor_Type>;
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.setCursor(cursor_type)
  .then(()  =>  console.log("Success"))
  .catch(error  =>  console.log(error));
         });
});

resetCursor

This API revokes an applied cursor style and reverts it to the default cursor style.

Input parameters

N/A

API output

N/A

API signature
previewFilePromise.then(adobeViewer => {

        adobeViewer.getAPIs().then(apis => {
                apis.resetCursor();
         });
});

getCurrentPage

This API returns the current page number of the in focus page.

Input parameters

N/A

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getCurrentPage()
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
         });
});

getPageZoom

This API takes the PDF page number as input and returns the zoom level of that page.

Input parameters

<Page_Number>

API output

Returns a Promise which,

API signature
	
previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.getPageZoom(<Page_Number>)
                        .then(result => console.log(result))
                        .catch(error => console.log(error));
         });
});

gotoLocation

This API enables navigation to any PDF page. It accepts a page number as input. You can also pass the x and y coordinates on the page as optional input parameters to enable navigation to a particular location on the page. When no coordinates are passed, the default coordinates are (0, 0).

data-slots=text
Navigation will not work if the specified page number exceeds the PDF page limit. Moreover, the x and y input coordinates must be within the PDF page width and height limit. If either the x or y coordinate is not within the page limit, then they default to 0.
Input parameters

(<Page_Number>, <X_Coordinate>, <Y_Coordinate>)

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {

        adobeViewer.getAPIs().then(apis => {
                apis.gotoLocation(<Page_Number>, <X_Coordinate>, <Y_Coordinate>)
                        .then(() => console.log("Success"))
                        .catch(error => console.log(error));
         });
});

clearPageSelection

This API accepts a page number as input and clears any text selection applied to the page.

Input parameters

<Page_Number>

API output

Returns a Promise which,

API signature
previewFilePromise.then(adobeViewer => {

adobeViewer.getAPIs().then(apis => {
                apis.clearPageSelection(pageNumber)
                        .then(() => console.log("Success"))
                        .catch(error => console.log(error));
         });
});

enableTextSelection

This API controls text selection in PDF. The default is enabled (true). Note that disabling text selection also disables the highlight annotation tool from the quick tools menu on the left-hand side.

Input parameters

Boolean

API output

Returns a Promise which,

API signature
const allowTextSelection = false;

previewFilePromise.then(adobeViewer => {
        adobeViewer.getAPIs().then(apis => {
                apis.enableTextSelection(allowTextSelection)
                        .then(() => console.log("Success"))
                        .catch(error => console.log(error));
         });
});