Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created January 30, 2023 14:20
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/b434ba906c59d3258e94c3ca91904072 to your computer and use it in GitHub Desktop.
Save bjoerntx/b434ba906c59d3258e94c3ca91904072 to your computer and use it in GitHub Desktop.
function saveDocument() {
// save document
TXTextControl.saveDocument(TXTextControl.StreamType.AdobePDF, function (e) {
// create temporary link element
var element = document.createElement('a');
element.setAttribute('href', 'data:application/octet-stream;base64,' + e.data);
element.setAttribute('download', "results.pdf");
element.style.display = 'none';
document.body.appendChild(element);
// simulate click
element.click();
// remove the link
document.body.removeChild(element);
});
}
function loadDocument() {
const htmlDocument = "<p>Hello <strong>World!</strong></p>";
TXTextControl.loadDocument(TXTextControl.StreamType.HTMLFormat,
window.btoa(htmlDocument));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment