FWH 13:09 Default Printer

User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Re: FWH 13:09 Default Printer

Post by mastintin »

A sample code :

Code: Select all

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

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

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

_,

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

Linares,

Result:

CutePDF Writer
Fax
PDF reDirect Pro v2
Argox OS-214tt PPLA
\\OASYS4\Samsung SCX-4200 Series
Enviar para o OpenNote 2007
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

If I do this, ::hDC returns zero and does not print.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

_,

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

Code: Select all

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

Results:
nScan = 6
cDevice = \\OASyS4\Samsung SCX-4200 Series,winspool,Ne04:

But printing out the PDF reDirect.

Do you have another idea?

Thanks
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

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

Code: Select all

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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: FWH 13:09 Default Printer

Post by James Bott »

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

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

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

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

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

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?
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Post by ORibeiro »

Please, test it:

Code: Select all

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

 
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FWH 13:09 Default Printer

Post by Enrico Maria Giordano »

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

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

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
 
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

_, 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
Post Reply