Export Header/Footer to RTF
-
- Site Admin
- Posts: 17534
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17534
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
different header/sections in version 11?
Hi,
Please, do you have an example for different headers?
I have a complex project that needs multiples headers/sections and I have waiting for a solution to this problem in RTF generation.
I am waiting more than a year for it. Please, tell me that it's solved, and an example.
Please, do you have an example for different headers?
I have a complex project that needs multiples headers/sections and I have waiting for a solution to this problem in RTF generation.
I am waiting more than a year for it. Please, tell me that it's solved, and an example.
Last edited by josemaria on Wed Jul 08, 2009 12:10 pm, edited 1 time in total.
-
- Site Admin
- Posts: 17534
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If you have header in RichViewH, footer in RichViewF, then saving RTF with header:
Code: Select all
RichView1.Options := RichView1.Options+[rvrtfSaveHeaderFooter];
RichView1.RTFReadProperties.SetHeader(RichViewH.RVData);
RichView1.RTFReadProperties.SetFooter(RichViewF.RVData);
RichView1.SaveRTF(...);
Thanks.
I will tray it, but, also, I need multiple sections with different headers.
Mi application generates first one RichViewEdit text from a lot of data, and need to export it to RTF and/or DOC file, with multiple sections, any with different header and different page numbers, at less in the RTF file, that is the final task of my application. If no, the RTF must to be processed one and another time with one word processor.
I will tray it, but, also, I need multiple sections with different headers.
Mi application generates first one RichViewEdit text from a lot of data, and need to export it to RTF and/or DOC file, with multiple sections, any with different header and different page numbers, at less in the RTF file, that is the final task of my application. If no, the RTF must to be processed one and another time with one word processor.
-
- Site Admin
- Posts: 17534
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
A. Does include it page numbers?Sergey Tkachenko wrote:Finally, TRichView can save formatted headers and footers in RTF. Update is uploaded for registered users.
It is basic for headers/footers.
B. I have tried the CreateRTFWithSections example. It is possible generation of RTF with sections without RTF files, directly with richview editors?.
C. It is possible merging of RTF files in one file so that it include the different headers from the separated RTF files?
D. I think actually we have two different ways:
1. Headers/footers via RV1.RTFReadProperties.SetHeader(RV1H.RVData) (formated, but no page numbers?)
2. Headers/footers via OnSaveRTFExtra and RTFCode (page numbers, but limited and complicated format options)
It is possible that the two ways joint in one way?
Anything similar happens with doc properties
I think this questions are the more complicated themes about RichView
Do you can make a document that resume and clarifies it?
Thank you for your fast replays.
-
- Site Admin
- Posts: 17534
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
A. If you want to include page number in RTF, you need to insert the following RTF code in the document (header or footer):
B. Of course. Instead of inserting from TFileStream, create TMemoryStream, save in it, then insert.
C. Merging RTF file is not easy. RTF file has tables of colors, fonts, lists, etc. (one table of each type in a file). You cannot just take a fragment of RTF code from one file and insert in another, because it refers to different tables.
There are two ways how to insert RTF code in document, see http://www.trichview.com/forums/viewtopic.php?t=2742 . This example inserts different RTF code, but the idea is the same.{\field{\*\fldinst PAGE}{\fldrslt 1}}
B. Of course. Instead of inserting from TFileStream, create TMemoryStream, save in it, then insert.
C. Merging RTF file is not easy. RTF file has tables of colors, fonts, lists, etc. (one table of each type in a file). You cannot just take a fragment of RTF code from one file and insert in another, because it refers to different tables.
From the CreateRTFWithSections example procedure:Sergey Tkachenko wrote: B. Of course. Instead of inserting from TFileStream, create TMemoryStream, save in it, then insert.
Code: Select all
procedure CreateRTFWithSections(RVFFiles: array of String;
const RTFFile: String; rv: TCustomRichView);
var i: Integer;
Stream: TFileStream;
...
for i := Low(RVFFiles) to High(RVFFiles) do
try
Stream := TFileStream.Create(RVFFiles[i], fmOpenRead);
try
rv.InsertRVFFromStream(Stream, rv.ItemCount);
if i<>High(RVFFiles) then
rv.AddNL('\sect\pgnrestart', 1, 0);
finally
Stream.Free;
end;
except
rv.AddNL('Error loading file', 0, 0);
end;
Code: Select all
procedure CreateRTFWithSections2(RVFFiles: array of TRichViewEdit;
const RTFFile: String; rv: TCustomRichView);
var i: Integer;
MStream: TMemoryStream;
...
for i := Low(RVFFiles) to High(RVFFiles) do
try
MStream := TMemoryStream.Create;
RVFFiles[i].SaveRVFToStream(MStream, False);
try
rv.InsertRVFFromStream(MStream, rv.ItemCount);
if i<>High(RVFFiles) then
rv.AddNL('\sect\pgnrestart', 1, 0);
finally
MStream.Free;
end;
except
rv.AddNL('Error loading file', 0, 0);
end;
Please, help me!
Thank you
-
- Site Admin
- Posts: 17534
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Add:
after calling SaveRVFToStream.
Code: Select all
Stream.Position := 0;