new page in C#

G

G.Esmeijer

Friends,
Coming from VB6 i have problems finding the right methods for printing.
ending a line of text to the printer seems to ask a lot of code in c# while
it was relatiely easy in vb.

How do I in c# :
- Enddoc
- empty line
- endpage
- newPage

Are there any good examples. Maybe a collection of functions, may a class
that has all the goodies in it to do the normal straight forwad printing
stuff.

Hope tat someone can help me

Thanks in advance.

gerrit Esmeijer
 
G

Guest

This link has several articles about printing. It will surely get you started.
http://www.c-sharpcorner.com/Printing.asp

When I had an application that required printing I quickly found out that in .NET you loose a lot of control over printing. I'd love to see an example on how to print just one line at a time to a printer without having to print the entire page.

Enter a piece of data and have that data spit to the printer and then have the printer happily wait for the next piece of data. When say... 55 lines have printed then start a new page. From what I can tell you have to dig down into the Win32 API to make this happen.
 
D

David Totzke (.NET/C# MVP)

Friends,
Coming from VB6 i have problems finding the right methods for
printing. ending a line of text to the printer seems to ask a lot of
code in c# while it was relatiely easy in vb.

How do I in c# :
- Enddoc
- empty line
- endpage
- newPage

Are there any good examples. Maybe a collection of functions, may a
class that has all the goodies in it to do the normal straight forwad
printing stuff.

Hope tat someone can help me

Thanks in advance.

Rockford Lhotka has two great articles on MSDN in his Adventures in
Visual Basic column. In them, he explores printing and previewing in
the .NET Framework using VB.NET. It should be pretty straight forward
to convert to C#.

Search for The Power of Print and Generating Reports in the .NET
Framework in the MSDN Library.

Dave
 
R

Ron Allen

Petzold's books Program Windows with C# (VB.NET) have printing examples
showing the basics. You will se a lot of discussion on printing in the
archives of microsoft.public.dotnet.framework.drawing.

Printing is done via a PrintDocument subclass or by just adding an
OnPrintPage handler to the base class.
Basically EndDoc is when you return from the last OnPrintPage call with
HasMorePages = false.
Empty line is done by simply advancing the y coordinate by the linespacing
value.
End Page is when you return from OnPrintPage and NewPage is when
HasMorePages = true at this time.

This is much like printing in the older versions of C++ using a hDC used to
be. You just go to locations on the page and draw things there.

Ron Allen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top