> 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/salesforce/open-save/load-tiff-documents-salesforce.md).

# Open TIFF documents in Salesforce

Learn how to use config.js with Webviewer, load .tiff files, and convert them to PDF. Explore a sample project on Salesforce PDF App and try the live demo. Salesforce WebViewer adds accurate, reliable

## Getting Started

We recommend the [Overview](/salesforce/get-started/readme.md) page to learn how to correctly use a `config.js` before getting started with using Webviewer.

<a href="https://github.com/ApryseSDK/salesforce-webviewer-tiff-viewer" class="button primary">Sample Project</a>

## Open Document

To view and load `.tiff` files first will be different than loading a standard document file. First you'll need to configure the lwc component `pdftronWvInstance` to divert any tiff files uploaded or selected files and create another `iframeWindow.postMessage` to the config file and transport the tiff file payload.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
handleBlobSelected(record) {
    const blobby = new Blob([_base64ToArrayBuffer(record.body)], {
      type: mimeTypes[record.FileExtension]
    });

    const payload = {
      blob: blobby,
      extension: record.cv.FileExtension,
      filename: record.cv.Title + "." + record.cv.FileExtension,
      documentId: record.cv.Id
    };

    switch (payload.extension){
      case 'tiff':
        this.iframeWindow.postMessage({ type: 'OPEN_TIFF_BLOB', payload }, '*');
        break;
      default:
        this.iframeWindow.postMessage({ type: 'OPEN_DOCUMENT_BLOB', payload }, '*');
        break;
    }
  }
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Recieve Message

In your config file, `recieveMessage` method would receive the tiff file payload. You can then use the full API to manually create a document, add the TIFF image to the document and load the document in WebViewer:

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
window.addEventListener("message", receiveMessage, false);

function receiveMessage(event) {
  if (event.isTrusted && typeof event.data === 'object') {
    switch (event.data.type) {
      case 'OPEN_TIFF_BLOB':
        loadTIFF(event.data.payload)
        break;
      default:
        break;
    }
  }
}

async function loadTIFF(payload){
  var blob = payload.blob;
  
  await PDFNet.runWithoutCleanup(async () => {
    var newDoc = await PDFNet.PDFDoc.create();
    newDoc.initSecurityHandler();
    newDoc.lock();

    let bufferTiff = await blob.arrayBuffer();
    const tiffFile = await PDFNet.Filter.createFromMemory(bufferTiff);
    await PDFNet.Convert.fromTiff(newDoc, tiffFile);
    const buffer = await newDoc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);
    newDoc.unlock();
    instance.loadDocument(newDoc);
  });
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

If you want to download from the Webviewer instance, it would be converted to a `pdf` file.

## Sample project

You can review the Salesforce PDF App to showcase an end-to-end example of search, and how you can leverage it for redaction and content replacing on our [Github repository](https://github.com/ApryseSDK/salesforce-webviewer-tiff-viewer/).

## Live demo

Check out this live [Demo](https://showcase.apryse.com) (hosted outside of Salesforce).


---

# 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/salesforce/open-save/load-tiff-documents-salesforce.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.
