pdfclass sample, error in page width

398 views
Skip to first unread message

Paola Bruccoleri

unread,
Apr 7, 2025, 8:22:31 PMApr 7
to harbour-users
Hello Luiz and other colleagues.

I reviewed your ticket example and it worked fine for me.
Now I'm trying to create my own ticket for a thermal printer and I get this error (the program abort):

73DA0000 00008000 C:\WINDOWS\SYSTEM32\VERSION.dll                               
74120000 00019000 C:\WINDOWS\SYSTEM32\MPR.dll                                   
77310000 00066000 C:\WINDOWS\System32\WINTRUST.dll                              
74010000 00008000 C:\WINDOWS\SYSTEM32\WSOCK32.dll                               
76BC0000 00025000 C:\WINDOWS\System32\IMM32.DLL                                 
6EE30000 0000E000 C:\WINDOWS\SYSTEM32\MSASN1.dll                                
73A50000 00015000 C:\WINDOWS\SYSTEM32\CRYPTSP.dll                               
733F0000 00033000 C:\WINDOWS\system32\rsaenh.dll                                
73C30000 0000B000 C:\WINDOWS\SYSTEM32\CRYPTBASE.dll                             
773B0000 00069000 C:\WINDOWS\System32\bcryptPrimitives.dll                      
76F70000 0001B000 C:\WINDOWS\System32\imagehlp.dll                              
741E0000 0002B000 C:\WINDOWS\SYSTEM32\SspiCli.dll                               
73CD0000 00082000 C:\WINDOWS\system32\uxtheme.dll                               
1E940000 00201000 f:\ah\marcrefe\adsloc32.dll                                                                                                                   
Called from HPDF_PAGE_SETWIDTH(0)                                               
Called from PDFCLASS:ADDPAGE(242) in F:\ah\libh\ze_pdfclass.prg       

THE EXAMPLE:

oPDF:= PDFClass():New()
oPDF:nPageWidth:=  226.77  // 8 cm  =  80 * 0.03937 * 72 px
oPDF:nPageHeight:= 841.89  // largo A4 ??????
oPDF:cFileName:= 'abc.pdf'
oPDF:cFontName:= "Helvetica"
oPDF:nFontSize:= 8
oPDF:nDrawMode:= 2 // mm
oPDF:nPrinterType:= 1 // Portrait

oPDF:Begin()
FOR i:=1 TO 2
   oPage:= oPDF:AddPage()
   oPDF:DrawMemImageBox( nLine, 20, nLine + 7, 46,  GetCurrentFolder()+'\logo.jpg' )

NEXT
oPDF:End()


Also, how can I know the length of the page if I depend on the length of the information I have? I put A4 to put something

This is an example I'm just starting, and I want to test how a logo looks.
I have these questions:
1) What would be the optimal size?
2) How can I center it, just like any other text?

Thank you very much for any help



Paola Bruccoleri

unread,
Apr 9, 2025, 4:42:37 PMApr 9
to harbour-users
Hello

The problem was solved.
Thanks


De: "Paola Bruccoleri" <pbruc...@adinet.com.uy>
Para: "harbour-users" <harbou...@googlegroups.com>
Enviados: Lunes, 7 de Abril 2025 21:22:18
Asunto: [harbour-users] pdfclass sample, error in page width

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/1017988950.2835682.1744071738549.JavaMail.zimbra%40vera.com.uy.

Nenad Batoćanin

unread,
Apr 9, 2025, 8:19:19 PMApr 9
to harbou...@googlegroups.com

The user just installed Windows Server 2025 Standard and the program has slowed down drastically. Working with dbf tables is 5-10 times slower than on Windows Server 2012R2.

 

Is there any recommendation to solve this problem?

 

Regards, NB

Message has been deleted

Gerald Drouillard

unread,
Apr 9, 2025, 8:33:26 PMApr 9
to harbou...@googlegroups.com
Single user or network user load?

Look at the standard things that can slow down a dbf app:
  • antivirus
  • network performance and I/O benchmarks
  • disk I/O benchmarks
  • cpu usage
  • using MS networking?  then the protocols have evolved and have extra encryption overhead
  • did you disable the oplocks?


