Se pierden los datos de Impresora

Post Reply
User avatar
VitalJavier
Posts: 249
Joined: Mon Jun 10, 2013 6:40 pm
Has thanked: 2 times
Been thanked: 1 time

Se pierden los datos de Impresora

Post by VitalJavier »

Hola, buen dia a Todos
Estoy teniendo este problema
Primero imprimo sobre una impresora de tickets (Todo Bien)
Después quiero imprimir sobre una impresora de ancho normal y
me sigue tomando el ancho de la impresora de tickets.

Para Los Tickets utilizo PRINT
Para la impresora de ancho normal, estoy usando REPORT

Alguna sugerencia?
Gracias por su tirmpo.
Saludos.
User avatar
karinha
Posts: 8057
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 10 times
Contact:

Re: Se pierden los datos de Impresora

Post by karinha »

Muestra un ejemplo de cómo creas la primera impresión y luego cómo pasas a la otra impresión o viceversa.

Gracias.

Regards, saludos
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
VitalJavier
Posts: 249
Joined: Mon Jun 10, 2013 6:40 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Se pierden los datos de Impresora

Post by VitalJavier »

Para imprimir en la primera impresora:

Code: Select all | Expand

	cPrint := RETORNA_SYSP("IMPRESORA_CODIGOS")
	PRINT oPrn TO cPrint
		IF Empty( oPrn:hDC )
			MsgStop("Impresora de Etiquetas NO se Encuentra Lista","Alto..")
			ENDPRINT
			RETURN .T.
		ENDIF			
		Select "MICODE"
		DbGoTop()
		DO WHILE !Eof()				
			Ren_ := .1
			PAGE
				oPrn:CmSay(Ren_,3.5,Dtoc(MICODE->FENT1),aLetras[15],,,,2)				
				Ren_+=0.4
				cCadena := MICODE->ID				
				c_Code128(Ren_+=0.2,2,cCadena,oPrn,"C",,.T.,.04,.8)
				oPrn:CmSay(Ren_+=0.8,3.5,cCadena,aLetras[19],,,,2)
				Ren_+=0.5
				oPrn:CmSay(Ren_,3.5,AllTrim(MICODE->MODELO)+"   "+AllTrim(MICODE->TALLA),aLetras[15],,,,1)
				Ren_+=0.4
				oPrn:CmSay(Ren_,3.5,AllTrim(MICODE->COLOR),aLetras[15],,,,1)
			ENDPAGE	
			Select "MICODE"
			DbSkip()		
		ENDDO	
	ENDPRINT
Imprimo unos tickets con un codigo de barras

En la segunda impresion:

Code: Select all | Expand

	REPORT 	oReporte Title "Entrada : "+ENTRADAG->ID,"Fecha : "+Dtoc(ENTRADAG->FECHA),"Marca : "+AllTrim(ENTRADAG->NOMBRE)+"  "+IIF(!ENTRADAG->APLICA,">> ENTRADA SIN APLICAR AL INVENTARIO <<","") Left ;
 				Header AllTrim(EMPRESA->EMPRESA),"Sistema De Administracion","" Center ;
            Footer "Pagina # "+str(oReporte:nPage,3)+" -- "+"Fecha :"+Dtoc(Date())+" Hora : "+Time();            
            Font aLetras[31],aLetras[33],aLetras[52];
            Caption "Reportes Del Sistema de Administracion" Preview              
            Column Title "#"  			Data nRen__++ SIZE 4 PICTURE "999" SHADOW
				Column Title "Modelo"  		Data (cCrea)->MODELO SIZE 8	SHADOW
				Column Title "Color"  		Data (cCrea)->COLOR	SIZE 20	SHADOW
				FOR J := 1 TO LEN(bTallas)
					cDet := "(cCrea)->TALLA"+AllTrim(Str(J))
					cHea := '"'+AllTrim(bTallas[J])+'"'
					Column Title &cHea Data &cDet SIZE 8 TOTAL	SHADOW
				NEXT				
				Column Title "Total"  		Data (cCrea)->TOTAL	SIZE 6 TOTAL	SHADOW
  	ENDREPORT
	oReporte:cGrandTotal := "Totales ... "
	oReporte:lBoxOnTotal := .T.
	oReporte:lShadow := .T.
 	oReporte:lAutoLand := .F.
  	Activate Report oReporte ON STARTLINE AEval( oReporte:aColumns, { | o | o:lShadow := ! o:lShadow } )
