Lotus Script Web Agent: Send binary data back to browser - lotus-domino

I have a Lotus Script Agent that shall return a decoded PDF file (as attachment) that is stored in Notes as a base64 encoded string:
Print("Content-type: application/pdf")
Print(DecodeBase64(PDFContentBase64))
The issue is that the PDF contains null bytes and the Print statement seems to terminate at the first null byte it encounters. Is there a way to send binary data back to the user's browser from a Lotus Notes Agent?

Having an agent print something that should be interpreted by the browser may not be the best course for your intent.
You could attach the PDF to a document then present that document to the user.
Another way, which may or may not be suitable depending on confidentiality concerns and on how cooperative your admin is, would be to save the pdf in the data/domino/html directory on the server then pass the corresponding URL to the browser.

Related

Can't send a binary attachment to Slack using LogicApp

I'm trying to use a logicapp to get the content of an email and post it to slack. By content I mean:
the body of the email and other elements like From:, Subject:
any attachment in the email (which usually are binary like PDF, Excel, image)
the email itself saved in a blob as .eml file
Slack chat.postMessage API works without any problem to send any text element. This API has some attachment argument but doesn't seemto be designed or binary files (or not for files at all, only strings)
I've tried slack files.upload one but couldn't figure out the syntax, especially the syntax using a regular HTTP POST. Could find examples online using curl, Python, JS and C# SDK but I don't know how to translate them to HTTP POST just like I do with chat.PostMessage
I've tried the API on SOAP UI, using file as argument as per the documentation, and I've used it in different sections: in the header, in the body, and using the Attachment Tab, none of the work and always the same error message : no_file_data
Unfortuatelly slack documentation lacks of details. Here's what it says about files.upload:
You must provide either a file or content parameter.
The content of the file can either be posted using an enctype of multipart/form-data (with the file parameter named file), in the usual way that files are uploaded via the browser, or the content of the file can be sent as a POST var called content. The latter should be used for creating a "file" from a long message/paste and forces "editable" mode.
In both cases, the type of data in the file will be intuited from the
filename and the magic bytes in the file, for supported formats.
I could use alternatives like just saving the attachments in blobs and use Azure functions to send the file, but I want to understand what's the limitations before changing the method.
Any clue?

Create PDF file from emails

I am trying to create a zap where if an email with a certain subject string is sent to me, it automatically saves the body as a file in a specific folder. I could do all of this but I need those files to be in PDF format. How do I go about this?
Last I looked a few months ago, I couldn't find a free convert to PDF function, but there are a few paid subscription apps that would create and return PDFs using the email body.
Search "pdf" on https://zapier.com/apps and you'll see a bunch of options.
If the email is in HTML you can pass the body_HTML field to Cloud Convert. Then use Capture a Website to convert it to a PDF. see screenshot

How does an AWS S3 POST object form initiate an upload

I’m uploading images from a user’s device to a S3 bucket using POST object from a HTML form. Everything is working fine but I don’t understand how the S3 server can initiate an upload from a client browser after the form data (file name, signature, policy, etc.) has been posted to its URL. The image data is in a file on the client device and is not contained in the form, only the file name is there. Where in the process is the upload started and how does the S3 server tell the client browser to upload the image data? Perhaps there’s more communication between the web server and browser during a post/response that I’m not aware of. Any insight would be appreciated.
Further research has shown that the browser itself automatically formats each file as a part of the form submission when the form has an input type="file" control. The file becomes an intrinsic part of the form data submitted and the server side processing knows to look for it as such.
HTML4 input type="file" spec
"The following example shows how the contents of a user-specified file may be submitted with a form. The user is prompted for his or her name and a list of file names whose contents should be submitted with the form. By specifying the enctype value of "multipart/form-data", each file's contents will be packaged for submission in a separate section of a multipart document."

docusign PDF validation issue, is there documentation available?

We have some code which is generating a data filled PDF (fdf) file from an excel spreadsheet which is then being sent to docusign in our test environment.
Some of these work, and some come back with an error "PDF_VALIDATION_FAILED".
We have narrowed it down to the PDF document itself, and have watered down the original template to contain just four fields. We have watered down our excel spreadsheet to four basic fields using (for example) "a,1,a,2" for one input and "aa,1,a,2" as another, however one will consistently work and one will consistently fail.
Viewing the generated PDF's in a local PDF viewer (Adobe and PDF XChange Editor) the document appears fine, viewing the documents side by side in a hex/diff editor (WinMerge) shows minor differences in the streams being sent (as expected).
Is there any documentation on what validation is being performed on the PDF so we can emulate this locally and make sure our PDF's are valid before sending to the docusign API?
Thanks
Template
I am able to successfully create an envelope with the Documents you have provided.
See here for the complete CreateEnvelope request that I have used
I have used these documents that you have provided
Working PDF
Non Working PDF

How can I get the number of pages in a PDF file inside a Google Apps Script?

The PDF files are in my Google Drive. I just got that I can get the number of pages of a PDF sending it as a job to Cloud Print, because Cloud Print will return a JSON object with "numberOfPages" attribute.
Is there any faster and easier way? Thanks in advance.
Well, I actually did like I said.
I take my file, then send it to CloudPrint via its JSON Api. I need to send it to a dummy printer, a printer I registered in CloudPrint but actually is never connected to Internet. Then, I get the number of pages of the PDF file in the value of response's "numberOfPages" attribute. Save this number in some var. Finally, I send a delete petition to JSON Api for my file in the dummy printer, indeed isn't necessary at all.
Thanks!