--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Nenad Batoćanin

unread,
Apr 9, 2025, 8:52:58 PMApr 9
to harbou...@googlegroups.com

They use LetoDB with 10-15 users, but even single user on server without LetoDB run VERY slow...

 

I didn't turn off oplocks, but as far as I know it will slow down the server even more?

 

NB

Gerald Drouillard

unread,
Apr 9, 2025, 9:32:56 PMApr 9
to harbou...@googlegroups.com
Did you turn off AV?  At least for the directory where the .dbf's are located.

Another test is to copy a large file from one of your clients to the new and old server and see the difference.


Rosario Giuffré

unread,
Apr 10, 2025, 8:26:16 AMApr 10
to harbou...@googlegroups.com
Hi NB.

Excluye del control antivirus la carpeta con los archivos del sistema de trabajo.
Me pasó igual hace tiempo con NOD32 y WIN SERVER. Esa fue la solución.

Regards, Rosario Giuffré

Nenad Batoćanin

unread,
Apr 10, 2025, 10:26:14 AMApr 10
to harbou...@googlegroups.com

Yes, the exclude folder with the program was set, but unfortunately it didn't help. Also, Nod has some weird system to scan everything even when the scan is turned off, it just doesn't report anything.

 

Regards, NB

Harold San Lee

unread,
May 2, 2025, 4:55:07 PMMay 2
to harbou...@googlegroups.com

Saludos Paola.
Nos puedes mostrar como lo solucionaste?

Harold San.


Paola Bruccoleri

unread,
May 2, 2025, 7:06:36 PMMay 2
to harbour-users
Hi Harold
I made a lot of changes, I think it was because an AddPage was missing.
I'll give you a fully functional example.
-----------------
Hice muchos cambios, pienso que ese error era porque faltaba un addpage, pero ya no me acuerdo, no estoy segura.
Te paso un ejemplo totalmente funcional, después de varias pruebas. Espero te sirva para darte una idea.
La fuente Courier New es imposible usar porque en la impresora térmica se pixela demasiado y se ve muy borroso, es impresentable la impresión.

También estuve probando de imprimir el mismo formato de ticket pero usando la lib win32prn. Si querés te lo envío. Estoy en fase de pruebas, todavía no decidí si voy a usar PDFClass (basada en la librería harupdf) o la lib win32prn.
Espero te sirva, saludos!!!


//---------------------------------------------------------------------
PROCEDURE PruebaLaser5()
//---------------------------------------------------------------------
/* Impresion con clase PDFClass de Jose Quintas
ze_pdfclass.prg

la clase usa la libreria harupdf incluida en harbour
INCLUDEO3GH_32 *Last* f:\hb32\lib\win\mingw\liblibhpdf.a 
INCLUDEO3GH_32 *Last* f:\hb32\lib\win\mingw\libhbhpdf.a 

este ch está en la instalación de hb32
*/
LOCAL oPdf, oPage, nLargoPag
LOCAL aCuotas  := {}

// aCuotas:= {doc, cta, importe, gasto, mora, tramite, total, pxvto, pxcta, det, vtocta, totctasvale, prov, tipo, devint, serie, devseg, CAPITAL, INTERES, SEG}
AADD(aCuotas, {1234567,1,350,0,50,0,9450,Date(),2,'Detalle 1 xxxxxxxxxx', ctod('15032025'),6,111, 'C',0,'C',0, 200,100,50,.f. } )
AADD(aCuotas, {548796,1,110258,0,500,0,110358,ctod('15032025'),2,'Detalle 2 xxxxxxxxxxgfgfg', ctod('15032025'),6,333, 'T',0,'Z',0, 200,100,50,.f. } )
AADD(aCuotas, {232323,1,15550,0,35682,0,15650,ctod('15032025'),2,'Detalle 3 xxxxxxxxxxfgfgfgf', ctod('15032025'),50,333, 'E',0,'Z',0, 200,100,50,.f. } )

nFontSizeXLarge:= 13
nFontSizeLarge:= 11
nFontSizeSmall:= 7
nFontSizeNormal:= 9

oPDF:= PDFClass():New()
oPDF:nPageWidth:=  226.80  // 8 cm  =  80 * 0.03937 * 72 px

