> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/open-save-document/open/url.md).

# Open a document by URL

Efficiently open a document in WebViewer from a URL. The Apryse Web SDK streamlines secure, serverless document processing with robust support for JavaScript and TypeScript, and seamlessly integrates

## Opening a document in WebViewer from URL

If you have a URL for a document, you can open it by including [`initialDoc`](https://sdk.apryse.com/api/web/global.html#WebViewerOptions__anchor) as a constructor option or by using the [`loadDocument`](https://sdk.apryse.com/api/web/UI.html#loadDocument__anchor) API.

{% tabs %}
{% tab title="Constructor option" %}
Use the **initialDoc** constructor option to provide the document when mounting WebViewer.

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...,
  initialDoc: 'https://myserver.com/myfile.pdf',
}, document.getElementById('viewer')).then(instance => {
    const { documentViewer } = instance.Core;
    documentViewer.addEventListener('documentLoaded', () => {
      // perform document operations
    });
});
```

{% endcode %}

[WebViewer Options](https://sdk.apryse.com/api/web/global.html#WebViewerOptions__anchor) [documentViewer](https://sdk.apryse.com/api/web/Core.html#.documentViewer__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer({
  ...,
  initialDoc: 'https://myserver.com/myfile.pdf',
}, document.getElementById('viewer')).then(instance => {
    const { docViewer } = instance;
    docViewer.on('documentLoaded', () => {
      // perform document operations
    });
});
```

{% endcode %}

[WebViewer Options](https://sdk.apryse.com/api/web/global.html#WebViewerOptions__anchor) [docViewer](https://sdk.apryse.com/api/web/Core.html#.documentViewer__anchor)
{% endtab %}
{% endtabs %}

###

{% endtab %}

{% tab title="API option" %}
Use [loadDocument](https://sdk.apryse.com/api/web/UI.html#loadDocument__anchor) to load documents with additional loading options after mounting WebViewer.

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    instance.UI.loadDocument('https://myserver.com/myfile.pdf', { filename: 'myfile.pdf' });
    const { documentViewer } = instance.Core;
    documentViewer.addEventListener('documentLoaded', () => {
      // perform document operations
    });
  });
```

{% endcode %}

[UI.loadDocument](https://sdk.apryse.com/api/web/UI.html#loadDocument__anchor) [documentViewer](https://sdk.apryse.com/api/web/Core.html#.documentViewer__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    instance.loadDocument('https://myserver.com/myfile.pdf', { filename: 'myfile.pdf' });
    const { docViewer } = instance;
    docViewer.on('documentLoaded', () => {
      // perform document operations
    });
  });
```

{% endcode %}

[WebViewerInstance.loadDocument](https://sdk.apryse.com/api/web/UI.html#loadDocument__anchor) [docViewer](https://sdk.apryse.com/api/web/Core.html#.documentViewer__anchor)
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
If you are loading from an extensionless URL, please ensure the [extension](/web/open-save-document/open.md#the-extension-option) or [filename](/web/open-save-document/open.md#the-filename-option) options are set.
{% endhint %}

## Loading Options

WebViewer provides various options to load a document. Whether you are loading a document through the `initialDoc` option in the constructor or calling `loadDocument` after mounting, you can always provide [options to load your document](/web/open-save-document/open.md#loading-options).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/web/open-save-document/open/url.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
