Página 1 de 1

Select printer

Publicado: Mié Jun 09, 2021 1:18 am
por nbatocanin
Hi to all :)

Is this forum still active?

I need to select a specific printer that is not Windows default for one specific report. Is there a way to do that?

Regards, Nenad

Re: Select printer

Publicado: Jue Jun 10, 2021 3:19 am
por hgarciaj
First you have to identify tthe correct name for the printer you need, (check tprinter class) then you have to send it to your fr3 with this:

::oFastReport:oPrintOptions:cPrinter:="your printer"
Regards

Re: Select printer

Publicado: Jue Jun 10, 2021 11:23 pm
por nbatocanin
hgarciaj escribió: Jue Jun 10, 2021 3:19 am First you have to identify tthe correct name for the printer you need, (check tprinter class) then you have to send it to your fr3 with this:

::oFastReport:oPrintOptions:cPrinter:="your printer"
Regards
Thank you!

NB

Re: Select printer

Publicado: Mié Jun 16, 2021 1:56 am
por nbatocanin
hgarciaj escribió: Jue Jun 10, 2021 3:19 am ::oFastReport:oPrintOptions:cPrinter:="your printer"
Unfortunately, this is not work (undefined variable cPrinter). I try with

oFr:SetProperty ("PrintOptions", "cPrinter", "My Printer")

But this has no effect either :(

Re: Select printer

Publicado: Mié Jun 16, 2021 10:05 am
por ignacio
Imagen 180.png
Imagen 180.png (7.4 KiB) Visto 2483 veces

Re: Select printer

Publicado: Mié Jun 16, 2021 3:50 pm
por nbatocanin
Ah, I realized what the problem was! I use FrReportManager as base class instead TFastReport. Unfortunately, it's a big problem for me to change this, is there a way to set up a printer from this class? I try

::Super:oPrintOptions:cPrinter

but :oPrintOptions is NIL??

Re: Select printer

Publicado: Mié Jun 16, 2021 5:37 pm
por ignacio
Hi,
CLASS frReportManager FROM TFastReport
::Super NOT NEEDED.

Regards,

Re: Select printer

Publicado: Jue Jun 17, 2021 2:31 am
por nbatocanin
Ignacio, thank you very much!

The problem is of course in my code. I did that part a long time ago (Spirin version), so I forgot how it works. Basically, all my reports look like this:

oFr := FRInit()
...
...
oFr:activate()

FRInit() doing this:

Código: Seleccionar todo

oFr := FrReportManager():New()
oFr:SetProperty("DESIGNER", "DefaultFont.Charset", 238)
oFr:SetFormatSettings(frxThousandSeparator, ".")
...
:activate() is this method:

Código: Seleccionar todo

::Create() 
::LoadFromFile (::cScript) 
::Init()
::ShowReport()
The problem occurs because variable oPrintOptions = NIL before the ::create() activation! As I put oFr:oPrintOptions:cPrinter := "..." before ::activate(), I got an error.