Save Buffer to ServiceNow
Dear valued Community,
we are currently trying to use and integrate the PDF Embed API in our Platform of "ServiceNow". What we already achived is, that a PDF attachted to a record can be viewed and annotated.
The main problem is, that the PDF get's destroyed after saving it via GlideSysAttachment.write() into the ServiceNow Database. We are receiving a blank PDF which includes the correct number of pages and - if available - save Annotations made via the API.
I think that our code is mocking up the binary part of the PDF, while (trying to) translating the BufferArray into String, as the .write() function is awaiting a plain string.
Our options:
{
showDownloadPDF: true,
showPrintPDF: false,
enableAnnotationAPIs: true,
includePDFAnnotations: true
}
Our Transform-Part in the Save-Promise:
var textDecoder = new TextDecoder('utf-8');
file.content = textDecoder.decode(content);
I know, that we are doing it wrong, because transforming binary into String will mock up the part, but how can we implement the Save-Callback to Store the file as an new Attachment in ServiceNow?
Do we need to use the .writeBase64() function after doing some other magic in the Save-Callback? Our workaround is to download the file via the Download-Option and attaching it back to the record. But - honstly - thats not very userfriendly and we would like to use the possibilities provided by both APIs or systems.
Any help is appreciated!
