Re: Print multiple copies
The standard way of preparing data for printing is in a report, printing a screen shot of a form seems like a bit of a hack.
rdlc reporting comes with VS standard, if just using express, there are a some free options:
http://www.fast-report.com/en/downlo...-download.html
http://www.gotreportviewer.com/
HTH
Re: Print multiple copies
I have to kinda agree with enrico. If all you were doing is making a screenshot of the form then making use of the printform would be much easier than what you're doing. In fact it's just printform1.print(). As for printing in .net I would do a search in the codebank for a person by the name of Merrion. He is like the forum's .net-printing-guru! Actually, Imma make it easy and post a link... Here :]
Re: Print multiple copies
I need the form that comes up to be exactly like a 4x7 or a 3x5 index card. So the person using it can see if all of the ingredients and the text process will fit on the card. I have .Net Express so not sure if reporting is in it. but the main thread that shows this code is from .paul. and listed here
http://www.vbforums.com/showthread.php?t=641994
using printform also prints the title bar and the forms border.
Re: Print multiple copies
Quote:
Originally Posted by
enrico1982
The standard way of preparing data for printing is in a report
The "standard" way to print from a .NET application is using a PrintDocument. Using a report is "cheating" by getting someone else to handle the actual printing for you. The RDLC format you speak of is SQL Server Reporting Services.
The PrintDocument has a PrinterSettings property of type PrinterSettings. The PrinterSettings class has a Copies property, which is the number of copies of the output that you want to print.
This:
Code:
Dim dpiX As Integer = CInt(Me.CreateGraphics().DpiX)
Dim dpiY As Integer = CInt(Me.CreateGraphics().DpiY)
is very, very bad. You should never do something like create two Graphics objects when you only need one. In situations like this, you should be assigning the result of the method to a variable and then using the variable multiple times. You should always be disposing objects that support it too, and the Graphics class supports it. The proper way to do that would be:
Code:
Dim dpiX As Integer
Dim dpiY As Integer
Using g = Me.CreateGraphics()
dpiX = CInt(g.DpiX)
dpiY = CInt(g.DpiY)
End Using
Re: Print multiple copies
thanks jmcilhinney, but it doesn't solve my problem. By default it should only print once, but certain times they may want 2 copies. Without giving the user a choice I would just like to print it once. but if you click print again right after you print it doesn't print correctly. closing the form and re-opening it will allow you to print again.
But I am open to suggestions. If there is a better way to print just the text the user sees and not the whole form, title and border, then I would like to do that.
In vb6 I did use printform and it worked great, but .net prints the whole form, title and border and everything, I can't use that.
Re: Print multiple copies
If it's not printing properly the second time then there's something wrong with your code. Have you debugged it to see what that might be? That's how you find and fix bugs in your code. Obviously there is something left over from the first print run that is affecting the second. You need to find out what it is and make sure that it doesn't happen.
As for not printing the whole form, the way to not do it is to not do it. In the PrintPage event you can draw whatever you want. You are creating a Bitmap containing a direct visual representation of the form and drawing that, so that's what gets printed. If that's not what you want then don't do it. If you just want the words "Hello World" printed then you call DrawString and pass that String as an argument. It's up to you to decide what you want printed and to draw that and only that.
Re: Print multiple copies
so are you saying I should use printform and not printdocument?
Re: Print multiple copies
I went with printform again and although I must say I finally got it to print how I want, problem is its a little blurry when it comes out of the printer? anyway to adjust that? Even PrintPreview is blurry
jmcilhinney:
Of course if I don't want it to print like that don't code it to do that, thats is so obvious, but if a person doesn't know it is wrong they will not know how to fix it. You say use printform and you can control what it prints. Same with this, if you don't know anything about ClientAreOnly option then you wouldn't know to look for it. So saying "if you don't want it, don't code" it doesn't help anybody and makes the OP frustrated. I looked at the PrintForm page on msdn and it is not obvious that you can use options like that. I understand not writing it for them, makes perfect sense, but giving them the ideas to know what to look for is a lot better than telling them to don't code it if you don't want it to do it.