FWH 13:09 Default Printer

Re: FWH 13:09 Default Printer

Postby mastintin » Fri Nov 15, 2013 7:23 pm

A sample code :
Code: Select all  Expand view

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: Select all  Expand view

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)
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: FWH 13:09 Default Printer

Postby Antonio Linares » Sat Nov 16, 2013 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby ORibeiro » Sat Nov 16, 2013 8: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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Antonio Linares » Sat Nov 16, 2013 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby ORibeiro » Sat Nov 16, 2013 9: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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Antonio Linares » 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: Select all  Expand view
     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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby ORibeiro » Sat Nov 16, 2013 3: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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Antonio Linares » Sat Nov 16, 2013 7:35 pm

In Class TPrinter method New() then this code should be ok:

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby James Bott » Sat Nov 16, 2013 9: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"
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: FWH 13:09 Default Printer

Postby Antonio Linares » Sun Nov 17, 2013 9: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: Select all  Expand view

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby ORibeiro » Sun Nov 17, 2013 2: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: Select all  Expand view

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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby ORibeiro » Sun Nov 17, 2013 2:31 pm

Please, test it:

Code: Select all  Expand view

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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Enrico Maria Giordano » Sun Nov 17, 2013 4: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
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FWH 13:09 Default Printer

Postby ORibeiro » Sun Nov 17, 2013 7: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: Select all  Expand view

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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi, Silvio.Falconi and 40 guests