Convert richview files to rtf
Convert richview files to rtf
Hi,
I'm a Delphi developer but not a user of RichView components. I came across a database of files with TRichView's format. I have to convert these files to rtf (more than 10.000 files).
Any recommendations, command line tools etc to convert them?
Best regards
Bora Aydemir
I'm a Delphi developer but not a user of RichView components. I came across a database of files with TRichView's format. I have to convert these files to rtf (more than 10.000 files).
Any recommendations, command line tools etc to convert them?
Best regards
Bora Aydemir
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Do you want to store in the same database?
It's simple: TDBRichViewEdit autodetects the field format, and saves to format specified in FieldFormat property.
So, if you want to convert all the fields, you can use the code below.
Let:
Table is a data set containing documents.
DBRVE is TDBRichViewEdit linked to this table.
It's simple: TDBRichViewEdit autodetects the field format, and saves to format specified in FieldFormat property.
So, if you want to convert all the fields, you can use the code below.
Let:
Table is a data set containing documents.
DBRVE is TDBRichViewEdit linked to this table.
Code: Select all
DBRVE.AutoDeleteUnusedStyles := True;
DBRVE.FieldFormat := rvdbRTF;
Table.First;
while not Table.EOF do
begin
Table.Edit;
DBRVE.Change;
Table.Post;
Table.Next;
end;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Convert richview files to rtf
Sergey,
I'm using TRichView with Delphi 2007 and saving data directly in firebird 2.5 blobs. I don't use dbware components. Now, I need to convert all blobs to the Seatle version, with unicode support. There is any easy way?
Best regards,
Edward
I'm using TRichView with Delphi 2007 and saving data directly in firebird 2.5 blobs. I don't use dbware components. Now, I need to convert all blobs to the Seatle version, with unicode support. There is any easy way?
Best regards,
Edward
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Convert richview files to rtf
I do not think that conversion is needed, if you continue using TRichView.
The component can read document saved by older versions
What's the format of documents?
1) If RTF
There is no need to do something with existing RTF documents.
They will be loaded in Unicode, if TRichView.RTFReadProperties.UnicodeMode = rvruOnlyUnicode.
There is no need to change format of the field containing RTF to Unicode: all what you get is increased data size (twice). RTF is able to contain Unicode characters even when stored in ANSI field.
2) If RVF
RVF should be stored in a binary field, allowing any type of data. It must not be stored in Unicode memo field.
RVF documents are loaded as they are, so if they contained non-Unicode text, it will be non-Unicode after loading.
So, after loading, you should convert text to Unicode, see ConvertToUnicode from http://trichview.com/forums/viewtopic.p ... 569#p11569
The component can read document saved by older versions
What's the format of documents?
1) If RTF
There is no need to do something with existing RTF documents.
They will be loaded in Unicode, if TRichView.RTFReadProperties.UnicodeMode = rvruOnlyUnicode.
There is no need to change format of the field containing RTF to Unicode: all what you get is increased data size (twice). RTF is able to contain Unicode characters even when stored in ANSI field.
2) If RVF
RVF should be stored in a binary field, allowing any type of data. It must not be stored in Unicode memo field.
RVF documents are loaded as they are, so if they contained non-Unicode text, it will be non-Unicode after loading.
So, after loading, you should convert text to Unicode, see ConvertToUnicode from http://trichview.com/forums/viewtopic.p ... 569#p11569
Re: Convert richview files to rtf
Hi Sergey,
The RVF content stored in blob field is loaded correctly but I use fields to fill data in document, in runtime. At this moment, the content of all fields are being showed in the editor correctly, but not in the print preview. If I edit the document, the characters are transformed to "chinese characters".
I did see when the editor inserts the line feed at any position of this text inserted by tag, it is changed by chinese characters too.
Do you have any idea?
Best regards
Edward
The RVF content stored in blob field is loaded correctly but I use fields to fill data in document, in runtime. At this moment, the content of all fields are being showed in the editor correctly, but not in the print preview. If I edit the document, the characters are transformed to "chinese characters".
I did see when the editor inserts the line feed at any position of this text inserted by tag, it is changed by chinese characters too.
Do you have any idea?
Best regards
Edward
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Convert richview files to rtf
How do you insert these fields?
Re: Convert richview files to rtf
Hi, bellow is the code:
Code: Select all
procedure TfrEditor.FillFields(RVData: TCustomRVData);
function ConvertStringToItemText(const Text: String;
UnicodeItem: Boolean; CodePage: Cardinal): TRVRawByteString;
begin
if UnicodeItem then
Result:=RVU_StringToRawByteString(Text,True,CodePage)
Result := RVU_AnsiToUnicode(CodePage, Text)
else
Result := TRVAnsiString(Text);
end;
var
i, j, r, c: Integer;
table: TRVTableItemInfo;
FieldName{, FieldValue}: string;
ParaNo: Integer;
BR, ContinuePara, Unicode: Boolean;
item: TRVTextItemInfo;
CodePage: TRVCodePage;
sr: TRVRawByteString;
s,Value: String;
StyleNo: Integer;
begin
for i := 0 to ComponentCount - 1 do
if (Components[i] is TdxBarButton) and (StrLeft(TdxBarButton(Components[i]).Name,8)='btF10Var') then
TdxBarButton(Components[i]).Description:=TdxBarButton(Components[i]).Caption;
for i := 0 to RVData.ItemCount - 1 do begin
if RVData.GetItemStyle(i) = rvsTable then begin
table := TRVTableItemInfo(RVData.GetItem(i));
for r := 0 to table.Rows.Count - 1 do
for c := 0 to table.Rows[r].Count - 1 do
if table.Cells[r, c] <> nil then
FillFields(table.Cells[r, c].GetRVData);
table.Changed;
end else if RVData.GetItemStyle(i) >= 0 then begin
FieldName := RVData.GetItemTag(i);
if AllTrim(FieldName)<>'' then begin
LoadFields(FieldName);
ParaNo := RVData.GetItemPara(i);
BR := RVData.GetItem(i).BR;
StyleNo:=RVData.GetItem(i).StyleNo;
ContinuePara := RVData.GetItem(i).SameAsPrev;
StyleNo:=RVData.GetItem(i).StyleNo;
Value := GetFieldItem(FieldName).Description;
RVData.DeleteItems(i,1);
item := RichViewTextItemClass.Create(RVData);
s := Value;
item.ParaNo := ParaNo;
item.StyleNo := StyleNo;
CodePage := RVData.GetItemCodePage2(item);
item.SameAsPrev := ContinuePara;
item.BR := BR;
sr := ConvertStringToItemText(s, True, CodePage);
item.Inserting(RVData, sr, False);
RVData.Items.InsertObject(i, sr, item);
item.Inserted(RVData,i);
end;
end;
end;
end;
Last edited by edward on Mon Jul 24, 2017 7:00 pm, edited 2 times in total.
Re: Convert richview files to rtf
Code: Select all
// basicly to work with Unicode
sr := ConvertStringToItemText(s, True, CodePage);
item.Inserting(RVData, sr, False);
RVData.Items.InsertObject(i, sr, item);
item.Inserted(RVData,i);
function ConvertStringToItemText(const Text: String;
UnicodeItem: Boolean; CodePage: Cardinal): TRVRawByteString;
begin
if UnicodeItem then
Result:=RVU_StringToRawByteString(Text,True,CodePage)
else
Result := TRVAnsiString(Text);
end;
Last edited by edward on Mon Jul 24, 2017 7:01 pm, edited 1 time in total.
Re: Convert richview files to rtf
If the entire content of the field fits in to the screen, without a line break, works fine. When the field cause a line break, ou either, the content is edited, the chinese character apears in the text. The format in database is RVF. The blob field is saved in a temp file and the file is loaded to the richedit. All its process is working fine. Only my "macro" fields, is wrong.
Best regards
Edward
Best regards
Edward
Re: Convert richview files to rtf
Firebird 3.0
Character Set WIN1252
Character Set WIN1252
Re: Convert richview files to rtf
Sergey, the problem was solved:
Code: Select all
function ConvertStringToItemText_(const Text: String; UnicodeItem: Boolean; CodePage: Cardinal): TRVRawByteString;
begin
if UnicodeItem then
Result := RVU_GetRawUnicode(Text)
else
Result := TRVAnsiString(Text);
end;
function ConvertStringToItemText(const Text: String; RVData: TCustomRVData; StyleNo: Integer): TRVRawByteString;
begin
Result := ConvertStringToItemText_(Text, RVData.GetRVStyle.TextStyles[StyleNo].Unicode, RVData.GetStyleCodePage(StyleNo));
end;
sr := ConvertStringToItemText(s, RVData, StyleNo);
if Editor.Style.TextStyles[item.StyleNo].Unicode then
item.ItemOptions := item.ItemOptions+[rvioUnicode];
item.Inserting(RVData, sr, False);
RVData.Items.InsertObject(i, sr, item);
item.Inserted(RVData,i);