p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Visual Basic 2005 Basics (http://p2p.wrox.com/forumdisplay.php?f=137)
-   -   Printing in VB 2005 (http://p2p.wrox.com/showthread.php?t=43819)

BroadwayLion June 11th, 2006 03:02 PM

Printing in VB 2005
 
Printing seems to be more difficult in VB 2005 than in VB6. In VB6 I made a module that I used in several programs, it would pass information directly to the print spooler:

prntxt(Data$,Font,Size,Attribute,xLoc,yLoc) were supplied, line after line until the page was complete, and then an end document command sent it to the printer, and the document would print at that time.

These new naming conventions, and the print.document object seem to be a little over my head, but this is the protocol that I need for the projects that I build.

Can anybody point me to a resource that will help me to use the printer.

Thanks,

Elias


K S Beale July 25th, 2006 10:05 AM

May I suggest you look at the help files for "Walkthrough: Creating a ReportViewer Report". This will allow you to access any database and generate a report.


charkins August 27th, 2006 11:40 PM

I could not find report template under Project ->Add New Item. Any ideas?
Thanks
Cal


Cal

Ankur_Verma August 29th, 2006 11:10 AM

Hi Elias,

Compact it may not be and it does seem like too much work but
printing in VB2005 is much niftier.

Read this article
http://msdn2.microsoft.com/en-us/library/9s96f6ft.aspx

You can get a printing sample at this link
http://msdn2.microsoft.com/en-us/library/54z247f9.aspx

Regards
Ankur

fdagroup January 17th, 2008 09:34 AM

Hi, I am developing a report to be printed with PrintDocument class.The problem is some parts of this report are iterated and some not.In fact report consist of three sections.The top and buttom sections are always the same but middle section is being produced from Database.The problem is how to print more than one page, I tried to use HasMorePages but somehow I think I am doing something wrong.



I need to :

1-Print top and buttom sections more than one time if the data in middle section won't fit in its specified area.

2-Be able to access each new page, if possible.That way I can repeat itereated sections and write down the continued middle section.

3-Control the behaviour of HasMorePages in order to print middle section succefully.



Since this development is company-based the code I am gonna attach is protected.It cannot be used , distributed and altered under any circumstances.I am using the following code.






Code Block

While (intLastPrintedCell < strText.GetUpperBound(0))

e.HasMorePages = True

If Not intLastPrintedCell > 0 Then

Dim intDistance As Integer = 0

For i As Integer = strText.GetLowerBound(0) To strText.GetUpperBound(0)

If intDistance <= intSplit2Distance Then

text = strText(i)

If chkShowTextInBox.Checked = True Then

e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))

End If

rec.X = rea("FLEFT")

rec.Y = rea("FTOP") + intSplit1Distance + intDistance

rec.Height = rea("FHEIGHT")

rec.Width = rea("FWIDTH")

e.Graphics.DrawString(text, printFont, brsh, rec, frmt)

intDistance = intDistance + rec.Height + intFieldDistance

'e.HasMorePages = False

intLastPrintedCell = i

Else

'intLastPrintedCell = i

Exit For

'

End If

Next

Else

Dim intDistance As Integer = 0

For i As Integer = intLastPrintedCell To strText.GetUpperBound(0)

If intDistance < intSplit2Distance Then

text = strText(i)

If chkShowTextInBox.Checked = True Then

e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))

End If

rec.X = rea("FLEFT")

rec.Y = rea("FTOP") + intSplit1Distance + intDistance

rec.Height = rea("FHEIGHT")

rec.Width = rea("FWIDTH")

e.Graphics.DrawString(text, printFont, brsh, rec, frmt)

intDistance = intDistance + rec.Height + intFieldDistance

'e.HasMorePages = False

intLastPrintedCell = i

Else

'e.HasMorePages = True

'intLastPrintedCell = i + 1

'

End If

Next

End If

End While

e.HasMorePages = False





I'd apperciate any help.If you have more information about the code contact me directly.



Remember!This code snippet is protected by international laws.



fdagroup January 24th, 2008 11:45 AM

Hey everyone, me again.Does anyone know how to print to a file? I mean like after finished working with PrintPageEventArgs graphics, save that out put to a file.


Ankur_Verma February 19th, 2008 11:22 AM

Here is a hint, just search around a bit on PrintToFile and how to use it :)

Regards
Ankur

Ankur_Verma February 19th, 2008 11:28 AM

As an aside, if you were printing in VB6 you would assign this flag to Printer class's PrintAction property. VB 2005 is backward compatible for most purposes and if it aint for some, you always have VB6 namespace at your disposal.

Regards
Ankur


All times are GMT -4. The time now is 08:54 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.