473,461 Members | 1,501 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
Nov 22 '05 #1
0 990

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

Similar topics

19
by: dcrespo | last post by:
Hi all... Is there a way to print a PDF file directly from Python without having Acrobat installed? I know about ReportLab. It's a python module that lets you create almost any PDF document, but I...
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...
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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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: 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.