Created
October 18, 2023 10:25
-
-
Save bjoerntx/a0f66e268c4c875a04d78cc6b476a12e 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
async function saveDocument() { | |
try { | |
const saveSettings = { mergeFormFields: true, embedAnnotations: false }; | |
const result = await TXDocumentViewer.saveDocument( | |
TXDocumentViewer.StreamType.InternalUnicodeFormat, | |
saveSettings); | |
const base64 = await result.base64(); | |
const data = { document: base64 }; | |
const { success, error } = await saveDocumentAjax(data); | |
if (success) { | |
alert("Document saved."); | |
} else { | |
alert("Error saving document."); | |
} | |
} catch (error) { | |
console.error("An error occurred:", error); | |
} | |
} | |
async function saveDocumentAjax(data) { | |
return new Promise((resolve) => { | |
$.ajax({ | |
type: "POST", | |
url: "/Home/receiveDocument", | |
data: data, | |
success: (data) => resolve({ success: true, data }), | |
error: (xhr, ajaxOptions, thrownError) => resolve({ success: false, error: thrownError }), | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment