Created
March 12, 2024 12:27
-
-
Save bjoerntx/5fdeace70208ce37fb057f8be539e69f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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