Hi, I am using MsNet to trigger a bot as in this example:
https://help.mjtnet.com/article/331-how ... p-requests
I know that MACRO_RESULT variable can return text response. Is there any way for it to return a file? PDF file in particular?
Thanks in advance
Returning file through MsNet API call
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Returning file through MsNet API call
I'm not 100% sure this is answering your question, but you could certainly use WriteLn to output to a text file.
Macro Scheduler can't natively create a pdf, but it can certainly work with some of the command line PDF creator tools out there.
Code: Select all
hour>TheHour
min>TheMin
sec>TheSec
let>Macro_result=Processed at %TheHour%:%TheMin%:%TheSec%
WriteLn>d:\macro-result.txt,,Macro_Result
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Returning file through MsNet API call
I downloaded and installed the free trial of Total Doc Converter (the full version is not free but the utility looks excellent).
I was able to automate converting the txt output to pdf via the CLI using :
or :
I'm not sure if CoolUtils have anything that churns out a PDF direct from text, but it might be worth looking.
I was able to automate converting the txt output to pdf via the CLI using :
Code: Select all
runprogram>C:\Program Files\CoolUtils\TotalDocConverter\DocConverter64.exe "d:\macro-result.txt" "d:\macro-result2.pdf"
Code: Select all
let>TheProg=C:\Program Files\CoolUtils\TotalDocConverter\DocConverter64.exe
runprogram>%TheProg% "d:\macro-result.txt" "d:\macro-result.pdf"
Re: Returning file through MsNet API call
Hi Dorian, thanks for you replies. I was thinking more of a PDF being returned as a response to whatever calls the API endpoint.
Basically our plan is to have a person initiate the bot remotely by a press of a button that will call the API with some params, the bot will then remotely automate a process which as a result provides a PDF confirmation. We were wondering whether there's any way to return this PDF file back to the client calling this API.
Instead of having html sent in response as in the example:
We were looking into something along the lines of:
This doesn't work of course but would you know if there is any way to do it?
Basically our plan is to have a person initiate the bot remotely by a press of a button that will call the API with some params, the bot will then remotely automate a process which as a result provides a PDF confirmation. We were wondering whether there's any way to return this PDF file back to the client calling this API.
Instead of having html sent in response as in the example:
Code: Select all
Let>MACRO_RESULT=<p>hello %fname% %sname
Code: Select all
Let>MACRO_RESULT=file.pdf
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Returning file through MsNet API call
Once the PDF is created (and uploaded), simply set the Macro_Result to be the HTML to embed a PDF
I just tested that and it worked.
Code: Select all
let>Macro_result=<html><body><embed src="https://d3hk78fplavsbl.cloudfront.net/brochures/VirginHolidays-USAandCANADA-Touring2020.pdf" type="application/pdf" width="100%" height="600px" /></body></html>
Re: Returning file through MsNet API call
Thanks for help. I had to download a page in pdf format, I couldn't provide any direct url to the pdf before downloading it. So I did it through downloading the pdf to a shared OneDrive folder, then got shareable link and embedded it like you suggested.