Page 1 of 1

Save Header in RTF

Posted: Tue Mar 03, 2009 10:07 am
by janavida
Hello,
I will save Header in RTF. For that I have activated the rtfoption rvrtfSaveHeaderFooter. But now I get an error 'Error at reading from rve.RTFOptions'

Posted: Tue Mar 03, 2009 11:34 am
by Sergey Tkachenko
I think you have 2 versions of TRichView files in different directories.
A newer version is installed in Dephi, but applications are still compiled with older version.
Find files of older version and delete them.

Posted: Tue Mar 03, 2009 2:28 pm
by janavida
Thank you!! That was it.
Now I'm trying to save header like this:

Code: Select all

  rveHeader.clear;
  rveHeader.InsertText('test');
  rveHeader.Format;

  rve.Clear;
  rve.RTFReadProperties.SetHeader(rveHeader.RVData);
  rve.FORMAT;
  rve.SaveRTF(rtfcomplete,FALSE);
But there will be no Header in the RTF document.. I can't find a solution somewhere in the forum.

Posted: Tue Mar 03, 2009 4:24 pm
by Sergey Tkachenko
Your code must save RTF with header if rvrtfSaveHeaderFooter is included in rve.RTFOptions.
If not, please send me a project reproducing this problem.

Posted: Wed Mar 04, 2009 7:54 am
by janavida
Thanks for your fast answers!!
Now I tried this without any code around it - then it works!
But it doesn't solved my problem.
I am saving the RTF. When I open it with word I can see the Header. Then I open it again with RichViewPDF

Code: Select all

RichViewPDF.TopMargin:=0;
RichViewPDF.LeftMargin:=0;
RichViewPDF.RichView.LoadRTF('c:\Programme\idssdb\temp\text.rtf';
and then save it to PDF

Code: Select all

RichViewPDF.SaveToPDFFile(datverzeichnis + 'SDB.pdf'); 

I have to set TopMargin and LeftMargin to 0 because I have borders around text. When I don't set it to 0 the borders are on top and the text on the right place.
There is no Header in PDF.

But now I don't know what to do to have a topmargin..
My idea was, to save an empty Header. But it didn't work.
Do you have an idea?

Posted: Wed Mar 04, 2009 12:15 pm
by Sergey Tkachenko
First, what version of MS Word do you use? MS Word 2007 saves headers differently, and the current version of TRichView cannot read them yet.

Next, what is RichViewPDF?

Posted: Wed Mar 04, 2009 1:04 pm
by janavida
I'm using Word2003.
RichViewPDF is the RolePDF from Roledata. I think its a problem of this program. So im looking for another solution.

Posted: Wed Mar 04, 2009 4:54 pm
by Sergey Tkachenko
RichViewPDF does not support headers and footers.
You can look in its source code, in TRichViewPDF.SaveToPDFFile.
It outputs only content of RichView property (by copying it via RTF stream in TRVReportHelper component).

I suggest instead of using this component, use TRolePDF component directly. It provides Canvas where you can draw what you want, including header and footer. You can create your procedure basing on TRichViewPDF.SaveToPDFFile and code from http://www.trichview.com/forums/viewtopic.php?t=2511

If you need help, I'll try to create an example.

Posted: Thu Mar 12, 2009 8:28 am
by janavida
It would be nice if you could give me a small example. Thanks! :-)