Reads available formats for the clipboard type
Optional
type: ClipboardSelectionTypeClipboard Type defaults to 'clipboard', use 'selection' for linux
fin.Clipboard.getAvailableFormats().then(formats => console.log(formats)).catch(err => console.log(err));
Read the content of the clipboard as Html
Optional
type: ClipboardSelectionTypeClipboard Type defaults to 'clipboard', use 'selection' for linux
fin.Clipboard.readHtml().then(html => console.log(html)).catch(err => console.log(err));
Read the content of the clipboard as a base64 string or a dataURL based on the input parameter 'format', defaults to 'dataURL'
Clipboard Read Image request with formatting options
// see TS type: OpenFin.ImageFormatOptions
const pngOrDataURLOrBmpOptions = {
format: 'png', // can be: 'png' | 'dataURL' | 'bmp'
};
const jpgOptions = {
format: 'jpg',
quality: 80 // optional, if omitted defaults to 100
};
fin.Clipboard.readImage(pngOrDataURLOrBmpOptions)
.then(image => console.log('Image read from clipboard as PNG, DataURL or BMP', image))
.catch(err => console.log(err));
fin.Clipboard.readImage(jpgOptions)
.then(image => console.log('Image read from clipboard as JPG', image))
.catch(err => console.log(err));
// defaults to {format: 'dataURL'}
fin.Clipboard.readImage()
.then(image => console.log('Image read from clipboard as DataURL', image))
.catch(err => console.log(err));
Read the content of the clipboard as Rtf
Optional
type: ClipboardSelectionTypeClipboard Type defaults to 'clipboard', use 'selection' for linux
const writeObj = {
data: 'some text goes here'
};
async function readRtf() {
await fin.Clipboard.writeRtf(writeObj);
return await fin.Clipboard.readRtf();
}
readRtf().then(rtf => console.log(rtf)).catch(err => console.log(err));
Read the content of the clipboard as plain text
Optional
type: ClipboardSelectionTypeClipboard Type defaults to 'clipboard', use 'selection' for linux
fin.Clipboard.readText().then(text => console.log(text)).catch(err => console.log(err));
Writes data into the clipboard
The object for writing data into the clipboard
fin.Clipboard.write({
data: {
text: 'a',
html: 'b',
rtf: 'c',
// Can be either a base64 string, or a DataURL string. If using DataURL, the
// supported formats are `data:image/png[;base64],` and `data:image/jpeg[;base64],`.
// Using other image/<format> DataURLs will throw an Error.
image: '...'
}
}).then(() => console.log('write data into clipboard')).catch(err => console.log(err));
Writes data into the clipboard as Html
The object for writing data into the clipboard
fin.Clipboard.writeHtml({
data: '<h1>Hello, World!</h1>'
}).then(() => console.log('HTML On clipboard')).catch(err => console.log(err));
Writes data into the clipboard as an Image
The object to write an image to the clipboard
fin.Clipboard.writeImage({
// raw base64 string, or dataURL of either data:image/png or data:image/jpeg type
image: '...'
}).then(() => console.log('Image written to clipboard')).catch(err => console.log(err));
Writes data into the clipboard as Rtf
The object for writing data into the clipboard
fin.Clipboard.writeRtf({
data: 'some text goes here'
}).then(() => console.log('RTF On clipboard')).catch(err => console.log(err));
Writes data into the clipboard as plain text
The object for writing data into the clipboard
fin.Clipboard.writeText({
data: 'hello, world'
}).then(() => console.log('Text On clipboard')).catch(err => console.log(err));
The Clipboard API allows reading and writing to the clipboard in multiple formats.