Si primero imprimo el reporte y despues los tickets <== Todo bien
Pero si primero imprimo los tickets y despues el reporte, se descuadra el reporte.

Saludos.
User avatar
sysctrl2
Posts: 1088
Joined: Mon Feb 05, 2007 7:15 pm
Has thanked: 10 times
Been thanked: 9 times
Contact:

Re: Se pierden los datos de Impresora

Post by sysctrl2 »

Amigo, asi mero aplícalo
saludos !!!

Code: Select all | Expand

SetPrintDefault( cToPrinter )
PRINTER ::oPrn PREVIEW NAME 'SysCtrl ERP Report'
Cesar Cortes Cruz
SysCtrl Software
Mexico

' Sin +- FWH es mejor "
User avatar
VitalJavier
Posts: 249
Joined: Mon Jun 10, 2013 6:40 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Se pierden los datos de Impresora

Post by VitalJavier »

Cesar, parece que lo resolví asi:

Code: Select all | Expand

	cPrint := RETORNA_SYSP("IMPRESORA_REPORTES")	
	PRINT oPrn TO cPrint		
	ENDPRINT
Puse eso antes de generar el Reporte
Y listo, imprimo los tickets y después el reporte y todo bien

Saludos.
User avatar
karinha
Posts: 8057
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 10 times
Contact:

Re: Se pierden los datos de Impresora

Post by karinha »

Prueba,

Code: Select all | Expand

// C:\FWH\SAMPLES\IMPVARIA.PRG

#include "FiveWin.ch"
#include "Objects.ch"
#include "report.ch"

#define RGB_BLACK      RGB(   0,  0,  0 )
#define RGB_RED        RGB( 255,  0,  0 )
#define RGB_GREEN      RGB(   0,255,  0 )
#define RGB_BLUE       RGB(   0,  0,255 )
#define RGB_CYAN       RGB(   0,255,255 )
#define RGB_YELLOW     RGB( 255,255,  0 )
#define RGB_MAGENTA    RGB( 255,  0,255 )
#define RGB_WHITE      RGB( 255,255,255 )
#define FW_DONTCARE    0
#define FW_THIN        100
#define FW_EXTRALIGHT  200
#define FW_LIGHT       300
#define FW_NORMAL      400
#define FW_MEDIUM      500
#define FW_SEMIBOLD    600
#define FW_BOLD        700
#define FW_EXTRABOLD   800
#define FW_HEAVY       900
#define DMPAPER_A4       9

STATIC oReport