// Calculamos el largo de página según el largo del array aCuotas y lo que lleva cabecera y pie
// añadimos margen
nLargoPag:= 83 + (len(acuotas) * 8) + 30 + 5  // en mm  
   
// Ajustamos el tamaño de la página al contenido real
// Convertimos centímetros a puntos PDF
oPdf:nPageHeight:= (nLargoPag * 28.35) / 10
   
oPDF:cFileName:= GetCurrentFolder()+'\abc.pdf'
oPDF:cFontName:= "Helvetica"
oPDF:nFontSize:= 8
oPDF:nDrawMode:= 2 //mm
oPDF:nPrinterType:= 1 // Portrait

// Ajustamos márgenes para impresoras térmicas
//oPdf:nTopMargin := 5     // 5 puntos
oPdf:nLeftMargin := 5    // 5 puntos
oPdf:nRightMargin := 5   // 5 puntos
oPdf:nBottomMargin := 5  // 5 puntos

oPDF:Begin()
FOR i:= 1 TO 2   
   oPDF:AddPage()
      
   CrearTicket (oPdf, aCuotas, Date(), 1, 'NOMBRE1DD XXXXXXXXX', 'APELLIDO YYYYYYYYY', 23456,;
   'P', 10000, 'C', 'X')   
NEXT
oPDF:End()
RETURN


PROCEDURE CrearTicket (oPdf, aCuotas, dFecha, nCli, cNomCli, cApeCli, nComp,;
   cMon, nPuntos, cTipo, cSerieR)
LOCAL nLine, nReng, i, nTotal

nTotal:= 0
nLine:= 5

// CABECERA 
oPDF:DrawText( nLine,  5, "Marcre Ltda. - RUT: 170090190014", , nfontsizeNormal )

oPDF:DrawImageBox( nLine+2, 22, nLine + 35, 25+35,  GetCurrentFolder()+'\logo.jpg' )

oPDF:DrawTextCenter( nLine + 40, "Sucursal San José", , nfontsizeNormal)
oPDF:DrawTextCenter( nLine + 43, "Asamblea 11111", , nfontsizeNormal )
oPDF:DrawTextCenter( nLine + 46, "SAN JOSÉ DE MAYO - SAN JOSÉ", , nfontsizeNormal )
oPDF:DrawTextCenter( nLine + 49, "xxxxx.yyyy.uy", , nfontsizeNormal )

oPDF:DrawLine( nLine + 54, 5, nLine + 54, 75, 0 )

// DATOS DEL RECIBO
oPDF:DrawText( nLine + 58,  5, "Recibo:", , nfontsizeNormal )
oPDF:DrawText( nLine + 58,  25, cSerieR + ' ' + alltrim(str(nComp)), , nfontsizeNormal )

oPDF:DrawText( nLine + 61,  5, "Fecha:", , nfontsizeNormal )
oPDF:DrawText( nLine + 61, 25, dtoc(dFecha), , nfontsizeNormal )

oPDF:DrawText( nLine + 64,  5, "Moneda:", , nfontsizeNormal )
oPDF:DrawText( nLine + 64, 25, if(cMon='P', 'PESOS','DÓLARES'), , nfontsizeNormal )

// DATOS DEL CLIENTE
oPDF:DrawText( nLine + 70, 5, alltrim(cApeCli), , nfontsizeNormal )
oPDF:DrawText( nLine + 73, 5, alltrim(cNomCli), , nfontsizeNormal )
oPDF:DrawText( nLine + 76, 5, 'Nro.Cliente: ' + alltrim(str(nCli)), , nfontsizeNormal )

// CUOTAS QUE PAGA
oPDF:DrawText( nLine + 82, 3, 'DETALLE      CTA    CAPITAL      MORA    DEV.INT      TOTAL', , nfontsizeSmall )

nReng:= 86

