473,466 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Printing to Legal Paper through windows application

Greetings,

I have code which prints a document who's attributes are saved as
flags in a database. One of the those attributes is letter or legal.
When I am printing, I use the following code, which is the ONLY way I
could come up with to reliably print to legal paper, assuming a
default of letter. There HAS to be a better way. I'm having to
loop through all paper options on the remote server's printer, until I
find the one that corresponds to legal or letter. The problem is that
this looping on a remote (networked) server is very SLOW!!!! I need
like a one line solution that doesn't require me to loop through
remote server's printer settings.

Any thoughts about how I could optimize the selection of the legal
papersize?

p = New PrintDocument

''call print page event handler
AddHandler p.PrintPage, AddressOf pd_printpage

''name the printing service (que)
p.DocumentName = "GIB Non-System Document " & strItem

With p.DefaultPageSettings.Margins
.Top = 40
.Bottom = 40
.Left = 40
.Right = 40
End With

''which printer
p.PrinterSettings.PrinterName = "\\civility\" &
strPrinterName
'paper size
Select Case strSize
Case "1"
'legal
For i = 0 To p.PrinterSettings.PaperSizes.Count -
1
pkSize = p.PrinterSettings.PaperSizes.Item(i)
If pkSize.Kind = PaperKind.Legal Then
p.DefaultPageSettings.PaperSize =
p.PrinterSettings.PaperSizes.Item(i)
End If
Next

Case "0"
'letter
For i = 0 To p.PrinterSettings.PaperSizes.Count -
1
pkSize = p.PrinterSettings.PaperSizes.Item(i)
If pkSize.Kind = PaperKind.Letter Then
p.DefaultPageSettings.PaperSize =
p.PrinterSettings.PaperSizes.Item(i)

End If
Next

End Select

Try
p.Print() ' - raises printpage event
David Fields
Jul 21 '05 #1
0 1248

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: VMI | last post by:
I have a BMP image (the form is also in PDF) that contains a scanned copy of a paper form that we need to fill out. Is it possible to use this image in my application so that the application can...
2
by: Jurjen de Groot | last post by:
I'm about to start a new ASP.NET application, this application will generate several types of documents (PDF HTML XML-DOC) wich have to be printed at the client-side... (probably on different...
5
by: Tom | last post by:
I am converting an old application that was printing directly to a specialized printer device (i.e. a special label printer). It was doing this by opening a file with the file path of 'LPT1:' and...
0
by: mykidisgollum | last post by:
Greetings, I have code which prints a document who's attributes are saved as flags in a database. One of the those attributes is letter or legal. When I am printing, I use the following...
4
by: sachin | last post by:
Hi I am working on report using print preview dialog control in windows application. Report is displayed properly in control. With paper size 850X1350 (Legal)(Lanscape mode=true) . But when...
8
by: Steve Macleod | last post by:
Hi, I was wondering if anyone had a solution for printing HTML elements (especially style elements). I do not wish to make any changes to the page, other than in the <css media="print"block. I can...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
9
by: Gurbinder Kaur | last post by:
Hi, i have made a project for printing fee receipt. Using Windows-XP, VBasic 6.0 & Ms-Access-97. i have designed a form for prinring receipts. m paper-size is 5x10. Two copies of bills in this...
1
by: gowens | last post by:
I'm definitely not a MS Access expert (more a real novice..) I have a report that I inherited for support. The user is complaining that when the report is printed - it prints on legal-sized paper...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.