Status Update
Comments
ze...@gmail.com <ze...@gmail.com> #2
It looks like you are raising an issue as an Android user, rather than an Android Open Source Developer. Our Android Support team will be in contact with you shortly. In the meantime, here are helpful resources:
se...@google.com <se...@google.com>
se...@google.com <se...@google.com> #3
Not a user issue. Routing back to sunkesulaa@google.com.
Description
the element.copy() function should copy not just the element but all child elements as well. And that works well when you copy() and then insert() or append() in the same document, but when you try to copy from document to document, in some instances it doesn't work ok. Namely if you have a document that has an image in a table, and you copy() that table and insert it into another document, the destination document will have both the table and the "image" but the image will be empty. I have prepared a function below that demonstrates the problem and I have prepared 2 documents i.e.
src document:
and target document:
Note, the script below will first delete any table from the target document so that if you run it multiple times, it doesn't grow unnecessarily. Also, note that I've hardcoded the document id's, so if you want to try with different documents, you'll have to change them.
function myFunction()
{
//first clear the target document by deleting any table elements there (in reverse) that were left over from previous runs.
var dstDoc=DocumentApp.openById('1MTy4WcJWBNb0F4j95f4Ps3POHPmu6KH7jzukElAWCNA');
var dstBody=dstDoc.getBody();
var dstNumOfElements=dstBody.getNumChildren();
for( var elid=dstNumOfElements -1; elid>=0; elid--)
{
var element = dstBody.getChild(elid);
var type = element.getType();
if( type == DocumentApp.ElementType.TABLE )
{
dstBody.removeChild(element);
}
}
// now open the source document and copy any table from src to target.
var srcDoc=DocumentApp.openById('1xTnsXS7ORFCE1Ptwt4lIaR6eBEeUKv88__orFNUnVUs');
var srcBody=srcDoc.getBody();
var srcNumOfElements=srcBody.getNumChildren();
for( var elid=0; elid<srcNumOfElements-1; elid++)
{
var element = srcBody.getChild(elid)
var type = element.getType();
if( type == DocumentApp.ElementType.TABLE )
{
var elementCopy=element.copy();
dstBody.appendTable(elementCopy);
}
}
}
To see the problem, open the src and dst documents and compare their content. you'll notice that in dst document, the table containing image has an "image" but that image is shown as empty, i.e. white. The same happens when you put a chart in a table. But surprisingly works well with drawings, symbols, horizontal rulers and tables within tables.
If you run the script above, it'll recreate the problem from scratch.
Note: both src and dst document are shared publicli, i.e. anyone with a link can edit them, so if someone deletes the contents of the src doc, the script won't be able to demonstrate the problem. In that case you can:
a) simply insert a couple of tables and then insert some images, diagrams, charts, etc. in the src doc and then run the script
b) contact me, and I'll prepare the files for testing again.