for i:=1 to LEN(aCuotas) 
  oPDF:DrawText( nLine + nReng,  3, aCuotas[i,16] + ' ' + alltrim(str(aCuotas[i,1])), , nfontsizeSmall ) // serie + nro.vale
  oPDF:DrawText( nLine + nReng,  17, alltrim(str(aCuotas[i,2]))+'/'+alltrim(str(aCuotas[i,12])), , nfontsizeSmall ) // cuota que paga

  oPDF:DrawTextRight( nLine + nReng,  35, TRANSFORM(aCuotas[i,3], '999,999.99'), nfontsizeSmall) // capital
  oPDF:DrawTextRight( nLine + nReng,  50, TRANSFORM(aCuotas[i,5], '999,999.99'), nfontsizeSmall )  // mora
  oPDF:DrawTextRight( nLine + nReng,  61, TRANSFORM(aCuotas[i,6]+aCuotas[i,15]+aCuotas[i,17], '99,999.99'), nfontsizeSmall) // tramite + devol de interes + devol de seguro
  oPDF:DrawTextRight( nLine + nReng,  77, TRANSFORM(aCuotas[i,7], '999,999.99'), nfontsizeSmall )  // total

  nReng+=3

  // linea de detalles
  if aCuotas[i,14] = 'T'
     oPDF:DrawText( nLine + nReng,  3, if(aCuotas[i,8] = ctod(''), 'Vale Cancelado', 'Prox.Vto el '+ dtoc(aCuotas[i,8]) + if(aCuotas[i,9]=0,'', ' Cta Nº'+alltrim(str(aCuotas[i,9]))) ), , nfontsizeSmall ) 
     oPDF:DrawText( nLine + nReng,  45, 'VALE TICKET', , nfontsizeSmall )    
  elseif aCuotas[i,14] = 'C'
     oPDF:DrawText( nLine + nReng,  3, if(aCuotas[i,9]=0, 'Vale Cancelado', 'Próxima Cuota Nº'+alltrim(str(aCuotas[i,9]))+' el '+dtoc(aCuotas[i,8]) ) , , nfontsizeSmall ) 
  else
     oPDF:DrawText( nLine + nReng,  3, if(aCuotas[i,8] = ctod(''), 'Vale Cancelado', 'Prox.Vto el '+ dtoc(aCuotas[i,8]) + if(aCuotas[i,9]=0,'', ' Cta Nº'+alltrim(str(aCuotas[i,9]))) ), , nfontsizeSmall ) 
     oPDF:DrawText( nLine + nReng,  45, 'VALE EFECTIVO', , nfontsizeSmall )    
  endif

  nTotal+= aCuotas[i,7]
  nReng+=5 
next

// PIE
nReng+=5
oPDF:DrawText( nLine + nReng,  20, 'Total a cobrar:', , nfontsizeNormal, 'Courier-Bold' ) 
oPDF:DrawText( nLine + nReng,  55, nTotal, '999,999', nfontsizeNormal, 'Courier-Bold' ) 

nReng+=3
oPDF:DrawLine( nLine + nReng, 5, nLine + nReng, 75, 0 )

// observaciones
nReng+=5
oPDF:DrawText( nLine + nReng,  5, i_cObs1, , nfontsizeNormal ) 

// PUNTAJE DE LA PROMO
nReng+=3   
if nPuntos > 0
   oPDF:DrawText( nLine + nReng,  5, 'MONEDAS: ' + TRANSFORM(nPuntos, '99,999.99'), , nfontsizeNormal ) 
endif
   
RETURN


A la clase PDFClass le agregué estos dos métodos:

