Files, clipboard, printing and links
7 min read
A streamed app still has to hand work back to the person using it: a PDF, a link, a copied value, a printout. The SDK gives your app direct calls for each, so you do not have to bolt on a file share or a print server.
Send a file to the browser
Call Onscryn_SendFile with the full path of a file on the host, the name to show, and a MIME type. Leave the name and type empty and the SDK uses the file's own name and guesses the type from its extension. The browser downloads the file, or opens it in a tab when it can, which suits PDFs the user may want to print on their own printer.
The file travels with the session, so there is no shared folder to set up, and it goes only to the viewer of that session.
Open a link
Onscryn_OpenUrl asks the browser to open a URL, in place of a shell call on the host that would open a browser nobody can see.
Receive files from the user
Set the upload callback to receive a file the user chooses to upload, as a name and the bytes. Set the drop callback to receive a file dropped onto the picture, as a name, the bytes and the drop position as fractions of the surface, so you can decide which control it landed on.
Clipboard
Browser to app: the clipboard callback receives text the user pasted. App to browser: call Onscryn_SendClipboard to push text to the user's clipboard. The reference app watches the host clipboard on a background thread and sends changes, so copying in the app lands in the browser without an extra step.
Clipboard and file transfer can be switched off per application in Admin, then Apps. Test your flows with those controls on, because a blocked action never arrives.
Print to the user's printer
Call Onscryn_EnablePrinting once after starting the SDK. It makes the Onscryn Printer the Windows default for the account your app runs as, and delivers every PDF printed to it to the user's browser, where it opens in a tab to print or save.
It returns 1 when printing is ready, 2 when it is watching but the printer is not installed on the host, and 0 when it could not start. On 2, fall back to generating the PDF yourself and sending it with Onscryn_SendFile, as the reference app does.
The Onscryn Printer has to be installed on the host for browser printing to work. A host without it still works for everything else.