Solved

How to print a trichEdit with quickReport

Posted on 1998-07-15
2
859 Views
Last Modified: 2013-11-22
Hi,
I want to print the containt of a trichtext in a tqrrichEdit.
The only way I found to make it work is the following :

     beforeEdit.Lines.SaveToFile('Before.rtf');
     backEdit.Lines.SaveToFile('Behind.rtf');
     form2.QRbackEdit.Lines.LoadFromFile('Behind.rtf');
     form2.QRbeforeEdit.Lines.LoadFromFile('Before.rtf');
     form2.jacket.Print;
     
The problem is that the text seems to be stretched even with true type
fonts.

I know that I have to link the parentRichEdit property to my trichedit. But if
I do so, the text prints very small, like when you ask a trichedit to print.

At the printpreview the text looks like it should, but I know it's normal :
96 dpi on the screen and 600dpi on the printer.

So, how do I properly print the contain of a trichedit with the help of a
tqrrichedit. What's the right and working method ?
Thanks for your help.
0
Comment
Question by:jeurk
2 Comments
 
LVL 1

Expert Comment

by:Greedy
ID: 1357940
This is how I do it...This is for if the RTF data was stored in a database but if you have it stored in another string then create the stream off that instead.  The only other thing I do is set AutoStretch to True and set the Height to 20...but that's just normal stuff.

var
  MyStream : TStringStream;

begin
  MyStream := TStringStream.Create(Table1.FieldByName('YourFieldHere').AsString + #13 + #10);
  QRRichText1.Lines.Clear;
  QRRichText1.Lines.LoadFromStream(MyStream);
  MyStream.Free;
end;

0
 
LVL 10

Accepted Solution

by:
Jacco earned 50 total points
ID: 1357941
I know this problem. It is a bug in QRReport... and has not been resolved in the updates yet...

I only have a work around that works for me.

The band on which you have the TQRRichEdit should have a BeforePrint method assigned and look like this:

procedure TrepBill_01.SummaryBand1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
var
  sLine : String;
  sKey  : String;
  iCount : Integer;
  iPos : Integer;
begin
  if (Abs(TotalToBePayed)<0.01) or
     (FPayment<>'DEBITEUR') or
     (FBillType in [btPFGuest,btPFCompany,btPFAlternative]) then begin
    reMemo.DefAttributes.Size:=9;
    reMemo.DefAttributes.Name:='Arial';
    reMemo.WordWrap:=False;
    if (sLanguage='EN') or (sLanguage='FR') or (sLanguage='DU') then
      reMemo.Lines.LoadFromFile(HotConDir + '\Editor\bott_fact_cont_' + sLanguage + '.rtf')
    else
      reMemo.Lines.LoadFromFile(HotConDir + '\Editor\bott_fact_cont.rtf');
  end else begin
    reMemo.DefAttributes.Size:=9;
    reMemo.DefAttributes.Name:='Arial';
    reMemo.WordWrap:=False;
    if (sLanguage='EN') or (sLanguage='FR') or (sLanguage='DU') then
      reMemo.Lines.LoadFromFile(HotConDir + '\Editor\bott_fact_deb_' + sLanguage + '.rtf')
    else
      reMemo.Lines.LoadFromFile(HotConDir + '\Editor\bott_fact_deb.rtf');
  end;
  // Recalculate Summary band size
  SummaryBand1.Height := 100 + (1 + reMemo.Lines.Count)*17;
  qrrtMemo.Height     := SummaryBand1.Height - 100;
  reMemo.WordWrap:=True;
  qrrtMemo.ParentRichEdit:=reMemo;
  qrResFol.Close;
end;

Note: If you use the preview of QRReport the memo still will not show up properly! But on the printer it will.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now