Page 1 of 1

Copying Table Containing Footnote

PostPosted: Mon Nov 19, 2012 10:43 pm
by Zaeem
Hello guys!
What I want to do is to copy a table from one document to another, and that table contains a cell that has a footnote reference. I used the following code, that compiles, but when I try to open the document it gives an error saying "One or more footnotes referenced in the document are missing or corrupt."

Code: Select all
// Get a list of tables from the source document
List<Object> listOfTables= getAllElementFromObject(sourceDocument.getMainDocumentPart(), Tbl.class);

// Select the table at index 0, containing the cell having footnote reference
Tbl footNoteTable = (Tbl)referenceTables.get(0);

// Make a deep copy of that table
Object footNoteTableCopy = XmlUtils.deepCopy(footNoteTable);

// This function places the copied table below placeholder text in destination
insertTable(destinationDocument, "Placeholder Text", (Tbl)footNoteTableCopy);


Any help would be welcomed!
Thanks!

Re: Copying Table Containing Footnote

PostPosted: Tue Nov 20, 2012 2:49 pm
by jason
You need to find the footnote reference, then get the relevant footnote from the footnotes part, then copy it to the footnotes part in the target docx, then change the footnote reference to match the new number.

Or use MergeDocx ;-)

Re: Copying Table Containing Footnote

PostPosted: Tue Nov 20, 2012 4:00 pm
by Zaeem
Thanks for the quick reply Jason!
Could you please guide me in doing the stuff you mentioned by hinting some code. I'm a beginner in all this stuff :) Thanks in advance!

Re: Copying Table Containing Footnote

PostPosted: Wed Nov 21, 2012 12:31 pm
by jason
Sorry, I don't have time right now to do your work for you.

So you can either roll up your sleeves, or pay someone to do it for you. If you choose the latter and need to find someone to do it, you are welcome to post in the marketplace sub-forum. But for this particular thing, if you don't write the code yourself, MergeDocx might be the most cost effective approach!