FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH 13:09 Default Printer
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: FWH 13:09 Default Printer
Posted: Fri Nov 15, 2013 07:23 PM
A sample code :
Code (fw): Select all Collapse
Function Main()
   local oPrn
   PRINT oPrn TO "miEpson" 
            PAGE
         oPrn:Say( 4, 4, "hola mundo" )
      ENDPAGE
   ENDPRINT

return nil

This code is ok . work print in Epson
Code (fw): Select all Collapse
unction Main()

   local oPrn

   PRINT oPrn TO "miEpson" 
      
  oPrn:SetPage(1)   // code added
     
      PAGE
         oPrn:Say( 4, 4, "hola mundo" )
      ENDPAGE
   ENDPRINT

return nil


The work print in Brother HL duplex ( default printer)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 07:25 AM

Oscar,

Please try this code:

MsgInfo( StrTran( GetProfString( "Devices" ), Chr( 0 ), Chr( 13 ) + Chr( 10 ) ) )

and post here your result

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 08:13 AM

Linares,

Result:

CutePDF Writer
Fax
PDF reDirect Pro v2
Argox OS-214tt PPLA
\OASYS4\Samsung SCX-4200 Series
Enviar para o OpenNote 2007

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 08:16 AM

Ok, so if you do:

PRINTER oPrn TO "Samsung"

that would be enough to select the Samsung printer

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 09:34 AM

If I do this, ::hDC returns zero and does not print.

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 10:22 AM
Oscar,

In Class TPrinter, function PrintBegin() we search for the printer based on the provided cModel name:

Code (fw): Select all Collapse
      if ( nScan := Ascan( aPrn, { | v | Upper( xModel ) == Upper( v ) } ) ) == 0
         nScan = Ascan( aPrn, { | v | Upper( xModel ) $ Upper( v ) } )
      endif


Please place a MsgInfo( nScan ) there to see what is going on there with your printer.

If you write To "Samsung", then: nScan = Ascan( aPrn, { | v | Upper( xModel ) $ Upper( v ) } ) should find it.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 03:05 PM
Results:
nScan = 6
cDevice = \\OASyS4\Samsung SCX-4200 Series,winspool,Ne04:

But printing out the PDF reDirect.

Do you have another idea?

Thanks
Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 07:35 PM
In Class TPrinter method New() then this code should be ok:

Code (fw): Select all Collapse
METHOD New( cDocument, lUser, lPreview, cModel, lModal, lSelection, cFile ) CLASS TPrinter

   local aOffset
   local cPrinter

   DEFAULT cDocument  := "FiveWin Report" ,;
       lUser := .f., lPreview := .f., lModal := .f., lSelection := .f.

   if lUser
      ::hDC := GetPrintDC( GetActiveWindow(), lSelection, PrnGetPagNums() )
      if ::hDC != 0
         cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif
   elseif cModel == nil
      ::hDC  := GetPrintDefault( GetActiveWindow() )
      if ::hDC != 0
         cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif
   else
      MsgInfo( cModel )  // here
      ::hDC = PrinterDcFromName( , cModel, )  
      MsgInfo( ::hDC )  // here
   endif


Please let me know if your code goes through there and what you get on the MsgInfos()
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: FWH 13:09 Default Printer
Posted: Sat Nov 16, 2013 09:33 PM
Oscar,

PRINTER oPrn TO "Samsung"

that would be enough to select the Samsung printer

If I do this, ::hDC returns zero and does not print.

Try using the exact printer name:

PRINTER oPrn TO "Samsung SCX-4200 Series"
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Sun Nov 17, 2013 09:53 AM
ORibeiro wrote:Results:
nScan = 6
cDevice = \\OASyS4\Samsung SCX-4200 Series,winspool,Ne04:

But printing out the PDF reDirect.

Do you have another idea?

Thanks


Please try this code:

Code (fw): Select all Collapse
PRINT oPrn TO "Samsung"
   PAGE
      oPrn:Say( 1, 1, "Hello" )
   ENDPAGE
ENDPRINT


that code should work fine. Please try it and let me know if it works fine, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Sun Nov 17, 2013 02:00 PM
I found! eureka

The problem is the command PrnGetName().

Please test with the following code within an application and run it twice: Perform close viewing and rerun without leaving the application.
Code (fw): Select all Collapse
PRINT oPrn NAME "TESTING"+" ("+ PrnGetName() +")" PREVIEW MODAL TO "Samsung"
   PAGE
      oPrn:Say( 1, 1, "Hello" )
   ENDPAGE
ENDPRINT


The first time he respects the printer sent in command TO "Samsung", the second time he returns to the Default Windows.

I use this command on all reports of my system to display the title of the selected printer viewer.

How can I solve this?
Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Sun Nov 17, 2013 02:31 PM
Please, test it:

Code (fw): Select all Collapse
GetPrintDC( GetActiveWindow() ) // -> Please, change de default printer in this point

MsgInfo( PrnGetName() ) // See the new printer selected above

PRINT oPrn NAME "TESTING"+" ("+ PrnGetName() +")" PREVIEW MODAL
   PAGE
      oPrn:Say( 1, 1, "Hello" )
   ENDPAGE
ENDPRINT

MsgInfo( PrnGetName() ) // See that printer go back to the default in windows
Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FWH 13:09 Default Printer
Posted: Sun Nov 17, 2013 04:01 PM

Please try to remove the PrinterEnd() call from TPrinter End() method. It seems to solve the problem. But I don't know if there will be side effects.

Antonio, what is it for?

EMG

Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Sun Nov 17, 2013 07:06 PM
Yes Enrico,
Thanks a lot.
This change solve my problem.

Linares, any side effects to remove this line?


Another existing problem: In the same example, change the printer on button of the viewer and see the result. The system will disconnect the printer.
Code (fw): Select all Collapse
GetPrintDC( GetActiveWindow() ) // -> Please, change de default printer in this point
MsgInfo( PrnGetName() ) // See the new printer selected above
PRINT oPrn NAME "TESTING"+" ("+ PrnGetName() +")" PREVIEW MODAL
   PAGE
      oPrn:Say( 1, 1, "Hello" )
   ENDPAGE

// CHANGE THE PRINTER in the button of the Report Preview

ENDPRINT
MsgInfo( PrnGetName() ) // See that printer go back to the default in windows
Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Mon Nov 18, 2013 10:52 AM

Oscar, Enrico,

Yes, PrinterEnd() is cleaning all the printer setup. We could remove it from METHOD End()

I am doing some tests, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com