Home Devices
New Blog Posts: Merging Reports - Part 1 and Part 2

Printing a specific page

edited April 2013 in Devices
Hi Nico, all fine?
I would like to print a specific page of a report.

Example:
ppReport1.PrintPage (3);


But, I see in TppReport source that the "PrintPage" method has
implementation.

How could I do?

Regarts,

Eliseu Corrona.

Comments

  • edited April 2013
    Hi Eliseu,

    Take a look at demo 124 of the main reports demo. It shows how to print
    specific pages using the BeforePrint Event and the ppTextToPageList routine.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2013
    Hi Nico, thanks for your help.
    I founded your tip in other topic a few minutes before your answer. I
    tested, but my intention is save with .pdf files this report.
    My objective is export to pdf file the first and last page by the report.
    In my tests don't work because this process is only runtime, without user
    choice.

    Example of my code:

    Procedure TForm1.BtnExportToPDFClick(Sender: TObject);
    Begin
    rptTeste.DeviceType := 'PDF';
    rptTeste.ShowPrintDialog := False;
    rptTeste.ShowCancelDialog := False;
    rptTeste.TextFileName := 'Pagina1.pdf';
    rptTeste.Print;
    End;

    Procedure TForm1.rptTesteBeforePrint(Sender: TObject);
    Begin
    If (rptTeste.PrinterDevice <> Nil) Then
    Begin
    rptTeste.PrinterDevice.PageSetting := psPageList;

    //Print only first page
    ppTextToPageList('1', rptTeste.PrinterDevice.PageList, True);
    End;

    End;

    Is there anything I can improve?

    Regarts,

    Eliseu Corrona.



  • edited April 2013
    Only complement the before message.
    Same setting page interval, export all pages of the report.

    Regarts,

    Eliseu Corrona.







    "Eliseu Corrona" escreveu na notícia da mensagem:515d840b$1@mail....

    Hi Nico, thanks for your help.
    I founded your tip in other topic a few minutes before your answer. I
    tested, but my intention is save with .pdf files this report.
    My objective is export to pdf file the first and last page by the report.
    In my tests don't work because this process is only runtime, without user
    choice.

    Example of my code:

    Procedure TForm1.BtnExportToPDFClick(Sender: TObject);
    Begin
    rptTeste.DeviceType := 'PDF';
    rptTeste.ShowPrintDialog := False;
    rptTeste.ShowCancelDialog := False;
    rptTeste.TextFileName := 'Pagina1.pdf';
    rptTeste.Print;
    End;

    Procedure TForm1.rptTesteBeforePrint(Sender: TObject);
    Begin
    If (rptTeste.PrinterDevice <> Nil) Then
    Begin
    rptTeste.PrinterDevice.PageSetting := psPageList;

    //Print only first page
    ppTextToPageList('1', rptTeste.PrinterDevice.PageList, True);
    End;

    End;

    Is there anything I can improve?

    Regarts,

    Eliseu Corrona.



  • edited April 2013
    The example is designed for the printer (hence Report.PrinterDevice).

    You will want to swap out for Report.FileDevice is you want this effect
    when exporting to file.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2013
    Thanks Nico.
    Work perfectly.
    Sorry about this doubt, I don't know there was this differentiation.
    I thought everything was based on PrintDevice because it was treated as an
    impression.

    Thank you again.

    Regarts,

    Eliseu Corrona.


This discussion has been closed.