Replace Label with Text
Posted: Tue Sep 04, 2012 7:07 pm
Hello,
I am trying to setup a mail merge using the Label examples. However, in the final document I need to be able to have merged fields wrap. I've looked at the different demos and for creating the merge templates I like how the labels work the best.
However I am having trouble deleting the label and replacing it with the text during the merge. Here is what I am trying but I keep ending up with junk in the final document.
procedure TRVViewer.UpdateRVItem(RVData: TCustomRVData; ItemNo: integer; NewData: string);
var
item: TRVTextItemInfo;
x: TRVRawByteString;
begin
case RVData.GetItemStyle(ItemNo) of
rvsLabel:
begin
// Works OK but will not support the NewData being word wrapped.
//TRVLabelItemInfo(RVData.GetItem(ItemNo)).Text := NewData;
item := TRVTextItemInfo.Create(RVData);
item.StyleNo := TRVLabelItemInfo(RVData.GetItem(ItemNo)).TextStyleNo;
item.ParaNo := TRVLabelItemInfo(RVData.GetItem(ItemNo)).ParaNo;
item.ItemOptions := RVData.GetItem(ItemNo).ItemOptions;
RVData.DeleteItems(ItemNo, 1);
// What is the string needed for here? It can't be a string it needs to be TRVRawByteString because it
// is a var paramater.
item.Inserting(RVData, x, False);
RVData.Items.InsertObject(ItemNo, NewData, item);
item.Inserted(RVData, ItemNo);
end;
I am trying to setup a mail merge using the Label examples. However, in the final document I need to be able to have merged fields wrap. I've looked at the different demos and for creating the merge templates I like how the labels work the best.
However I am having trouble deleting the label and replacing it with the text during the merge. Here is what I am trying but I keep ending up with junk in the final document.
procedure TRVViewer.UpdateRVItem(RVData: TCustomRVData; ItemNo: integer; NewData: string);
var
item: TRVTextItemInfo;
x: TRVRawByteString;
begin
case RVData.GetItemStyle(ItemNo) of
rvsLabel:
begin
// Works OK but will not support the NewData being word wrapped.
//TRVLabelItemInfo(RVData.GetItem(ItemNo)).Text := NewData;
item := TRVTextItemInfo.Create(RVData);
item.StyleNo := TRVLabelItemInfo(RVData.GetItem(ItemNo)).TextStyleNo;
item.ParaNo := TRVLabelItemInfo(RVData.GetItem(ItemNo)).ParaNo;
item.ItemOptions := RVData.GetItem(ItemNo).ItemOptions;
RVData.DeleteItems(ItemNo, 1);
// What is the string needed for here? It can't be a string it needs to be TRVRawByteString because it
// is a var paramater.
item.Inserting(RVData, x, False);
RVData.Items.InsertObject(ItemNo, NewData, item);
item.Inserted(RVData, ItemNo);
end;