Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleSee if a printer is a PostScript printer
Keywordsprinter, PostScript
CategoriesGraphics
 
This code determines whether the current printer is a PostScript printer.
 
' Return True if this is a PostScript printer.
Private Function PrinterIsPostScript() As Boolean
Dim escape As Long
Dim technology As String

    ' See if the printer is using the generic
    ' PostScript driver.
    If LCase$(Printer.DriverName) = "pscript" Then
        PrinterIsPostScript = True
        Exit Function
    End If

    ' See if it supports POSTSCRIPT_PASSTHROUGH.
    escape = POSTSCRIPT_PASSTHROUGH
    If ExtEscape(Printer.hdc, QUERYESCSUPPORT, _
        Len(escape), escape, 0, ByVal 0&) > 0 _
    Then
        ' It supports POSTSCRIPT_PASSTHROUGH.
        ' It's a PostScript printer.
        PrinterIsPostScript = True
        Exit Function
    End If
    
    ' See if it supports GETTECHNOLOGY.
    escape = GETTECHNOLOGY
    If ExtEscape(Printer.hdc, QUERYESCSUPPORT, _
        Len(escape), escape, 0, ByVal 0&) <= 0 _
    Then
        ' It doesn't support GETTECHNOLOGY.
        ' We cannot tell so assume it's not a
        ' PostScript printer.
        PrinterIsPostScript = False
        Exit Function
    End If

    ' Get the technology string.
    'and check to see if the word "postscript" is in it.
    technology = Space$(MAX_PATH + 1)
    If ExtEscape(Printer.hdc, GETTECHNOLOGY, _
        0, ByVal 0&, MAX_PATH, GETTECHNOLOGY) <= 0 _
    Then
        ' We didn't get a value.
        ' Assume it's not a PostScript printer.
        PrinterIsPostScript = False
        Exit Function
    End If

    ' See if the technology string contains the
    ' word PostScript.
    technology = LCase$(Left$(technology, InStr(technology, _
        vbNullChar)))
    PrinterIsPostScript = InStr(technology, "postscript") > _
        0
End Function
 
Most of this code (the part after the driver test) is from the MSDN. Unfortunately that code cannot tell my ancient PostScript printer uses PostScript so I added the driver test.

Please try this out on your printer and let me know if it works for you.

 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated