Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1035437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:32:32+00:00 2026-05-16T14:32:32+00:00

I’m creating a simple WPF print dialog box to setup a label printer. I

  • 0

I’m creating a simple WPF print dialog box to setup a label printer. I want it to be very simple and so I’ve choosen not to use the standard WPF printdialog.

All is going well accept for one thing, paper sizes.

Having selected a printer from one combobox, a second combobox is populated with the paper sizes available from that device. I’m currently using selectedPrinter.GetPrintCapabilities.PageMediaSizeCapability and setting that as itemssource of the combobox.

However, my main issues with this are:

It seems to only get a subset of the available paper sizes (compared to the normal print dialog)

No way to add custom sizes since PageMediaSize is not inheritable and the constructor only allows you to use the PageMediaSizeName Enum

and

The only name I can display is the Enum text by binding the diplaypath to PageMediaSizeName, which is not particularly user friendly.

What I have also found is that if I dump selectedPrinter.GetPrintCapabilitiesAsXml to a file and look at that, I get everything I need; all the availble the paper sizes of the printer each with sizes and importantly a display name element.

My question is, am I missing something with selectedPrinter.GetPrintCapabilities or do I need to create a parser for selectedPrinter.GetPrintCapabilitiesAsXml and use this info instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:32:32+00:00Added an answer on May 16, 2026 at 2:32 pm

    I ended up creating my own PaperSize class (below) and I use this command

    PaperSize.ParsePaperSizeXML(New Xml.XmlTextReader(selectPrinter.GetPrintCapabilitiesAsXml))
    

    to retrieve the printer’s available paper sizes as a bindinglist (selectedPrinter is a instance of the Printing.PrintQueue class)

    Public Class PaperSize
    
        Const FEATURENODE As String = "psf:Feature"
        Const PAPERSIZEATTRIBUTE As String = "psk:PageMediaSize"
        Const PAPEROPTIONNODE As String = "psf:Option"
        Const SCOREDPROPERTYNODE As String = "psf:ScoredProperty"
        Const WIDTHATTRIBUTE As String = "psk:MediaSizeWidth"
        Const HEIGHTATTRIBUTE As String = "psk:MediaSizeHeight"
        Const VALUENODE As String = "psf:Value"
        Const PROPERTNODE As String = "psf:Property"
        Const DISPLAYNAMEATTRIBUTE As String = "psk:DisplayName"
        Const NAMEATTRIBUTE As String = "name"
    
        Public Sub New()
    
        End Sub
    
        Public Sub New(ByVal PaperKey As String, ByVal PaperDisplayName As String)
            DisplayName = PaperDisplayName
            Width = Nothing
            Height = Nothing
        End Sub
    
        Public Sub New(ByVal PaperKey As String, ByVal PaperDisplayName As String, ByVal PaperWidth As Double?, ByVal PaperHeight As Double?)
            Key = PaperKey
            DisplayName = PaperDisplayName
            Width = PaperWidth
            Height = PaperHeight
        End Sub
    
        Property Key As String
        Property DisplayName As String
        Property Width As Double?
        Property Height As Double?
    
    
        Public ReadOnly Property WidthInMM As Double?
            Get
                If Width.HasValue Then
                    Return WidthInInches * 25.4
                Else
                    Return Nothing
                End If
    
            End Get
        End Property
    
        Public ReadOnly Property HeightInMM As Double?
            Get
                If Height.HasValue Then
                    Return HeightInInches * 25.4
                Else
                    Return Nothing
                End If
    
    
            End Get
        End Property
    
        Public ReadOnly Property WidthInInches As Double?
            Get
                If Width.HasValue Then
                    Return Width / 96
                Else
                    Return Nothing
                End If
            End Get
        End Property
    
        Public ReadOnly Property HeightInInches As Double?
            Get
                If Height.HasValue Then
                    Return Height / 96
                Else
                    Return Nothing
                End If
            End Get
        End Property
    
        Public Shared Function ParsePaperSizeXML(ByVal XmlString As Xml.XmlReader) As ComponentModel.BindingList(Of PaperSize)
    
            Dim lstPaperSizes As New ComponentModel.BindingList(Of PaperSize)
    
            Try
    
                While XmlString.Read()
    
                    If XmlString.NodeType = Xml.XmlNodeType.Element Then
                        Select Case XmlString.Name
                            Case FEATURENODE
                                If XmlString.AttributeCount = 1 Then
                                    Select Case XmlString.GetAttribute(NAMEATTRIBUTE)
                                        Case PAPERSIZEATTRIBUTE
                                            lstPaperSizes = processAllPaperSizes(XmlString.ReadSubtree)
                                    End Select
                                End If
                        End Select
    
                    End If
    
                End While
    
            Catch ex As Exception
                Throw ex
            End Try
    
            Return lstPaperSizes
    
        End Function
    
        Private Shared Function processAllPaperSizes(ByVal PaperSizeXmlString As Xml.XmlReader) As ComponentModel.BindingList(Of PaperSize)
            Dim lstPaperSizes As New ComponentModel.BindingList(Of PaperSize)
            Dim currentKey As String
    
            Try
    
                While PaperSizeXmlString.Read()
    
                    If PaperSizeXmlString.NodeType = Xml.XmlNodeType.Element Then
                        Select Case PaperSizeXmlString.Name
                            Case PAPEROPTIONNODE
                                currentKey = PaperSizeXmlString.GetAttribute(NAMEATTRIBUTE)
    
                                lstPaperSizes.Add(processPaperSize(currentKey, PaperSizeXmlString.ReadSubtree))
    
                        End Select
    
                    End If
    
                End While
    
            Catch ex As Exception
                Throw ex
            End Try
            Return lstPaperSizes
        End Function
    
        Private Shared Function processPaperSize(ByVal currentPaperKey As String, ByVal PaperSizeXmlString As Xml.XmlReader) As PaperSize
    
            Dim currentWidth, currentHeight As Double?
            Dim currentName As String = String.Empty
            Dim stringwidth, stringheight As String
    
            Try
    
                While PaperSizeXmlString.Read()
    
                    If PaperSizeXmlString.NodeType = Xml.XmlNodeType.Element Then
                        Select Case PaperSizeXmlString.Name
                            Case SCOREDPROPERTYNODE
    
                                If PaperSizeXmlString.AttributeCount = 1 Then
                                    Select Case PaperSizeXmlString.GetAttribute(NAMEATTRIBUTE)
                                        Case WIDTHATTRIBUTE
                                            stringwidth = processPaperValue(PaperSizeXmlString.ReadSubtree)
                                            If String.IsNullOrEmpty(stringwidth) Then
                                                currentWidth = Nothing
                                            Else
                                                currentWidth = MasterWPFUtils.MMToDPI(CDbl(stringwidth)) / 1000
                                            End If
    
                                        Case HEIGHTATTRIBUTE
                                            stringheight = processPaperValue(PaperSizeXmlString.ReadSubtree)
                                            If String.IsNullOrEmpty(stringheight) Then
                                                currentHeight = Nothing
                                            Else
                                                currentHeight = MasterWPFUtils.MMToDPI(CDbl(stringheight)) / 1000
                                            End If
                                    End Select
                                End If
                            Case PROPERTNODE
                                If PaperSizeXmlString.AttributeCount = 1 Then
                                    Select Case PaperSizeXmlString.GetAttribute(NAMEATTRIBUTE)
                                        Case DISPLAYNAMEATTRIBUTE
                                            currentName = processPaperValue(PaperSizeXmlString.ReadSubtree)
                                    End Select
                                End If
                        End Select
    
                    End If
    
                End While
                Return New PaperSize(currentPaperKey, currentName, currentWidth, currentHeight)
            Catch ex As Exception
                Throw ex
            End Try
    
        End Function
    
        Private Shared Function processPaperValue(ByVal valueXmlString As Xml.XmlReader) As String
            Try
    
                While valueXmlString.Read()
    
                    If valueXmlString.NodeType = Xml.XmlNodeType.Element Then
                        Select Case valueXmlString.Name
                            Case VALUENODE
                                Return valueXmlString.ReadElementContentAsString.Trim
                        End Select
                    End If
                End While
            Catch ex As Exception
                Throw ex
            End Try
    
            Return String.Empty
        End Function
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.