Code. Get clipboard data in Java June 21, 2013 June 22, 2013 by omt. Java get Clipboard content with source formatting . Posted by: admin July 28, 2018 Leave a comment. The Get-Clipboard cmdlet gets the contents of the clipboard as text. ). Object. It would be possible to extend this to support other image types by various means, but those are outside the scope of the present response. e.clipboardData.setData('text/plain', escaped); }); // Primitive HTML escape function. new Clipboard('#but_copy'); Add data-clipboard-target attribute to the element which targets from where the text is being copied. Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0). An exception is thrown if either the clipboard is empty or contains other than string (for example an image). Steps: Initialize the Data Object, the type of MSForms.DataObject Get the text from the clipboard using Data Object Get the text out of Data Object using GetText() method. Questions: I have content in my clipboard, and using java creating a new word document using XWPFDocument() and try to paste the clipboard content with exact source formatting . getData. Java get Clipboard content with source formatting . An instance of this interface becomes the owner of the contents of a clipboard (clipboard owner) if it is passed as an argument to Clipboard.setContents(java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner) method of the clipboard and this method returns successfully. Clipboard is a data buffer which is used to store the data for a short-period of time to perform operations like cut, copy and paste. Javascript can easily do this in five short steps: Create a