I'm getting really big template binaries due orphaned objects that were manually deleted from the document and I'm wondering how can I find them and if possible how can I delete them completely from my template in order to shrink it, being careful to not delete actual/still used data.
My biggest template example that I have here is 11 mb size and has 2200 Document.RtfData.Count, but I assume there are bigger templates in some of my biggest customers.
When I call TWPRichText.Clear I'm able to erase everything, but I also lose the data that I want to keep (the visible data).
Thanks for the answer... I think I figure this out: I'm deleting all invisible RTFDataBlocks using this pseudo-code:
var
I,
itemsToDelete: TList<TWPRTFDataBlock>;
WPRTFDataBlock: TWPRTFDataBlock;
begin
for I := 0 to Document.RTFData.count - 1 do
begin
WPRTFDataBlock := wptDocument.RTFData[I];
if not WPRTFDataBlock.IsVisible then
begin
WPRTFDataBlock.Clear(True);
itemsToDelete.Add(WPRTFDataBlock);
end;
end;
for WPRTFDataBlock in itemsToDelete do
wptDocument.RTfData.DeleteRTFData(WPRTFDataBlock);
end;
The downsides:
1 - The Document needs to be loaded in desgin time;
2 - The Document needs to be focused (Document.SetFocus())
I had more than 2k useless objects loaded in the TWPRichText component!!