Page 4 of 5

Re: FWH 13:09 Default Printer

PostPosted: Fri Nov 15, 2013 7:23 pm
by mastintin
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)

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 7:25 am
by Antonio Linares
Oscar,

Please try this code:

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

and post here your result

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 8:13 am
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

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 8:16 am
by Antonio Linares
Ok, so if you do:

PRINTER oPrn TO "Samsung"

that would be enough to select the Samsung printer

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 9:34 am
by ORibeiro
If I do this, ::hDC returns zero and does not print.

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 10:22 am
by Antonio Linares
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.

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 3:05 pm
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

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 7:35 pm
by Antonio Linares
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()

Re: FWH 13:09 Default Printer

PostPosted: Sat Nov 16, 2013 9:33 pm
by James Bott
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"

Re: FWH 13:09 Default Printer

PostPosted: Sun Nov 17, 2013 9:53 am
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  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

Re: FWH 13:09 Default Printer

PostPosted: Sun Nov 17, 2013 2:00 pm
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  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?

Re: FWH 13:09 Default Printer

PostPosted: Sun Nov 17, 2013 2:31 pm
by ORibeiro
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

 

Re: FWH 13:09 Default Printer

PostPosted: Sun Nov 17, 2013 4:01 pm
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

Re: FWH 13:09 Default Printer

PostPosted: Sun Nov 17, 2013 7:06 pm
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  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
 

Re: FWH 13:09 Default Printer

PostPosted: Mon Nov 18, 2013 10:52 am
by Antonio Linares
Oscar, Enrico,

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

I am doing some tests, thanks