Color printing

Color printing

Postby TimStone » Wed Mar 20, 2019 9:11 pm

Using the tPrinter class, is there a way to print a column with a specific color ?

I have a report that attaches to an Invoice. It is a checklist. The first column should be green, the second yellow, the third red, and the last ( and biggest ) is no color and contains the description. The first 3 columns will have printing but just a few characters each.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Color printing

Postby nageswaragunupudi » Thu Mar 21, 2019 3:13 am

Yes
Please use nClrText parameter in the Print (say) methods of Printer class.
Please refer to printer.prg
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Color printing

Postby TimStone » Thu Mar 21, 2019 5:00 pm

I had looked at that. What I want is to have the column background color to be set.

With an xBrowse, we get this effect by using this:

Code: Select all  Expand view  RUN

        oLbx8:aCols[1]:SetCheck()
        oLbx8:aCols[1]:bClrstd := {|| { 0, 65280 } }         // Green
        oLbx8:aCols[2]:SetCheck()
        oLbx8:aCols[2]:bClrstd := {|| { 0,  65535 } }    // Yellow
        oLbx8:aCols[3]:SetCheck()
        oLbx8:aCols[3]:bClrstd := {|| { 0,  255 } }        // Red
        oLbx8:aCols[4]:SetCheck()
 


Now I want to have the same result when I do a printout, where the first 3 COLUMNS can have the background color set to green, yellow, and red.

I also noticed that I can use the SAYTEXT( ) method so I tried this:

Code: Select all  Expand view  RUN

                IF oPrintInspect:svcpas
                        oPrn:SayText( nRow, 2*nCsp, "PASS",,, oFbold, , CLR_BLACK,  CLR_GREEN  )
                ELSEIF oPrintInspect:svcwat
                        oPrn:SayText( nRow, 2*nCsp, "Watch",,, oFbold , , CLR_BLACK, CLR_YELLOW  )
                ELSEIF oPrintInspect:svcfal
                        oPrn:Say( nRow, 2*nCsp, "FAIL",,, oFbold , , CLR_BLACK, CLR_RED )
                ENDIF  
 


It prints no color. I am using a Brother Color Laser Printer ... but not getting any output to Preview, or to Print, in color ... just black and white
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Color printing

Postby Otto » Thu Mar 21, 2019 11:34 pm

Hello Tim,
try Fivewin’s EasyReport.
Best regards
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Color printing

Postby Otto » Thu Mar 21, 2019 11:44 pm

Hello Tim
now with your green and red .
Best regards
Otto

Image


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Color printing

Postby TimStone » Fri Mar 22, 2019 5:51 pm

Otto,

I want to try EasyReport but I don't think I have a working build yet.

HOWEVER, in this case I am creating an invoice that includes a variety of data to be presented. It is certainly not simple, and it has decisions to make as it is processed. I wrote it using tPrinter and it works quite well.

I would like to work with EasyReport but I need to have a stable copy. It is my understanding that it was never finished ( thought Antonio told me in 12/2017 that was a priority for 2018 ). I believe it should be in our FWH distributions and useable as a report generator that we can build into our application. I think that was the original goal, so I can give my clients a tool to build custom reports.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Color printing

Postby Otto » Fri Mar 22, 2019 10:37 pm

Hello Tim,
vrd.prg is renamed as esreport.prg and included in fwh\functions.
The function and class names are changed.
easyrep.ch translates the same commands to esreport.prg function names.
No need to link vrd.prg.
Can you please post a screen of your bill.
EasyReport is in FWH distributions and useable as a report generator.
You can build EasyReport into our application.
Please start with some reports.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Color printing

Postby TimStone » Fri Mar 22, 2019 11:12 pm

Otto,

Can I have an email address to send you a copy ?

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Color printing

Postby nageswaragunupudi » Sat Mar 23, 2019 12:13 am

Using printer object directly:

FWH15.10 introduced enhanced methods for printing text and images.

Code: Select all  Expand view  RUN

METHOD SayText( nRow, nCol, cText, nWidth, nHeight, oFont, cAlign, nClrText, nClrBack )
METHOD PrintImage( nRow, nCol, uImage, nWidth, nHeight, lStretch, nAlpha, lTransp, lGray )
 


Command syntax is provided for ease of use (see print.ch). We recommend use of command syntax.

