Number of copy

Leo BidiLeo Bidi Montevideo, Uruguay
edited 11:01AM in FastReport VCL 5
Hi, this is a very basic question but cant find the answer [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I have a report that print 2 copies and want to print only some text in the first copy. I've tried on the beforeprint of that text with variables like <CopyName> , <copy#> , etc etc, but none of them works. What it's the name of the variable that contains the actual copy printing ???? Thanksss[/img]

Comments

  • gpigpi
    edited 11:01AM
    - put a memo object with [CopyName#] text inside. It will show a copy name;

    - go "Code" tab and write a simple script that will give names to each copy. You can also do this in Delphi code;
    begin
      frxGlobalVariables['CopyName0'] := '';             // copy viewed in the preview
      frxGlobalVariables['CopyName1'] := 'First copy';   // 1st printed/exported copy
      frxGlobalVariables['CopyName2'] := 'Second copy';  // 2nd printed copy
      frxGlobalVariables['CopyName3'] := 'Third copy';   // 3rd printed copy
    end.
    

    - print a report.
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 11:01AM
    Hi gpi, thanks for your answer..

    Still I can't manage to work as I want.

    I did what you've mentioned , this is my code in the report's code page.
    begin
       frxGlobalVariables['CopyName1'] := '1';
       frxGlobalVariables['CopyName2'] := '2';
    end.
    
    and in my delphi code it says
        Rep_Ticket.PrintOptions.Copies  := 2;
        Rep_Ticket.PrepareReport();
        Rep_Ticket.Print;
    
    but still in the two copies of my report the memo with copyname# text , prints '1'.

    As I've mentioned before, how can I check what copy is printing , so I can disable another memo object to print in the second copy.

    Many thanks for you invaluable help.

    Regards

  • gpigpi
    edited 11:01AM
    Attach your report template (fr3)
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 11:01AM
    Thanks gpi.
  • gpigpi
    edited 11:01AM
    wrote:
    As I've mentioned before, how can I check what copy is printing , so I can disable another memo object to print in the second copy.
    Try to use TfrxReport.OnPrintPage event
    wrote:
    but still in the two copies of my report the memo with copyname# text , prints '1'.
    Set Collate option to True
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 11:01AM
    Thanks again gpi , but still cant do it right, sorry.

    I did as you said but still cant find out which numer of copy is printing.

    In the report beforeprint event I have
    if MemoCopy.Text = '1' then MemoText.visible := False;
    

    MemoCopy is the memo object with [CopyName#] text inside.

    What I need is that if printing the first copy then Memotext its invisible.

    Thanks and sorry for my inexperience.

    Regards

  • gpigpi
    edited 11:01AM
    CopyName# variable is macro variable. It available in the prepared report only, you can't to use it during preparing of report. Use TfrxReport.OnPrintPage event
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 11:01AM
    Please can you tell me how to use that macro on that event ?? How can I find out witch copy is ??

    Many many thanks..

  • gpigpi
    edited July 2017
    wrote:
    Please can you tell me how to use that macro on that event ?
    You can't.
    wrote:
    How can I find out witch copy is ?
    Look at TfrxReport.OnPrintPage header
    procedure TForm1.frxReport1PrintPage(Page: TfrxReportPage; CopyNo: Integer);
    begin

    end;
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 11:01AM
    Thanks gpi for you help but still cant manage to do it.

    this is my code when printing
    Rep_Ticket.PrintOptions.Copies  := 2;
    Rep_Ticket.PrintOptions.Collate := True;
    Rep_Ticket.PrepareReport();
    Rep_Ticket.Print;
    
    and on the Report.OnPrintPage event I have
    Rep_Ticket.Variables['CopyNumber'] := IntToStr(CopyNo)
    
    and then on the report I have a memo object that contains the same variable 'CopyNumber' but when printing , in both pages it prints "2", it seems that always prints the second copy.

    I cant make the report prints 1 on the first copy and 2 in the second... :angry:" border="0" alt="mad.gif" />" alt=">" />[img]style_emoticons/<#EMO_DIR#>/mad.gif" style="vertical-align:middle" emoid=":angry:" border="0" alt="mad.gif" /> Can you tell me please what I'm doing wrong ?? Many thanks..[/img]
  • gpigpi
    edited 11:01AM
    Demo project in the attach
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 11:01AM
    Thanks gpi for the code.

    I've done earlier what you've mentioned in the code and the memo with the variable global prints perfect.

    My problem is how can I check the content of that global variable because I need to print ONLY some objects in the first copy but not in the second one.

    Just need that.

    Best regards


  • gpigpi
    edited 11:01AM
    Check CopyNo Delphi variable in the TfrxReport.OnPrintPage event, pass through all Page's (prepared page) objects and change visibility for these objects
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 11:01AM
    Thanks so much gpi.

    I've did this way and works perfect. I put my solution here for any person who may need it.
    procedure Rep_TicketPrintPage(Page: TfrxReportPage; CopyNo: Integer);
    var
      Memo : TfrxMemoView;
      RichView : TfrxRichView;
      nPage : TfrxPageFooter;
    begin
        inherited;
        Memo := TfrxMemoView( Page.FindObject('Memo24') );
        if Memo <> nil then
        begin
            if CopyNo = 1 then
                Memo.Printable := False
            else
                Memo.Printable := True;
        end;
        RichView := TfrxRichView( Page.FindObject('Rich1') );
        nPage    := TfrxPageFooter( Page.FindObject('PageFooter') );
        if ( RichView <> nil ) and ( lImprimePie ) then
        begin
            if CopyNo = 1 then
            begin
                RichView.Printable := True;
                nPage.Height       := 4.07;
            end
            else
            begin
                RichView.Printable := False;
                nPage.Height       := 1.00;
            end;
        end;
    end;
    
    Best regards

Leave a Comment