FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help : Regarding Reports & Printing using FWH
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Sat Oct 18, 2008 11:36 AM
Dear Freinds,

Most of the users of my app use DOT Matrix printers connected to their local LPT port and few of them are using network printers (DOT Matrix) mapped to their local LPT port (Net use LPT1 \\PcName\PrintShareName)

For printing they use computer paper stationaries with size 10x12 inch or 10*15" inch papers and not A4.

My application create reports on a text file and once the report is created on a text file, I give choice to user either to
1) View the report on screen (using a Text file browser)
2) Print the report ( If this opted then the already created text file is copied to the LPT port using the command copy file xxx.txt to LPT1, which prints the report in a much faster way unlike printing from windows in graphics mode)
3) Save the report (Txt) in a user specified folder for future reference.

I use to write my clipper app using the following method

Set Printer to "Report.Txt"
Set Device to Printer
SetPrc(00,00)
Set Console Off

Use Account Index Account

@prow()+1,00 say "Company Name"
@prow()+1,00 say Padc("Account Heads",80)
@prow()+1,00 say "/---------------------------------------------\"
@prow()+1,00 say "|  Ac Head                       | Op.Balance |"
@prow()+1,00 say "|-----------------------------|---------------|"

Sele Account
Go Top
Do while !eof()
       If prow() > 65
             @prow()+1,00 say "\-------------------------------------/"
             EJECT
             @prow()+1,00 say "Company Name"
             @prow()+1,00 say Padc("Account Heads",80)
             @prow()+1,00 say "/---------------------------------------------\"
             @prow()+1,00 say "|  Ac Head                       | Op.Balance |"
             @prow()+1,00 say "|-----------------------------|---------------|"
       Endif

       @prow()+1,00 say "| "+AC_NAME+" | "+str(OP_BALANCE,9,2)+" |"
       Sele AcMaster
       Skip
Enddo
@prow()+1,00 say "\-------------------------------------/"
@prow()+100 say "End of Report"
SetPrc(00,00)
Set Printer to
Set Device to Screen
Set Console On
RptOptions()    // This function gives the choice to the user either to view or print or to save the text file for future ref.


Trying to accomplish similiar task using FWH I wrote code in FWH as given below.

I know that the method used by me is very old and FWH will have much more powerful techniques which can be done in a much better way.

I need your view on this, keeping in mind the following

1) an option for the user to either dump to LPT port for those who need fast printing.
2) Preview of the report
2) Save the report in Text format, excel etc.

How can the same be accomplished using FWH in a much better way.

I also noticed that Prev32.Dll should be there for the Report preview to work.

As a beginner I tried to create a report using FWH, I don't know whether this is the right way or not.

The font is appearing too small. I don't know what is thosr parameters 0,-12 while defining font Define Font oFont "Font Name " Size 0, 13

My FWH code

*---------------------------------------------------*
Function AcPrn()
*---------------------------------------------------*
local oPrn, oFont, oPen
Local nRowStep, nColStep
Local nRecNo
Local nRow := 0, nCol := 0

Sele AcMaster_ACM
nRecNo:=RecNo()


PRINT oPrn NAME "Account Heads" PREVIEW
	if Empty( oPrn:hDC )
		MsgStop("No printers Installed")
		Return nil          // Printer was not installed or ready
	endif
	DEFINE FONT oFont NAME "Courier New" SIZE 0, -12 
*	DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12 OF oPrn
*	DEFINE FONT oFont NAME "Arial" SIZE 0, -10 BOLD OF oPrn

	nRowStep = oPrn:nVertRes() / 65   // We want 65 rows
	nColStep = oPrn:nHorzRes() / 80   // We want 80 cols


