Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created March 21, 2024 13:35
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/4a8109d836c3da66cc942fdd4f83828a to your computer and use it in GitHub Desktop.
Save bjoerntx/4a8109d836c3da66cc942fdd4f83828a to your computer and use it in GitHub Desktop.
loadDocument(name: string) {
// Call HTTP GET with the name of the document as a query parameter
this.http.get<DocumentData>('/document/load', {
params: {
name: name
}
}).subscribe(
(result) => {
this.selectedDocument = result;
let streamType = TXTextControl.StreamType.InternalUnicodeFormat;
switch (this.selectedDocument.name.split('.').pop()) {
case 'docx':
streamType = TXTextControl.StreamType.WordprocessingML;
break;
case 'rtf':
streamType = TXTextControl.StreamType.RichTextFormat;
break;
case 'doc':
streamType = TXTextControl.StreamType.MSWord;
break;
}
TXTextControl.loadDocument(streamType, this.selectedDocument.data, () => {
TXTextControl.setEditMode(1);
});
},
(error) => {
console.error(error);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment