473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how to creat and print multi page document

I have been tring to recreate a simple program that I wrote many years ago in quick basic. The program get name and address from a database, then the user will enter in info like order #, po # and starting box then number of boxes.

In quick basic it was easy to send a form feed and print the next label. But this visual basic .net stuff has me pulling my hair out. I can print all the info to desired printer. But do not understand how to created a multi page document to send. I could have it loop through all the box numbers and call the print routine multiply time but This would send many seperate print jobs.
I will paste code below (it's not pretty) I'll start with the print button code and then jump to the class it is calling to.

Hope someone can make sense of this and maybe even help me,
David DeWitt

/CODE/

Public Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

Dim Print As New myPrinter
Call Print.prt()

End Sub


Public Class myPrinter


Public Sub prt()

Dim prn As New Drawing.Printing.PrintDocument
Using (prn)
prn.PrinterSettings.PrinterName = My.Settings.Printer
AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler
prn.Print()
RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler
End Using
End Sub

Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Drawing.Printing.PrintPageEventArgs)
Dim smFont As New Font("Microsoft San Serif", 10)
Dim medFont As New Font("Microsoft San Serif", 14)
Dim lrgFont As New Font("Microsoft San Serif", 18)
Dim startlbl As Integer = MainForm.txtStartBoxNUmber.Text
Dim endlbl As Integer = MainForm.txtStartBoxNUmber.Text + MainForm.txtBoxes.Text

Do Until startlbl = endlbl

' return address
args.Graphics.DrawImage(My.Resources.LOGO_2, 60, 10)
args.Graphics.DrawString(My.Settings.returnAddress , New Font(smFont, FontStyle.Regular), Brushes.Black, 117, 70)
args.Graphics.DrawString(My.Settings.returnCity, New Font(smFont, FontStyle.Regular), Brushes.Black, 110, 85)
' ship to address
args.Graphics.DrawString("Ship to:", New Font(medFont, FontStyle.Bold), Brushes.Black, 5, 150)
args.Graphics.DrawString(MainForm.txtCompanyName.T ext, New Font(lrgFont, FontStyle.Bold), Brushes.Black, 30, 175)
args.Graphics.DrawString(MainForm.txtAttn.Text, New Font(medFont, FontStyle.Regular), Brushes.Black, 30, 210)
args.Graphics.DrawString(MainForm.txtAddress1.Text , New Font(medFont, FontStyle.Regular), Brushes.Black, 30, 235)
args.Graphics.DrawString(MainForm.txtAddress2.Text , New Font(medFont, FontStyle.Regular), Brushes.Black, 30, 260)
args.Graphics.DrawString(MainForm.txtCity.Text & ", " & MainForm.txtState.Text & " " & MainForm.txtZip.Text, New Font(medFont, FontStyle.Regular), Brushes.Black, 30, 285)
' Package & Order information
args.Graphics.DrawString("P.O. #" & MainForm.txtPO.Text, New Font(smFont, FontStyle.Bold), Brushes.Black, 30, 370)
args.Graphics.DrawString("Order #" & MainForm.txtOrderNumber.Text, New Font(smFont, FontStyle.Bold), Brushes.Black, 30, 390)
args.Graphics.DrawString("Box #" & startlbl, New Font(smFont, FontStyle.Bold), Brushes.Black, 30, 410)
startlbl = startlbl + 1
args.HasMorePages = True

Loop
args.HasMorePages = False

End Sub
End Class

/CODE/
Dec 10 '06 #1
1 2338
Killer42
8,435 Expert 8TB
Sorry to see you're not getting any response here in the VB forum. You might try posting your question in the .NET forum, to see whether anyone over there can help.
Dec 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Steel | last post by:
Hi at all, I have a very long html page with many photo. Therefore the best to print this page is to print the some page as PDF. Therefore I maked a PDF file like my page to print best. I'ld want...
1
by: Alex | last post by:
I need to duplicate some of the multi-page tiff and thumbnail viewing functionality found in the Microsoft Office Document Imaging application for an in-house company application. Does anyone...
9
by: trint | last post by:
Instead of just sending one document at a time, I need to send multiple documents as a print job because our laserprinter will only stack and staple one printjob it receives at a time. I need to...
0
by: magic man | last post by:
I have written an application in VB.Net using server side controls. I realize that I need client side controls to print anything at the clients computer. I have a web page that consists of a 1...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
6
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page...
4
by: DeWittds | last post by:
Had no luck in the visual basic group maybe someone here can give me a hand. I have been tring to recreate a simple program that I wrote many years ago in quick basic. The program get name and...
2
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I am trying to offer "Print" functionality using an HTML button with the help of "window.print()" This button works fine in Firefox but not in IE7. I am dumping the entire content...
0
by: Jason7899 | last post by:
hi, i use the crystal report for creat reports and print all that i want in vb or vb.net now i looking for a such like crystal report for use in php or html all data is retrieve from a mysql...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.