*	DEFINE PEN oPen WIDTH  2                        OF oPrn
	oPrn:SetPage(9)  // A4
	oPrn:SetPortrait() //Vertical

	PAGE
		
		nRow:=0; nCol:=0
		oPrn:Say(nRow,nCol,"/-------------------------------\",oFont)
		nRow += nRowStep          
		
		nCol:=0
		oPrn:Say(nRow,nCol,"| AcName                        |",oFont)
		nRow += nRowStep          
		
		nCol:=0
		oPrn:Say(nRow,nCol,"|-------------------------------|",oFont)
		nRow += nRowStep          
		
		
		Sele AcMaster_ACM
		Go Top
		Do While !eof()
		
			if nRow > oPrn:nVertRes() -5
				nCol:=0
				oPrn:Say(nRow,nCol,"\-------------------------------/",oFont)
             ENDPAGE
				PAGE
					nRow:=0; nCol:=0
					oPrn:Say(nRow,nCol,"/-------------------------------\",oFont)
					nRow += nRowStep          
					
					nCol:=0
					oPrn:Say(nRow,nCol,"| AcName                        |",oFont)
					nRow += nRowStep          
					
					nCol:=0
					oPrn:Say(nRow,nCol,"|-------------------------------|",oFont)
					nRow += nRowStep          

			Endif
		
			nCol:=0
			oPrn:Say(nRow,nCol,"| "+NAME+" |",oFont)
			nRow += nRowStep          
			
			Select AcMaster_ACM
			Skip	      
		Enddo
	ENDPAGE
ENDPRINT		
	
      
oFont:End()      // Destroy the font object
Sele AcMaster_ACM
Goto nRecNo
Return nil


Any help will be appreciated

Regards

Anser
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Help : Regarding Reports & Printing using FWH
Posted: Sat Oct 18, 2008 11:56 AM
anserkk wrote:DEFINE FONT oFont NAME "Courier New" SIZE 0, -12


Here you probably forgot "OF oPrn".

EMG
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Mon Oct 20, 2008 05:14 AM
Dear EMG

Here you probably forgot "OF oPrn".


Font OF oPrn solved the problem

Thanks & Regards

Anser
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Mon Oct 20, 2008 05:57 AM

Can any body explain the usage of SIZE while defining a font

For Eg: DEFINE FONT oFont NAME "Courier New" SIZE 0, -12

What is the first parameter and 2nd parameter
Sometime negetive numbers are used in the second parameter 0, -12
sometimes SIZe 8,12

Regards

Anser

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Mon Oct 20, 2008 08:03 AM

Any hint on setting custom page size

For eg: oPrn:SetPage(9) // A4 paper #Define DMPAPER_A4 9

Most of my application users work on DOT Matrix printers

I want to set the page size to be 10x12 inch size and another one 10x15" inch ( size of a standard computer stationery paper here)

Regards

Anser

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Help : Regarding Reports & Printing using FWH
Posted: Mon Oct 20, 2008 08:07 AM
anserkk wrote:Can any body explain the usage of SIZE while defining a font

For Eg: DEFINE FONT oFont NAME "Courier New" SIZE 0, -12

What is the first parameter and 2nd parameter
Sometime negetive numbers are used in the second parameter 0, -12
sometimes SIZe 8,12

Regards

Anser


8, 12 means a font with 8 points width and 12 points height while 0, -12 means a font with 12 points height and appropriate width, if I remember correctly.

EMG
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Mon Oct 20, 2008 08:09 AM
Thankyou EMG

8, 12 means a font with 8 points width and 12 points height while 0, -12 means a font with 12 points height and appropriate width


Regards

Anser
Posts: 223
Joined: Thu Dec 01, 2005 03:34 PM
Help : Regarding Reports & Printing using FWH
Posted: Mon Oct 20, 2008 01:19 PM

Here is an excerpt of the explanation in FiveWin's fwprog.hlp help file (in FWH\MANUAL). In that help file, the following text is found in the section titled "Fivewin Report Engine" (within the section titled "Printing")...

USING FONTS:

You can use any font you want with your reports. This is the way you use them:

First you have to define them with the command DEFINE FONT oFont ....

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

The size (width,height) specs. use different units of measure when printed versus displayed on screen. On screen, the units are pixels, but when printed, the units are font "points". Thus, for printed text, we only use the second size specification (height) to give the point size, leaving the "width" as "0". The point size is given as a negative number, i.e. "10 point" is "-10". Remember that point size for proportionally spaced type is different than "pitch," which is the term often used for non-proportionally spaced "typewriter" type like Courier.

Point size refers to letter height, whereas pitch refers to the number of equal-spaced letters printed per inch. Regular "pica" sized typewriter type is 10 pitch - 10 letters per inch. But represented in point size, this is 12 point -- very confusing because the smaller "elite" typewriter type is 12 pitch - 12 letters per inch, which is 9 point. (With "pitch," the bigger the number, the smaller the font -- just the opposite of how "point" size works.)

Now to add to the confusion, remember that in this Report Engine, we let FiveWin know that we're working with point size instead of pixels by using negative numbers for points (and we must use points instead of pitch for equal-spaced fonts like Courier). In this case, the "-" sign isn't mathematical -- it doesn't mean (as math rules would suggest) that your point size gets smaller as the integer gets bigger. Just the reverse. The bigger the integer, the bigger the point size.

  • Roger
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Tue Oct 21, 2008 04:44 AM

Hello Mr.Roger,

Thank you for the information. My vision on the usage of Fonts on Screen and Printer is getting more clear now.

Regards

Anser

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Tue Oct 21, 2008 04:45 AM

Any hint on setting custom page size

For eg: oPrn:SetPage(9) // A4 paper #Define DMPAPER_A4 9

Most of my application users work on DOT Matrix printers

I want to set the page size to be 10 inch width and 12 inch lenghth size and another one 15 Inch width 12 inch length ( size of a standard computer stationery paper here)

Regards

Anser

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help : Regarding Reports & Printing using FWH
Posted: Tue Oct 21, 2008 06:43 AM

oPrn:setSize( nWidth, nHeight) where the parameters are in tenths of a millimeter.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Help : Regarding Reports & Printing using FWH
Posted: Tue Oct 21, 2008 12:30 PM

Be aware that if you print usinng the printer class or the report engine you'll be printing in graphic mode not text mode. If your user are used to the speed of printing in text mode they might complain as printing in graphics mode is slower.

If you want to print in text mode have a look at tdosprn class.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Tue Oct 21, 2008 12:36 PM

Dear Hua,

Thankyou for the information about TDosPrn class

For certain reports (not all) My requirements are

1) DOS mode Printing ( not in Graphics mode, so that more speed in printing )
2) Preview of the Report
3) Provision to save the report as Text file. ( Would live to have saving in other formats like Excel or OpenOffice )

Regards

Anser

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Help : Regarding Reports & Printing using FWH
Posted: Tue Oct 21, 2008 12:48 PM
Thankyou Mr.James,

oPrn:setSize( nWidth, nHeight) where the parameters are in tenths of a millimeter.


Regards

Anser

Continue the discussion