METHOD DrawTextCenter( nTop, xValue, cPicture, nFontSize, cFontName, nAngle, anRGB ) CLASS PDFClass
   LOCAL nRadian, cTexto, nLeft, tw

   hb_Default( @nFontSize, ::nFontSize )
   hb_Default( @cFontName, ::cFontName )
   hb_Default( @cPicture, "" )
   hb_Default( @nAngle, ::nAngle )

   cTexto := Transform( xValue, cPicture )
   
   IF ::nPrinterType == PDFCLASS_TXT
      // Para impresión en modo texto, calculamos el centro basado en la longitud del texto
      nLeft := Int( (::MaxCol() - Len( cTexto )) / 2 )
      @ nTop, nLeft SAY cTexto
   ELSE
      // Para PDF, usamos la función de HaruPDF para obtener el ancho exacto del texto
      nTop := ::RowToPDFRow( nTop )
      
      // Obtenemos el ancho del texto según la fuente actual
      HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPdf, cFontName, ::cCodePage ), nFontSize )
      tw := HPDF_Page_TextWidth( ::oPage, cTexto )
      
      // Calculamos la posición izquierda para centrar
      nLeft := (::nPageWidth - tw) / 2
      
      // Aplicamos color si se especifica
      IF anRGB != NIL
         HPDF_Page_SetRGBFill( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
         HPDF_Page_SetRGBStroke( ::oPage, anRGB[ 1 ], anRGB[ 2], anRGB[ 3] )
      ENDIF
      
      // Dibujamos el texto
      HPDF_Page_BeginText( ::oPage )
      nRadian := ( nAngle / 180 ) * 3.141592
      HPDF_Page_SetTextMatrix( ::oPage, Cos( nRadian ), Sin( nRadian ), -Sin( nRadian ), Cos( nRadian ), nLeft, nTop )
      HPDF_Page_ShowText( ::oPage, cTexto )
      HPDF_Page_EndText( ::oPage )
      
      // Restauramos el color por defecto si se había cambiado
      IF anRGB != NIL
         HPDF_Page_SetRGBFill( ::oPage, 0, 0, 0 )
         HPDF_Page_SetRGBStroke( ::oPage, 0, 0, 0 )
      ENDIF
      
      // Actualizamos la columna actual para compatibilidad con otros métodos
      ::nCol := nLeft + tw
   ENDIF

   RETURN NIL


METHOD DrawTextRight( nTop, nRight, xValue, cPicture, nFontSize, cFontName, nAngle, anRGB ) CLASS PDFClass
   LOCAL nRadian, cTexto, nLeft, tw

   hb_Default( @nFontSize, ::nFontSize )
   hb_Default( @cFontName, ::cFontName )
   hb_Default( @cPicture, "" )
   hb_Default( @nAngle, ::nAngle )

   cTexto := Transform( xValue, cPicture )
   
   IF ::nPrinterType == PDFCLASS_TXT
      // Para impresión en modo texto, calculamos la posición utilizando el ancho total
      nLeft := nRight - Len(cTexto)
      @ nTop, nLeft SAY cTexto
      ::nCol := nRight
   ELSE
      // Para PDF, usamos la función de HaruPDF para obtener el ancho exacto del texto
      nTop := ::RowToPDFRow( nTop )
      nRight := ::ColToPDFCol( nRight )
      
      // Obtenemos el ancho del texto según la fuente actual
      HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPdf, cFontName, ::cCodePage ), nFontSize )
      tw := HPDF_Page_TextWidth( ::oPage, cTexto )
      
      // Calculamos la posición izquierda para alinear a la derecha
      nLeft := nRight - tw
      
      // Aplicamos color si se especifica
      IF anRGB != NIL
         HPDF_Page_SetRGBFill( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
         HPDF_Page_SetRGBStroke( ::oPage, anRGB[ 1 ], anRGB[ 2], anRGB[ 3] )
      ENDIF
      
      // Dibujamos el texto
      HPDF_Page_BeginText( ::oPage )
      nRadian := ( nAngle / 180 ) * 3.141592
      HPDF_Page_SetTextMatrix( ::oPage, Cos( nRadian ), Sin( nRadian ), -Sin( nRadian ), Cos( nRadian ), nLeft, nTop )
      HPDF_Page_ShowText( ::oPage, cTexto )
      HPDF_Page_EndText( ::oPage )
      
      // Restauramos el color por defecto si se había cambiado
      IF anRGB != NIL
         HPDF_Page_SetRGBFill( ::oPage, 0, 0, 0 )
         HPDF_Page_SetRGBStroke( ::oPage, 0, 0, 0 )
      ENDIF
      
      // Actualizamos la columna actual para compatibilidad con otros métodos
      ::nCol := nRight
   ENDIF

   RETURN NIL

Al método End() le agregué el parámetro lPreview de tal forma que me permita imprimir directamente el pdf sin visualizarlo, usando foxitreader.

METHOD End( lPreview ) CLASS PDFClass

   hb_Default( @lPreview, .T. )
   ::PageFooter()

   IF ::nPrinterType == PDFCLASS_TXT
      SET PRINTER TO
      SET DEVICE TO SCREEN
      SetPrc(0,0)
      IF lPreview
         ::Preview( ::cFileName, ::nPageWidth == 132 ) // compression
         fErase( ::cFileName )
      ELSE
         SET DEVICE TO PRINT
         SetPrc( 0, 0 )
         @ 0,0 SAY MemoRead( ::cFileName )
         SET DEVICE TO SCREEN
         SET PRINTER TO
         SetPrc( 0, 0 )
         fErase( ::cFileName )
      ENDIF
   ELSE
      //IF ::nPdfPage == 0
      //   ::AddPage()
      //   ::DrawText( 10, 10, "NINGÚN CONTENIDO (NO CONTENT)",, ::nFontSize * 2 )
      //ENDIF
      
      IF File( ::cFileName )
         fErase( ::cFileName )
      ENDIF
      HPDF_SaveToFile( ::oPdf, ::cFileName )
      HPDF_Free( ::oPdf )

      IF lPreview
         ::PDFRun( ::cFileName )
      ELSE
         IF EMPTY(::cPrinter)
            HB_RUN( ::cPDFReader + " /p " + ::cFileName )
         ELSE
            HB_RUN( ::cPDFReader + " /t " + ::cFileName + ' "' + ALLTRIM(::cPrinter) + '" ' )
         ENDIF
      ENDIF
   ENDIF

   RETURN NIL




De: "Harold San Lee" <edga...@gmail.com>
Para: "harbour-users" <harbou...@googlegroups.com>
Enviados: Viernes, 2 de Mayo 2025 17:54:50
Asunto: Re: [harbour-users] pdfclass sample, error in page width

fdaniele

unread,
May 3, 2025, 6:12:36 AMMay 3
to Harbour Users
@paola

I'm also doing a similar feat on a Custom POS printer with win32prn, the print comes out very well, after a pass of alcohol on the head.
I'll send you a piece of my attempts, I won't send everything because I'm ashamed of how messy it is and it's also in Italian.

I haven't managed to cut the paper yet, not even by passing the escape commands.
by the way, it's also possible to print via socket with the escape characters and the result is very good.

consider that the margin can't be changed with its commands but only with oPrinter:SetPos(..., ...)

I hope it's useful to you
Best regards
Daniele
x Paola.prg
STAMPA.pdf

Paola Bruccoleri

unread,
May 3, 2025, 10:43:21 AMMay 3
to harbour-users
Hey, Daniele...
Thank you so much for sharing!
My tests are not very good:)
I'm sending you what I have working pretty well, but I can't print the logo well (99x96px)
I'll give you the same example but with win32prn. The paper cuts it very well.
(in the pdf you do not see the cut but if you print on the ticket printer you cut well).
I didn't need to define a custom paper size.