FUNCTION Main()

   LOCAL oPrn, oPrint, oFnt, cPrinter := ""
   LOCAL oDlg, oBrw
   LOCAL aPrn := {}
   LOCAL cDef, i := 1

   SET _3DLOOK ON

   #ifdef __HARBOUR__  // GetPrinters() and GetDefaultPrinter() do not work in Harbour

      aPrn := aGetPrinters ()

      cDef := DefaultPrinter()

   #else // Harbour

      aPrn := GetPrinters ()

      cDef := GetDefaultPrinter()

   #endif

   IF Empty ( aPrn )

      MsgAlert ( "No Printers found" )

      RETURN NIL

   ENDIF

   DEFINE DIALOG oDlg FROM 2, 2 TO 21, 50 TITLE "Available Printers"

   @ 1, 2 LISTBOX oBrw FIELDS aPrn[ i ] ;
      HEADERS "Printer Array" ;
      FIELDSIZES 200 ;
      OF oDlg ;
      SIZE 100, 100

   oBrw:bGoTop    = { || i := 1 }
   oBrw:bGoBottom = { || i := Eval( oBrw:bLogicLen ) }
   oBrw:bSkip     = { | nWant, nOld | nOld := i, i += nWant, ;
      i := Max( 1, Min( i, Eval( oBrw:bLogicLen ) ) ), ;
      i - nOld }
   oBrw:bLogicLen = { || Len( aPrn ) }
   oBrw:cAlias    = "Array"                // Just put something

   @ 7.8, 2 SAY "Default printer: " + cDef

   @ 1, 20 BUTTON "Print (&FW)" OF oDlg ACTION TestCopias ( aPrn[i] )

   @ 2, 20 BUTTON "Print (&xH)" OF oDlg ACTION Test2 ( aPrn[i] )

   @ 3, 20 BUTTON "Print (&RP)" OF oDlg ACTION TestRPT ( aPrn[i] )

   @ 4, 20 BUTTON "&End       " OF oDlg ACTION( oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED

RETURN NIL

FUNCTION TestCopias( cPrn )  // Imprimir varias copias

   LOCAL nI, nCopias := 2

   // SetCopies
   FOR nI := 1 TO nCopias

      TestPrint( cPrn )

   NEXT

RETURN NIL

FUNCTION TestPrint( cPrn )

   LOCAL oFnt, oPrint, aPrn
   LOCAL cText := "Este é um texto de teste para impressão"

   aPrn := GetPrinters()

   PRINT oPrint NAME "Formulario" TO ( cPrn )

   DEFINE FONT oFnt NAME "ARIAL" SIZE 0, -14 OF oPrint

   // oPrint:SetCopies ( 2 ) // Nao funciona

   oPrint:SetLandscape()

   // oPrint:Setup ()   // check the settings

   PAGE

      oPrint:CmSay ( 1, 1, cText, oFnt )

   ENDPAGE

   ENDPRINT

   oFnt:End()

RETURN NIL

FUNCTION Test2 ( cPrn )

   LOCAL oPrinter
   LOCAL aFonts, cFont, nFont

   oPrinter           := Win32Prn():new( cPrn )      // Create printer object and configure print job
   oPrinter:landscape := .F.
   oPrinter:formType  := DMPAPER_A4
   oPrinter:copies    := 2  // <--- 2 copies !!

   IF ! oPrinter:create()                       // Create device context
      Alert( "Cannot create device context" )
      QUIT
   ENDIF

   IF ! oPrinter:startDoc( "xHarbour test page" )   // Create print job
      Alert( "Cannot create document" )
      QUIT
   ENDIF

   oPrinter:textOut( "Text in default font" )       // Text in fixed font
   oPrinter:bold( FW_EXTRABOLD )
   oPrinter:textOut( oPrinter:fontName )
   oPrinter:bold( FW_NORMAL )
   oPrinter:newLine()

   aFonts := oPrinter:getFonts()
   nFont  := AScan( aFonts, ;
      {|a| "ARIAL" $ Upper( a[1] ) } )
   cFont  := aFonts[nFont,1]

   oPrinter:setFont( cFont )                       // Text in proportional font
   oPrinter:textOut( "Text in Arial font" )
   oPrinter:bold( FW_EXTRABOLD )
   oPrinter:textOut( oPrinter:fontName )
   oPrinter:bold( FW_NORMAL )
   oPrinter:newLine()

   oPrinter:setColor( RGB_YELLOW, RGB_BLUE )    // Colored text
   oPrinter:textOut( "Yellow on Blue" )
   oPrinter:newLine()

   oPrinter:setPen( PS_DASH, 5, RGB_GREEN )    // Draw colored line across page

   oPrinter:line( oPrinter:posX, ;
   oPrinter:posY, ;
   oPrinter:rightMargin, ;
   oPrinter:posY  )

   oPrinter:endDoc()       // Send output to printer
   oPrinter:destroy()      // Release GDI device context

RETURN NIL

FUNCTION DefaultPrinter()

   LOCAL nPrn, nRet, sGetDefaultPrinter

   nRet := PrinterSetUp()

   nPrn := PrnGetName()

   IF( nRet # 0 )

      SetDefaultPrinter( PRNGETNAME() )

      sGetDefaultPrinter := GetDefaultPrinter()

      // ? PrnStatus( sGetDefaultPrinter )

      IF PrnStatus( sGetDefaultPrinter ) = 4096

         // Verifica se SPOOLER esta desligado e tenta liga-lo
         MsgRun( sGetDefaultPrinter +": "+isprint( GetDefaultPrinter() ) + ;
                         " ou Spooler Desligado.", "Status da Impressora", ;
                 {|| WinExec( "NET START SPOOLER", 7 ) } )

      ENDIF

      //? GetPrinter()

   ELSE

      MsgAlert ( "No Printers found" )

      RETURN( .F. )

   ENDIF

RETURN( sGetDefaultPrinter ) // NIL

FUNCTION TESTRPT()

   LOCAL oFont1, oFont2, aPrn, oPrn

   DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-10
   DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-10 BOLD

   USE Customer

   INDEX ON Customer->Last TO Customer
   SET INDEX TO Customer
   GO TOP

   aPrn := GetPrinters()

   IF Empty( aPrn ) // Empty( oPrn:hDC )
      MsgStop( "Nenhuma Impressora Encontrada", "Nenhuma Impressora Encontrada" )
      RETURN NIL
   ENDIF

   PRINTER oPrn PREVIEW MODAL // PARA TESTAR A IMPRESSORA ANTES DE IMPRIMIR

   IF EMPTY( oPrn:hDC ) // MODIFICADO EM: 05/05/2015 - Quebrou na Gilmaria.
      MsgInfo( "ALGUMA COISA OCORREU DE ERRADO COM A IMPRESSORA.", "LIGUE A IMPRESSORA." )
      oPrn:End()
      RETURN( .F. )
   ENDIF

   oPrn:End()

   REPORT oReport ;
      TITLE "*** LISTADO DE PRUEBA ***","",OemtoAnsi("FiveTech Software"),"" ;
      FONT oFont1, oFont2 ;
      HEADER "Fecha: "+dtoc(date()),"Hora:  "+time() ;
      FOOTER OemtoAnsi("P gina: ")+str(oReport:nPage,3) ;
      PREVIEW   // TO PRINTER

      oReport:oDevice:lPrvModal := .T. 
      oReport:oDevice:SetPage(9) //-> Formato A4

      COLUMN TITLE "ST" ;
          DATA Customer->State

      COLUMN TITLE "City" ;
          DATA Customer->City

      COLUMN TITLE "First Name","Last Name" ;
          DATA Customer->First, Customer->Last

      COLUMN TITLE "   Salary" ;
          DATA Customer->Salary ;
          PICTURE "9,999,999" ;
          SIZE 9 RIGHT ;
          TOTAL

      END REPORT

   ACTIVATE REPORT oReport ON STARTPAGE Datos()

RETURN NIL

Function Datos()

     local cText

     cText := "Ancho hoja    : "+str(oReport:nWidth)+CRLF
     cText += "Ancho listado : "+str(oReport:nRptWidth)+CRLF
     cText += "Margen Izquier: "+str(oReport:nLeftMargin)+CRLF
     cText += "Margen Derecho: "+str(oReport:nRightMargin)+CRLF
     cText += "Ancho del Font: "+str(oReport:aFont[1]:nWidth)+CRLF
     cText += "Alto del Font:  "+str(oReport:aFont[1]:nHeight)+CRLF
     cText += "Ancho Standard: "+str(oReport:nSeparator)+CRLF
     cText += "Ancho columna1: "+str(oReport:aColumns[1]:nWidth)+CRLF
     cText += "Ancho columna2: "+str(oReport:aColumns[2]:nWidth)+CRLF

RETURN NIL

// FIM
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Post Reply