Recent

Author Topic: Print method don't work  (Read 4355 times)

rretamar

  • New Member
  • *
  • Posts: 39
Print method don't work
« on: August 17, 2016, 12:43:21 am »
Hi.
I write a short-sample demo with TRichmemo componen using Lazarus Codetyphon 4.8 t. The code for print RICHMEMO is simple:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. Var
  3.   print_parameters: TPrintParams;
  4. begin
  5.   If Not PrinterSetupDialog1.Execute Then Exit; // Optional: printer selection
  6.  
  7.   print_parameters.JobTitle := 'Print test';
  8.   print_parameters.Margins.Top := 30;    
  9.   print_parameters.Margins.Bottom := 30;
  10.   print_parameters.Margins.Left := 30;
  11.   print_parameters.Margins.Right := 30;
  12.   RichMemo1.Print( print_parameters );  
  13. End;    

To test print, after paste or write rich text (rtf text from LibreOffice) suite into richmemo edit region.

The problem: the result print page is empty (in laser printer or into a pdfcreador pdf printer).

Any idea ???  :o
« Last Edit: August 17, 2016, 12:51:26 am by rretamar »

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Print method don't work
« Reply #1 on: August 17, 2016, 10:18:27 am »
I write a short-sample demo with TRichmemo componen using Lazarus Codetyphon 4.8 t.
Works fine here.

First of all, there is no such thing as Lazarus Codetyphon. There is Lazarus and there is Codetyphon (based on Lazarus). This forum is for Lazarus.

Second... you don't initialize your print_parameters. For me your examples printed 4 pages until I initialized the print_parameter with #0s before setting the options.

Code: Pascal  [Select][+][-]
  1. Fillchar(print_parameters, SizeOf(print_parameters), #0);

rretamar

  • New Member
  • *
  • Posts: 39
Re: Print method don't work
« Reply #2 on: August 17, 2016, 10:39:37 pm »
Solved !!!

I add line to blank print-parameters record using FILLCHAR....and works fine !!!  :)

Thanks !

 

TinyPortal © 2005-2018