// ------------------------------------------------------------------
FUNCTION PrnInit (cPrinter, oPrn, nCopies)
// ------------------------------------------------------------------
   oPrn:= Win32Prn():New(cPrinter)
   oPrn:FormType := 9 // A4 form
   oPrn:LandScape:= .f.
   oPrn:Copies := nCopies
   //oPrn:CharSet(255) //OEM_CHARSET
   
   if !oPrn:Create()
      Alert("Printer Error! check printer.")
      return .t.
   endif
   if !oPrn:StartDoc("Ticket")
      Alert("Printer Error! check printer.")
      oPrn:Destroy()
      return .t.
   endif
RETURN .t.

// ------------------------------------------------------------------
FUNCTION PrnExit (oPrn)
// ------------------------------------------------------------------
   oPrn:EndDoc() // call endpage() at least one time.
   oPrn:Destroy()
RETURN .t.
   
   
//------------------------------------------------------------------------------------------------------------
PROCEDURE PruebaTicket2()
// ------------------------------------------------------------------
   LOCAL oPrn
   LOCAL aCuotas := {}

   // Definir cuotas
   AADD(aCuotas, {1234567,1,350,0,50,0,9450,Date(),2,'Detalle 1 xxxxxxxxxx', ctod('15032025'),6,111, 'C',0,'C',0, 200,100,50,.f.})
   AADD(aCuotas, {548796,1,110258,0,500,0,110358,ctod('15032025'),2,'Detalle 2 xxxxxxxxxxgfgfg', ctod('15032025'),6,333, 'T',0,'Z',0, 200,100,50,.f.})
   AADD(aCuotas, {232323,1,15550,0,35682,0,15650,ctod('15032025'),2,'Detalle 3 xxxxxxxxxxfgfgfgf', ctod('15032025'),50,333, 'E',0,'Z',0, 200,100,50,.f.})

   cPrinter:= 'cfe'
   //cPrinter:= 'Brother DCP-T500W Printer'
   //cPrinter:= "Microsoft Print to PDF"

   PrnInit (cPrinter, @oPrn, 1)

   CrearTicket2 (oPrn, aCuotas, Date(), 1, 'NOMBRE1DD XXXXXXXXX', 'BRUCCOLERI ARRAMBIDE', 23456,;
      'P', 10000, 'C', 'X')
   
   PrnExit(oPrn)
