473,387 Members | 1,785 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,387 software developers and data experts.

Get Available Paper Sizes for Installed Printers

I'm writing a batch printing app that will interface with other
applications to print their native documents. All of the documents will
be printed on the same size paper.

On the main form, where the files are selected, are two comboboxes, one
for the user to select the printer, the other for the user to select
the paper size. Does anyone know how I can get the paper size for a
given printer? I can get a list of paper sizes using this code:

Dim objPrint As New System.Drawing.Printing.PrinterSettings
Dim strPrinters As String
Dim printerformat As System.Drawing.Printing.PaperSize

For Each printer As String In objPrint.InstalledPrinters

Dim PrinterObj As New
System.Drawing.Printing.PrinterSettings
PrinterObj.PrinterName = printer
For Each printerformat In PrinterObj.PaperSizes()

Try

Me.cboPaperSizes.Items.Add(printerformat.PaperName )
Catch ex As Exception

End Try

Next
Next
but it returns some paper sizes that I can't even use for that printer
(for exmaple 11X17 when the printer only prints 8.5X11 max). Does
anyone know how I can get ONLY paper sizes that the printer can print?

Thanks.

- Luther

Nov 21 '05 #1
1 11418
OK folks. Sorry for the mistake. These calls work fine. The problem is
that I wasn't testing each printer against the printer name so I was
getting paper sizes for every printer installed on my machine instead
of the one that was selected. The code should look like:

Private Sub cboPrinters_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboPrinters.SelectedIndexChanged

Me.Cursor = Cursors.WaitCursor

If Not sender.text = "" Then
Me.cboPaperSizes.Visible = True
Me.cboPaperSizes.Items.Clear()

Dim objPrint As New System.Drawing.Printing.PrinterSettings
Dim strPrinters As String
Dim printerformat As System.Drawing.Printing.PaperSize

For Each printer As String In objPrint.InstalledPrinters

If printer = sender.text Then

Dim PrinterObj As New
System.Drawing.Printing.PrinterSettings
PrinterObj.PrinterName = printer
For Each printerformat In PrinterObj.PaperSizes()

Try
Me.cboPaperSizes.Items.Add(printerformat.PaperName )

Catch ex As Exception

End Try

Next
End If
Next

End If

Me.Cursor = Cursors.Default

End Sub

Nov 21 '05 #2

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

Similar topics

0
by: Carlos Kirkconnell | last post by:
Hi guys this is the second time I place my question here, so I spect that at least SOMEBODY takes his time for reading it. Well, my problem is: I have an application that needs to dynamically...
1
by: Tumzadoc | last post by:
Hi I'm writing a software that prints receipts using a thermal printer. I don't want my user to set up the paper source i want to do it in my code, how do i do that? Much Luv Tumzadoc
1
by: JC Mugs | last post by:
Does anyone know how to set user defined paper sizes for and Epson LQ570E Printer under Windows XP Prof? The driver does not allow for user defined paper sizes.. So setting them from a report...
5
by: Ira S | last post by:
I use a DYMO labelwriter with my Access 97 database. I just purchased a new computer and in the report section under page setup/paper size, the new computer keeps changing the size automatically. I...
1
by: Bruce Wood | last post by:
I'm having a devil of a time calling DeviceCapabilities() in order to get the list of paper names / codes / sizes for a printer. Here is my code and the input it produces: static extern Int32...
0
by: Keith Wilson | last post by:
Hello all, not sure if this has been posted before but all similar posts never seem to get anywhere. I need to programmatically (vb.net) create a custom paper size for a specified printer...
13
by: matt | last post by:
hello, im guessing the answer is "no", but can a webpage set the printer's paper size & layout? trying to spare my intranet users some extra steps. thanks, matt
6
by: Brewtzaff | last post by:
Hello, I have a little problem to print my reports on custom sized paper. I got a db containing clubmembers, a query which selects only the needed infos to print out my membershipcards. My...
23
by: Al Grant | last post by:
I have a 'printable' button to generate printable output and want this to use A3 if available, irrespective of the user's default printer setting. Is there any way to set a page's preferred...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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...

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.