Link to home
Start Free TrialLog in
Avatar of Arvindtn
Arvindtn

asked on

Printing ?

Hi Friends,

   I have table called tbPrintDesign and tbLine. The structure of the table is as follows

tbLine
_______

  * LineNumber
  * Data To Print  // what data should be printed in that Line Number.

tbPrintDesign
_____________

  * LineNumber
  * LinesPerInch ( LPI )
  * CharacterPerInch ( CPI )
  * LayoutOfData

 I have to get the data from tbLine table, it's respective layout( How to print ) from tbPrintDesign table and show a preview to the end user. If the user says print it should print the document. Please Note : I cannot use Microsoft Word.

 

Avatar of mark2150
mark2150

Ok, from what I gather you're trying to make a dynamic data printer. You've got a definition table and live data tables.

The printer in VB can be treated as a plotter. If you set the .Scale property you can define the print region in units of your choosing. LPI and CPI don't have direct meaning. You can position the print cursor using .PrinterX/Y. When you want to move down to a new line simply add the spacing from the LPI to the .PrinterY like this:

LPISpace = 1 / LPI
OldY = Printer.CurrentY
Printer.Print "This is some text"
Printer.CurrentY = OldY + LPISpace

CPI really has little meaning when you're using proportionally spaced fonts. You either have to use Courier or some other mono-spaced font or you can determine the space that a specific text object needs by using the .TextWidth or .TextHeight properties.

Now I don't know if you're having data extraction issues as well, but this should get you headed in the right direction as far as printing goes.

M

Use Crystal Reports.
Avatar of Arvindtn

ASKER

i want to do it without crystal reports
Ok, so follow my example and generate your own report. Set up the printer's .scale and you can position yourself with .CurrentX/Y and print text with Printer.Print RS!Field.

If you need to, say, center a line of text then you can use the .TextWidth property to find out how wide your text is:

Txt = trim( "" & RS!SomeField )
Printer.CurrentX = ColumnN - (Printer.TextWidth(Txt) / 2)
Printer.Print Txt

For Right justified, simply leave off the "/ 2"

Use .Line to draw lines and boxes. All will be denominated in units you've set when you set the .Scale property.

If you need additional pages you can generate them with .Page and you can watch the .CurrentY to tell when you're getting near the bottom of the page.

Finally end the report with .EndDoc

M

How will i show the preview then Mark, Will it work in a LinePrinter. Because iam trying it in a Laser printer but the client will use Line Printer Only.
Also is there any method to find whether the printer is ON / OFF, Paper is present in the Printer, etc. The Printer could either be on a Network or directly connected to my machine.

 
ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your hints Mark, You gave me a path to approach the problem. Iam giving you the points only for that.

I had one problem which i had sorted out. The problem was in assigning Height and Width to a font. I did that using CreateFont().


I had solved the problem and it is working perfectly. I thank everybody for trying to help me out.

Bye
Arvind

Always glad to help.

M