RETURN

// ------------------------------------------------------------------
PROCEDURE CrearTicket2 (oPrinter, aCuotas, dFecha, nCli, cNomCli, cApeCli, nComp,;
   cMon, nPuntos, cTipo, cSerieR)
// ------------------------------------------------------------------
LOCAL oBmp, nTotal

nTotal:= 0

// ENCABEZADO
oPrinter:newline()
oPrinter:SetFont("Lucida Console", 8, {3,-70}, 0, .F., .F.)
oPrinter:TextOut("Empresa.     RUT: 123456789", .t.)

// LOGO
IF File(GetCurrentFolder()+ "\logo.bmp")
   oBMP:= Win_BMP():new()
   aTamlog := 8

   oBMP:= Win_BMP():new()
   oBmp:loadFile( GetCurrentFolder()+ "\logo.bmp" )
   //oBmp:Draw( oPrinter,  { 60, 100, 158, 194 } )  // MAL!!                           
   oBmp:Draw( oPrinter,  { 160, 100, 258, 194 } )                             
else
   aTamlog := 2
endif

FOR i = 1 TO aTamlog
   oPrinter:newline()
NEXT

// Imprimir datos de sucursal
oPrinter:SetFont("Lucida Console", 8, {0,0}, 0, .F., .F.)
oPrinter:TextOut(HB_AnsiToOem(PADC("Sucursal San José", 43, ' ')), .t.)            
oPrinter:TextOut(PADC("Peatonal Prueba 12345", 43, ' '), .t.)            
oPrinter:TextOut(HB_AnsiToOem(PADC("SAN JOSÉ DE MAYO - SAN JOSÉ", 43, ' ')), .t.)            
oPrinter:TextOut(PADC("marcre.com.uy", 43, ' '), .t.)            

// Imprimir datos del recibo
oPrinter:SetFont("Lucida Console", 8, {0,0}, 0, .F., .F.)
oPrinter:TextOut("___________________________________________", .T., .T.) // 43
oPrinter:TextOut("Recibo: "+ cSerieR + " "+alltrim(str(nComp)), .T.)
oPrinter:TextOut("Fecha: " + dtoc(dFecha), .T.)
oPrinter:TextOut("Moneda: PESOS", .T.)
oPrinter:newline()

// Datos del cliente
oPrinter:TextOut(cApeCli, .T.)
oPrinter:TextOut(cNomCli, .T.)
oPrinter:TextOut("Nro. Cliente: " + alltrim(str(nCli)), .T.)
oPrinter:newline()

// Imprimir detalle de cuotas
oPrinter:SetFont("Lucida Console", 8, {3,-70}, 0, .F., .F.)
oPrinter:TextOut("__________________________________________________________________", .T., .T.) // 66
oPrinter:TextOut("DETALLE      CTA     CAPITAL       MORA     DEVINT       TOTAL", .T.)