Example:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oPrn, oFont
   local oBrushGreen, oBrushRed, oBrushYellow
   local nRow, nRowSize

   USE CUSTOMER NEW ALIAS CUST

   PRINT oPrn PREVIEW

   DEFINE FONT oFont NAME "ARIAL" SIZE 0,-14 OF oPrn

   DEFINE BRUSH oBrushGreen  COLOR CLR_HGREEN
   DEFINE BRUSH oBrushRed    COLOR CLR_RED
   DEFINE BRUSH oBrushYellow COLOR CLR_YELLOW

   PAGE

      nRow        := 1.0   // inch
      nRowSize    := 0.3   // inch

      do while RECNO() < 11
         @ nRow, 1.0 PRINT TO oPrn TEXT CUST->FIRST SIZE 1.45,nRowSize INCHES FONT oFont ;
                     COLOR CLR_BLACK, oBrushGreen

         @ nRow, 2.5 PRINT TO oPrn TEXT CUST->CITY  SIZE 1.45,nRowSize INCHES FONT oFont ;
                     COLOR CLR_WHITE, oBrushRed

         @ nRow, 4.0 PRINT TO oPrn TEXT CUST->ZIP   SIZE 1.25,nRowSize INCHES FONT oFont ;
                     COLOR CLR_HBLUE, oBrushYellow

         @ nRow, 5.3 PRINT TO oPrn IMAGE If( CUST->MARRIED, FWBmpOn(), FWBmpOff() ) ;
                     SIZE 0.50,nRowSize INCHES

         nRow  += nRowSize

         SKIP
      enddo

   ENDPAGE
   ENDPRINT

   RELEASE FONT oFont
   RELEASE BRUSH oBrushGreen, oBrushRed, oBrushYellow

return nil
 


Result:
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Color printing

Postby TimStone » Sat Mar 23, 2019 7:11 pm

Thank you. Since all of my code is using the class rather than the command, I was getting an error trying to inject a COMMAND line. However, I translated to the SAYTEXT( ) successfully.

I would still suggest you look at SAY( ) and SAYTEXT( ) in printer.prg. As I noted before, if you set a color with either one for a single line ( or section ) it remains in force for all further calls to the SAY. It becomes the default until changed. Sometimes we want to simply put a highlight on a word or phrase in a different color. This requires extra code on each call to SAY( ) or SAYTEXT( ).

You could modify the method to save the current color value(s), then specify the new ones for the print line specified, and then return to the original colors before exiting the method(s). I think this would be helpful.

I can do it on my copy of printer.prg, and link that in, but then I have to make the change on every new version we receive.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Color printing

Postby nageswaragunupudi » Mon Mar 25, 2019 2:38 am

I would still suggest you look at SAY( ) and SAYTEXT( ) in printer.prg. As I noted before, if you set a color with either one for a single line ( or section ) it remains in force for all further calls to the SAY. It becomes the default until changed. Sometimes we want to simply put a highlight on a word or phrase in a different color. This requires extra code on each call to SAY( ) or SAYTEXT( ).

This is the behaviour of the METHOD Say() but NOT the METHOD SayText(). Seems you made the comment without actually testing SayText().

This behaviour of :Say() has been in existence since beginning and there could be a lot of working software using this behaviour. Any change might affect the existing software.

Since all of my code is using the class rather than the command, I was getting an error trying to inject a COMMAND line. However, I translated to the SAYTEXT( ) successfully.

Usage of command syntax should not give any errors. Proof is the posting above. In addition I have been using it in many software projects without any problem. However whether to use command syntax or method directly is a matter of programmers' choice.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Color printing

Postby TimStone » Tue Apr 09, 2019 6:29 pm

This is the behaviour of the METHOD Say() but NOT the METHOD SayText(). Seems you made the comment without actually testing SayText().


Seems that's a rather unfair assumption since I DID adopt the SayText() method as YOU suggested ... and that is how it is performing ...

Code: Select all  Expand view  RUN

// Prints FAIL as white on red
      oPrn:SayText( nRow, 2 * nCsp, "FAIL",6*nCsp,nRsp, oFbold, , CLR_WHITE, oBrushRed )
// Prints text in White on Red
     oPrn:SayText( nRow, 10 * nCsp, MemoLine( oPrintInspect:svcdes, 60, lx,, .T. ),,, oFnorm )
// Required to return text to default of black on white
     oPrn:SayText( nRow, 10 * nCsp, MemoLine( oPrintInspect:svcdes, 60, lx,, .T. ),,, oFnorm, , CLR_BLACK, oBrushWhite )
 
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2950
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests