473,322 Members | 1,755 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.

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 11385
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: 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...
1
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: 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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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

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.