FOR i:= 1 to LEN(aCuotas)
      oPrinter:TextOut(;
               aCuotas[i,16] + ' ' + PADR(alltrim(str(aCuotas[i,1])),9,' ') + "  " + ;
               PADR(alltrim(str(aCuotas[i,2]))+'/'+alltrim(str(aCuotas[i,12])), 5, ' ') + "  " + ;
               TRANSFORM(aCuotas[i,3], '999,999.99') + "  " + ;
               TRANSFORM(aCuotas[i,5], '999,999.99') + " " + ;
               TRANSFORM(aCuotas[i,6]+aCuotas[i,15]+aCuotas[i,17], '999,999.99') + " " + ;
               TRANSFORM(aCuotas[i,7], '999,999.99'),  .T.)
      
           
      // Imprimir detalle adicional
      IF aCuotas[i,14] == "C"
         oPrinter:TextOut(if(aCuotas[i,9]=0, 'Vale Cancelado', 'Próxima Cuota Nº'+alltrim(str(aCuotas[i,9]))+' el '+dtoc(aCuotas[i,8]) ), .T.)
      ELSEIF aCuotas[i,14] == "T"
         oPrinter:TextOut(if(aCuotas[i,8] = ctod(''), 'Vale Cancelado', 'Prox.Vto el '+ dtoc(aCuotas[i,8]) + if(aCuotas[i,9]=0,'', ' Cta Nº'+alltrim(str(aCuotas[i,9]))) ), .T.)
      ELSEIF aCuotas[i,14] == "E"
         oPrinter:TextOut(if(aCuotas[i,8] = ctod(''), 'Vale Cancelado', 'Prox.Vto el '+ dtoc(aCuotas[i,8]) + if(aCuotas[i,9]=0,'', ' Cta Nº'+alltrim(str(aCuotas[i,9]))) ), .T.)
      ENDIF
      
      nTotal+= aCuotas[i,7]
NEXT

// Imprimir total
oPrinter:newline()
oPrinter:TextAtfont(,,"TOTAL:   " + TRANSFORM(nTotal, '999,999.99'), "Lucida Console", 10, , WIN_FW_BOLD, , .T.)


// MONEDAS, OBSERVACION
oPrinter:SetFont("Lucida Console", 8, {0,0}, 0, .F., .F.)
oPrinter:newline()
oPrinter:TextOut("___________________________________________", .T., .T.) // 43
oPrinter:TextOut("Dif.Negativa por Devol.Int/Seg", .T.)
oPrinter:TextOut("MONEDAS: " + TRANSFORM(nPuntos, '999,999.99'), .T.)

RETURN


De: "fdaniele" <dfpro...@gmail.com>
Para: "Harbour Users" <harbou...@googlegroups.com>
Enviados: Sábado, 3 de Mayo 2025 7:12:36

fdaniele

unread,
May 3, 2025, 11:39:56 AMMay 3
to Harbour Users
Hi Paola

I haven't tried to print images yet but I'll have to.

Monday I'll have the printer available and if you want or can, send me your logo, even in trial and I'll try.

Anyway, from experience it's not always the code or the printer's fault but also the image itself.

with the previous script I couldn't print bold or italics in any way but I managed to do it with great results, also in terms of speed with the other system, via socket.

I also tried with pagescript but I found a really big problem and so I went back to Win32Prn.

Anyway, if you want I'll try to help you.

have a good weekend
Daniele

fdaniele

unread,
May 3, 2025, 2:32:49 PMMay 3
to Harbour Users
 
Immagine WhatsApp 2025-05-02 ore 08.50.35_4b57755f.jpg

@Paola

this is the print of last code, good for me.
a question: in your script which is the cut command?
best regards

Daniele

Harold San Lee

unread,
May 3, 2025, 3:52:46 PMMay 3
to harbou...@googlegroups.com
Saludos Paola, e Interesados

Logre esto con el código que enviastes.

Laser.pdf

Paola Bruccoleri

unread,
May 4, 2025, 1:18:17 PMMay 4
to harbour-users
Hi, Daniele.
It does it automatically, I didn't put any code.
Even if I put more than one copy.


De: "fdaniele" <dfpro...@gmail.com>
Para: "Harbour Users" <harbou...@googlegroups.com>
Enviados: Sábado, 3 de Mayo 2025 15:32:49
Reply all
Reply to author
Forward
0 new messages