For the complete documentation index, see llms.txt. This page is also available as Markdown.

What is a Document Event?

A document event occurs any time you open or create a new document using the SDK. In other words, any time you load a document into memory, it is counted as a document event.

Any operations that you make on a document after it's been loaded are not document events. You can perform as many operations on an opened document as you want without incurring additional document events.

The following sections include just a few languages as examples, but the rules apply to all languages that our SDKs support.

Opening files

In WebViewer, loading a new file into the viewer or into memory in any way counts as a document event. Interacting with that document after its loaded will not count as additional document events.

JavaScriptWebViewer({
  // Counts as a document event
  initialDoc: 'https://myserver.com/myfile.pdf',
}, document.getElementById('viewer')).then(instance => {
  // Counts as a document event
  instance.UI.loadDocument('https://myserver.com/myfile.pdf', { filename: 'myfile.pdf' });
  instance.UI.addEventListener(UI.Events.TAB_MANAGER_READY, async () => {
    // Counts as a document event
    await UI.TabManager.addTab('https://myserver.com/myfile.pdf', { setActive: true });
  });
});

In the server-side SDKs, loading a new file into memory in any way counts as a document event.

// Counts as a document event
const doc = await PDFNet.PDFDoc.createFromFilePath(filename);
// Counts as a document event
PDFDoc doc(filename);
// Counts as a document event
PDFDoc doc = new PDFDoc(filename);

Blank files

Creating a new blank file in WebViewer or the server SDKs counts as a document event.

Converting files

Some APIs allow you to convert a file and write it to disk. In the event where you want to perform additional operations on the converted file, loading it into memory will count as a document event.

Operations with multiple files

Operations that input multiple files may count as more than one document event. For example, merging two documents into one will count as two document events.

In operations like merging, it is recommended that you merge one document into another (2 document events), rather than creating a new blank file and then merging two documents into it (which would be 3 document events).

Saving files

Saving files does not count as a document event. After the document has been loaded into memory, you can save that document as many times as you want without incurring additional document events.

For example, you could load a file into memory (1 document event), and then convert that file to 5 different formats while only incurring 1 document event.

Additional information

If you are still unsure about what counts as a document event, or you're not sure how many document events your project will use, please reach out to our support team for more information.

Last updated

Was this helpful?