I need to read a MSWord document that has footnotes, copy the document on a second wprichtext control, and transform footnotes to text at the end of the document.
The reference to an old footnote has to be replaced by a hyperlink that links to the text of the old footnote (at the end of the document), and the old footnote number has to have another hyperlink that links to the reference of the footnote.
Footnotes in WPTools 6 are stored as elements in the RTFDataCollection.
This code will work on the same TWPRichText:
var txtobj : TWPTextObj;
RTFData : TWPRTFDataBlock;
begin
WPRichText1.CPPosition := 0;
repeat
txtobj := WPRichText1.TextCursor.ObjAtCP;
if (txtobj<>nil) and (txtobj.ObjType=wpobjFootnote) then
begin
RTFData := WPRichText1.RTFData.Find(wpIsFootnote, wpraOnAllPages, txtobj.Name);
if RTFData<>nil then
begin
WPRichText1.BodyText.AppendNewPar(false).SetText(RTFData.RtfText.AsANSIString('ANSI'));
WPRichText1.InputString(#127);
continue;
end;
end;
until not WPRichText1.CPmoveNext;
#2♥ 0
This category is archived. No new posts are possible.