Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created March 12, 2024 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/5fdeace70208ce37fb057f8be539e69f to your computer and use it in GitHub Desktop.
Save bjoerntx/5fdeace70208ce37fb057f8be539e69f to your computer and use it in GitHub Desktop.
import React, { useRef, useEffect } from 'react';
import DocumentViewer from '@txtextcontrol/tx-react-document-viewer'
function App() {
useEffect(() => {
window.addEventListener('documentViewerLoaded', handleLoaded);
}, []);
const handleLoaded = (event) => {
var html = "<html><p>This is a document</p></html>";
var base64 = btoa(html);
event.srcElement['TXDocumentViewer'].loadDocument(base64, "loaded.html");
};
return (
<DocumentViewer
width="1000px"
height="800px"
basePath="https://backend.textcontrol.com?access-token=yourtoken">
</DocumentViewer>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment