I have a requirement, which I should merge two or more word files (.docx) together into one file.
because I can't do arithmetic operations on Blob - I converted it to hex, made the arithmetic, converted it to blob again, and then I tried to save it inside the versionData.
But it saves only the first doc and not both.
I tried to do the following : (the hardcoded Ids is just for testing)
List<ContentVersion> cdlList = [SELECT Id,Title,ContentDocumentId,FileType,VersionData FROM ContentVersion WHERE ContentDocumentId='0691l000001DoBTAA0' OR ContentDocumentId='0691l000001DoE3AAK'];
List<ContentVersion> cvList = new List<ContentVersion>();
String combinedDataAsHex = EncodingUtil.convertToHex(cdlList[0].VersionData) + EncodingUtil.convertToHex(cdlList[1].VersionData);
ContentVersion testContentInsert = new ContentVersion();
testContentInsert.Title = 'Test';
testContentInsert.VersionData = EncodingUtil.convertFromHex(combinedDataAsHex);
testContentInsert.PathOnClient = '/' + cdlList[0].title + '.docx' ;
cvList.add(testContentInsert);
insert cvList;
Is there something I missed? Another way to do it?
Thanks.