Skip to main content
Participant
May 18, 2016
Question

Clipboard setData Chrome limit

  • May 18, 2016
  • 5 replies
  • 1746 views

Hi

Many years ago I developed an application that allows the users to copy data in the form of html to allow the user to easily paste data in other applications such as Excel.

However, I have received complaints that this is not working in Chrome and after some testing I have discovered that there is a limitation to 1 million characters when copying from the application using Chrome. It is working fine in IE as well as for smaller strings in Chrome.

Code to replicate the error...

var str:String = "";

for(var i:uint = 0; i < 1000001; i++)

   str += "X";

trace(str.length)

try {

    Clipboard.generalClipboard.clear();

    var clipboardSuccess:Boolean = Clipboard.generalClipboard.setData(ClipboardFormats.HTML_FORMAT,str);     

    trace("setClipboard " + clipboardSuccess)

} catch (e:Error) {

    trace("Error setClipboard " + e);

}     

Obviously the code has to run in a button event. It is always working in IE and also in Chrome if the string is 1000000 or shorter.

Clipboard.generalClipboard.setData always returns true (success) and is never throwing any error.

System.setClipboard is the same.

Any workarounds? Is this a general Chrome limitation or something the Chrome Flash player?

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

kglad
Community Expert
Community Expert
May 18, 2016

'chunk' the data.

the only problem is you may have to use some 'intelligent' chunking (because of the html formatting).

ndalenAuthor
Participant
May 18, 2016

Thanks kglad for the reply. There are many users of the app and I cannot ask them to cut and paste 3-4 times every time they want to use the data in another application. At the moment I tell users that Chrome is not compatible but it is a shame....

kglad
Community Expert
Community Expert
May 18, 2016

you would do the chunking with code so it's not seen by your users.