Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
'chunk' the data.
the only problem is you may have to use some 'intelligent' chunking (because of the html formatting).
Copy link to clipboard
Copied
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....
Copy link to clipboard
Copied
you would do the chunking with code so it's not seen by your users.
Copy link to clipboard
Copied
Sounds interesting. Pls elaborate. Can I "add" to the clipboard? Or how do you mean?
Let's say I want to export a table that the user can paste in Excel. Let's say it has 3.5 million characters. How would I do that? I thought you ment to chunk it into four parts and ask the user to paste part 1, then press a button in the as3 app, paste part 2 and so on. That is not a pretty solution. But do you suggest I can chunk it and programmatically concatenate it in the clipboard from the as3 app?
Copy link to clipboard
Copied
i just realized, i have a clipboard manager and most people do not. so most people cannot 'append' data to their clipboard and that means chunking can't be done seamlessly.