The Browser/notepadWordViewer extension fetches a Notepad text file or a Word document from a URL, displays the fetched content in the browser, and returns the displayed content for use in the journey.
This is useful when a test needs to open document content from a hosted file URL, validate that the content can be loaded, and make the rendered text or converted HTML available as an extension result.
Parameters:
-
fileUrlLinkrequired, a string containing the URL of the Notepad or Word document to fetch; -
fileTyperequired, a string that determines how the file is processed. Usenotepadfor plain text or HTML-like text content, andwordfor Word document content converted through Mammoth;
Note: The file URL must be reachable from the browser session. For Word documents, the extension fetches the file as an array buffer and converts it to HTML before appending it to the page.
NLP usage
Use the extension in a journey by calling Browser/notepadWordViewer with the execute command. Pass each value to the matching extension input using as inputName.
Note: The extension runs asynchronously and completes through done or doneError. The returned value is the fetched text content for Notepad files or the converted HTML content for Word files.
execute "Browser/notepadWordViewer" using "https://example.com/sample.txt" as fileUrlLink, "notepad" as fileType returning $responseexecute "Browser/notepadWordViewer" using "https://example.com/sample.docx" as fileUrlLink, "word" as fileType returning $responseYou can also pass values from variables when the file URL or file type is created earlier in the journey.
execute "Browser/notepadWordViewer" using "$documentUrl" as fileUrlLink, "$documentType" as fileType returning $responsestore value "https://example.com/sample.docx" in $documentUrl
store value "word" in $documentType
execute "Browser/notepadWordViewer" using "$documentUrl" as fileUrlLink, "$documentType" as fileType returning $responseExample output for a Word document is returned as converted HTML content.
<p>Sample document content</p>
<table>
<tr>
<td>Example value</td>
</tr>
</table>This extension requires the following resources:
https://cdn.jsdelivr.net/npm/axios/dist/axios.min.jshttps://cdnjs.cloudflare.com/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js
The extension should be configured as:
- Run asynchronously: Yes
- Scope: Global
Limitation: This extension supports only plain text Notepad-style files when fileType is notepad and Word .docx files when fileType is word. Older .doc files are not supported by Mammoth. File access also depends on CORS, network availability, and whether the file URL is publicly accessible or authenticated correctly.
Add the extension to your Virtuoso instance
Select the domain that matches your Virtuoso account.
View source
Last updated: 25/05/2026
Resources:
https://cdn.jsdelivr.net/npm/axios/dist/axios.min.jshttps://cdnjs.cloudflare.com/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js
function readNotepadContent(url) {
return axios.get(url)
.then(response => {
return response.data;
})
.catch(error => {
throw new Error('There was a problem fetching the file:', error);
});
}
function showContentInBrowser(htmlContent) {
var div = document.createElement('div');
div.innerHTML = htmlContent;
document.body.appendChild(div);
}
async function viewDocument(url, fileType) {
if (fileType === 'notepad') {
try {
const content = await readNotepadContent(url);
showContentInBrowser(content);
return content;
} catch (error) {
throw new Error(error);
}
} else if (fileType === 'word') {
try {
const response = await axios.get(url, {
responseType: 'arraybuffer'
});
const arrayBuffer = response.data;
const fileReader = new FileReader();
return new Promise((resolve, reject) => {
fileReader.onload = function() {
var arrayBuffer = this.result;
var mammothOptions = {
styleMap: [
"p[style-name='Table Contents'] => p:fresh",
"table => table:fresh",
"tr => tr:fresh",
"td => td:fresh"
]
};
mammoth.convertToHtml({
arrayBuffer: arrayBuffer
}, mammothOptions)
.then(result => {
var html = result.value; // HTML content
showContentInBrowser(html);
resolve(html);
})
.catch(error => {
reject(error);
});
};
fileReader.onerror = function() {
reject(new Error('Error reading the file.'));
};
fileReader.readAsArrayBuffer(new Blob([arrayBuffer]));
});
} catch (error) {
throw new Error(error);
}
} else {
throw new Error('Invalid file type');
}
}
let fileUrlInput = fileUrlLink;
let fileTypeInput = fileType;
(async () => {
try {
const content = await viewDocument(fileUrlInput, fileTypeInput);
console.log(content);
} catch (error) {
console.error(error);
throw error;
}
})().then(done).catch(doneError);
Comments
0 comments
Please sign in to leave a comment.