Page 2 of 2

Posted: Thu Apr 17, 2008 8:30 am
by Sergey Tkachenko
Not yet, but this will be the next feature to implement.

Posted: Wed Jun 11, 2008 6:31 pm
by Sergey Tkachenko
Finally, TRichView can save formatted headers and footers in RTF. Update is uploaded for registered users.

different header/sections in version 11?

Posted: Mon Jul 06, 2009 1:04 pm
by josemaria
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. :shock:

Posted: Mon Jul 06, 2009 6:09 pm
by Sergey Tkachenko
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(...);

Posted: Tue Jul 07, 2009 12:28 pm
by josemaria
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.
:?

Posted: Tue Jul 07, 2009 2:57 pm
by Sergey Tkachenko
I am sorry, saving headers and footers for sections is not supported.

Posted: Wed Jul 08, 2009 12:04 pm
by josemaria
Sergey Tkachenko wrote:Finally, TRichView can save formatted headers and footers in RTF. Update is uploaded for registered users.
A. Does include it page numbers?
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.

Posted: Wed Jul 08, 2009 3:56 pm
by Sergey Tkachenko
A. If you want to include page number in RTF, you need to insert the following RTF code in the document (header or footer):
{\field{\*\fldinst PAGE}{\fldrslt 1}}
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.

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.

Posted: Thu Jul 09, 2009 6:39 pm
by josemaria
Sergey Tkachenko wrote: B. Of course. Instead of inserting from TFileStream, create TMemoryStream, save in it, then insert.
From the CreateRTFWithSections example procedure:

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;
I changed for:

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;
It makes an empty rv file.
Please, help me! :(
Thank you

Posted: Fri Jul 10, 2009 7:24 am
by Sergey Tkachenko
Add:

Code: Select all

Stream.Position := 0;
after calling SaveRVFToStream.