locked
XPS Printing, Tray selection and InputBinCapability (InputBin) = Problem

    Question



  • Hi all, thanks for taking some time to read this.  I really hope that someone can give me a push in the right direction.

    Basically, when I print an XPS document I want to be able to select the papertray on a page by page basis.

    For example:  My document contains 2 pages.  The first page is a letter, and the second page is a cheque.  I want to load my printer with plain paper in tray 1, and cheque paper in tray 2.  When I send the XPS document to print the first page should be printed on paper from tray 1, and the second page should come from page 2.

    Currently, I have the following code:

    Dim oprintCapabilites As System.Printing.PrintCapabilities = myPrintQueue.GetPrintCapabilities()
     
     Dim value As System.Collections.ObjectModel.ReadOnlyCollection(Of System.Printing.InputBin)

    value = oprintCapabilites.InputBinCapability

    value at this stage now contains two values:
    (0) Autoselect{1}
    (5) Manual{5}

    From my understanding (and there is a good chance I am wrong!!!), the .InputBinCapability should be returning a list of all the available paper trays.  We have 3 trays to pick from our printer, so should I not be getting a return with 4 values?
    1. auto select
    2. Tray 1
    3. Tray 2
    4. Manual feed

    or am I looking in the wrong place?

    When I select AutoSelect, the document is printed from the default tray and when I select manual the printer display asks the user to insert paper into the manual feed.  So this tell me that I am changing the correct settings.  How do I find out the other tray numbers for my printer?

    Any help would be great thanks,

    C.


    Friday, January 12, 2007 3:23 PM

Answers

  • Yeah, we managed to get there but not sure if it is the most efficient way.  Hope this explains how we did it:

    Declare  an object as a print queue

    Dim pq As PrintQueue

    assign it to the printer you want to print to.

    Declare a list of array.

    Dim lstListOfPrinterTrays As New List(Of Array)

    We wrote a function that will use the pq.GetPrintcapabilitiesasXML to populate the list with the tray name and its option name:

    lstListOfPrinterTrays = PrinterOptions(pq.GetPrintCapabilitiesAsXml, "psk:JobInputBin")


    Function PrinterOptions(ByVal stmXML As System.IO.Stream, ByVal strOption As String) As List(Of Array)

            Dim objXMLReader As Xml.XmlReader
            Dim bolFeature As Boolean
            Dim bolOption As Boolean
            Dim bolProperty As Boolean
            Dim strPrinterOption(1) As String
            Dim lstPrinterOptions As New List(Of Array)

            bolFeature = False
            bolOption = False
            bolProperty = False
            objXMLReader = Xml.XmlReader.Create(stmXML)

            Do While objXMLReader.Read() = True

                Select Case objXMLReader.Name

                    Case "psf:Feature"

                        If objXMLReader.AttributeCount = 1 Then
                            objXMLReader.MoveToFirstAttribute()
                            objXMLReader.ReadAttributeValue()
                            Select Case objXMLReader.Value
                                Case strOption
                                    bolFeature = True
                                    bolOption = False
                                    bolProperty = False
                                Case Else
                                    bolFeature = False
                                    bolOption = False
                                    bolProperty = False
                            End Select
                        Else
                            bolFeature = False
                            bolOption = False
                            bolProperty = False

                        End If

                    Case "psfSurpriseption"

                        If bolFeature = True Then
                            If objXMLReader.AttributeCount > 0 Then
                                objXMLReader.MoveToFirstAttribute()
                                objXMLReader.ReadAttributeValue()
                                strPrinterOption(0) = objXMLReader.Value
                                bolOption = True
                                bolProperty = False
                            End If
                        End If

                    Case "psfStick out tongueroperty"

                        If bolFeature = True And bolOption = True Then
                            bolProperty = True
                        End If

                    Case "psf:Value"

                        If bolFeature = True And bolOption = True And bolProperty = True Then

                            If objXMLReader.AttributeCount > 0 Then
                                strPrinterOption(1) = objXMLReader.ReadInnerXml()
                                lstPrinterOptions.Add(strPrinterOption)
                                ReDim strPrinterOption(1)
                            End If
                        End If
                    Case Else
                End Select

            Loop

            PrinterOptions = lstPrinterOptions

        End Function





    Then you get the default print ticket and just make the updates you need:

                  stm = pq.DefaultPrintTicket.GetXmlStream
                    strInputBinForDefaultTicket = ReturnOptionAsStringFromMemStream(stm, "psk:JobInputBin")

                    memDefPrintTicket = pq.DefaultPrintTicket.GetXmlStream

                    streReader = New System.IO.StreamReader(memDefPrintTicket)

                    If streReader.Peek() >= 0 Then
                        strDefaultPrintTicket = strDefaultPrintTicket & streReader.ReadToEnd()
                    End If



        xpsWriter = PrintQueue.CreateXpsDocumentWriter(pq)
                            vxpsd = xpsWriter.CreateVisualsCollator
                            vxpsd.BeginBatchWrite()

    'more code here doing other things.



    'Then when the time comes, you can just replace the section you need in the print ticket:

    strPrintTicket = Replace(strDefaultPrintTicket, strInputBinForDefaultTicket, strArr(0))

    'where strInputBinForDefaultTicket = "psk:AutoSelect"
    'strArr(0)) = ns0000Surpriseption3 'from lstListOfPrinterTrays



    Sorry for the hard coded string, but we were at a loss of how else to get round this issue.

    Hope this helps.

    Friday, May 25, 2007 10:09 AM

All replies

  • I had same problem and this was the answer from Daniel Emerson, Microsoft:

    The PrintCapabilities object only supports the publicly defined values for the *InputBin keyword. To get the full set of input bins supported by the device there are several options:

    1. You can query the PrintCapabilities XML (using System.Printing.PrintQueue.GetPrintCapabilitiesAsXml()) and then parse the returned XML for the full list of Options until the *InputBin keyword. You can see some examples to get you started here: http://msdn2.microsoft.com/en-gb/library/system.printing.printcapabilities.aspx.

    2. Alternatively, you could extend the Print Schema objects to support more private values. Some examples of how to do this are shown here: http://msdn2.microsoft.com/en-us/library/aa970573.aspx.

    __________

    I have tried out method 1 to get the paperbins and I was able to read the ("missing" private) paperbins, but haven't tried out yet to extend the PrintSchema due to other issues/time.... but the samples/links should guide you into the right direction....

    hope this helps anyway, good luck...
    Friday, January 12, 2007 4:09 PM
  • Hi Jo,
    Thanks for such a quick response.  I took a look at option 1 and got the following: (see the end of the thread)

    Both the AutoSelect and the Manual options are present in the PrintTicket.  You said that only the public ones would be.  Am I write in assuming that the 'psk:' prefix of the keys signify that member as being public?

    Any idea what the 'ns0000:' prefix is anyone??

    - <psf:Feature name="psk:JobInputBin">
    - <psf:Property name="psf:SelectionType">
      <psf:Value xsi:type="xsd:QName">psk:PickOne</psf:Value>
      </psf:Property>
    - <psf:Property name="psk:DisplayName">
      <psf:Value xsi:type="xsd:string">Paper Source</psf:Value>
      </psf:Property>
    - <psf:Option name="psk:AutoSelect" constrained="psk:None">
    - <psf:Property name="psk:DisplayName">
      <psf:Value xsi:type="xsd:string">Automatically Select</psf:Value>
      </psf:Property>
      </psf:Option>
    - <psf:Option name="ns0000:Option2" constrained="psk:None">
    - <psf:Property name="psk:DisplayName">
      <psf:Value xsi:type="xsd:string">Cassette 1 (Internal)</psf:Value>
      </psf:Property>
      </psf:Option>
    - <psf:Option name="ns0000:Option3" constrained="psk:None">
    - <psf:Property name="psk:DisplayName">
      <psf:Value xsi:type="xsd:string">Cassette 2</psf:Value>
      </psf:Property>
      </psf:Option>
    - <psf:Option name="ns0000:Option4" constrained="psk:DeviceSettings">
    - <psf:Property name="psk:DisplayName">
      <psf:Value xsi:type="xsd:string">Cassette 3</psf:Value>
      </psf:Property>
      </psf:Option>
    - <psf:Option name="psk:Manual" constrained="psk:None">
    - <psf:ScoredProperty name="psk:FeedType">
      <psf:Value xsi:type="xsd:QName">psk:Manual</psf:Value>
      </psf:ScoredProperty>
    - <psf:Property name="psk:DisplayName">
      <psf:Value xsi:type="xsd:string">Multi-Purpose Feeder</psf:Value>
      </psf:Property>
      </psf:Option>

    Friday, January 12, 2007 5:24 PM
  • only the public ones will show up in the PrintCapabilities object, that's right... in the xml for the PrintCapabilities ofcourse both are present, public and private ones...

    psk and ns000 are namespaces as far as I can remember, where psk is the public and ns000 is a private namespace, hence the one you have to define when you extend the Print Schema I guess myself...

    just have a look at the 'PrintCapabilities Document Sample' (http://msdn2.microsoft.com/en-us/library/ms716353.aspx) where you can see they have been defined at the beginning....

    <psf:PrintCapabilities xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1"
    xmlns:ns0000="http://schemas.microsoft.com/windows/printing/oemdriverpt/ES_LNseries_PowerPrinter"
    xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords">

    Saturday, January 13, 2007 3:52 PM
  • Hi all,

    Update here for anyone that is interested....

    I took my printer and saved the print capabilities to a text file on the hard disc:
    Dim oprintCapabilites As System.Printing.PrintCapabilities = myPrintQueue.GetPrintCapabilities()

    Then I created a default printticket from my printer and saved the xml stream to a text file:
    Dim oPrintTicket As System.Printing.PrintTicket = myPrintQueue.DefaultPrintTicket
    Dim s As New System.IO.FileStream("c:\testxml.txt", IO.FileMode.Create)
    oPrintTicket.GetXmlStream.WriteTo(s)

    Manually changing the line:
      <psf:Feature name="psk:JobInputBin">
        <psf:Option name="
    psk:AutoSelect"" />
      </psf:Feature>
    to:
      <psf:Feature name="psk:JobInputBin">
        <psf:Option name="ns0000:Option2" />
      </psf:Feature>

    and creating a new printticket with this file as the stream allows me to change the input bins, so I am able to select all the trays from my printer on a page by page basis.

    Next thing I have to do is some how cobble all this together in code.

    Unfortunately, when I change the inputbin value in the ticket to a private option the ticket object shows the inputbin variable as 'Unknown {0}'.  I am assuming this is because I have not fully got to grips with extending the printticket object though.

    Basically, if anyone is trying to do this it is possible.  Unfortunately, it's just not easy!!

    Still looking for easier options anyone....

    Thanks Jo for your help.
    Tuesday, January 16, 2007 10:35 AM
  • I am facing the same problem. Could you please let me know if you have found a way to do this. Basically I am trying to route my printjob to a specified tray but the

    printCapabilites.InputBinCapability shows only the AutoSelect option and it doesnt show any other trays.

     

    Thanks

    RJ

    Thursday, May 24, 2007 9:33 PM
  • Yeah, we managed to get there but not sure if it is the most efficient way.  Hope this explains how we did it:

    Declare  an object as a print queue

    Dim pq As PrintQueue

    assign it to the printer you want to print to.

    Declare a list of array.

    Dim lstListOfPrinterTrays As New List(Of Array)

    We wrote a function that will use the pq.GetPrintcapabilitiesasXML to populate the list with the tray name and its option name:

    lstListOfPrinterTrays = PrinterOptions(pq.GetPrintCapabilitiesAsXml, "psk:JobInputBin")


    Function PrinterOptions(ByVal stmXML As System.IO.Stream, ByVal strOption As String) As List(Of Array)

            Dim objXMLReader As Xml.XmlReader
            Dim bolFeature As Boolean
            Dim bolOption As Boolean
            Dim bolProperty As Boolean
            Dim strPrinterOption(1) As String
            Dim lstPrinterOptions As New List(Of Array)

            bolFeature = False
            bolOption = False
            bolProperty = False
            objXMLReader = Xml.XmlReader.Create(stmXML)

            Do While objXMLReader.Read() = True

                Select Case objXMLReader.Name

                    Case "psf:Feature"

                        If objXMLReader.AttributeCount = 1 Then
                            objXMLReader.MoveToFirstAttribute()
                            objXMLReader.ReadAttributeValue()
                            Select Case objXMLReader.Value
                                Case strOption
                                    bolFeature = True
                                    bolOption = False
                                    bolProperty = False
                                Case Else
                                    bolFeature = False
                                    bolOption = False
                                    bolProperty = False
                            End Select
                        Else
                            bolFeature = False
                            bolOption = False
                            bolProperty = False

                        End If

                    Case "psfSurpriseption"

                        If bolFeature = True Then
                            If objXMLReader.AttributeCount > 0 Then
                                objXMLReader.MoveToFirstAttribute()
                                objXMLReader.ReadAttributeValue()
                                strPrinterOption(0) = objXMLReader.Value
                                bolOption = True
                                bolProperty = False
                            End If
                        End If

                    Case "psfStick out tongueroperty"

                        If bolFeature = True And bolOption = True Then
                            bolProperty = True
                        End If

                    Case "psf:Value"

                        If bolFeature = True And bolOption = True And bolProperty = True Then

                            If objXMLReader.AttributeCount > 0 Then
                                strPrinterOption(1) = objXMLReader.ReadInnerXml()
                                lstPrinterOptions.Add(strPrinterOption)
                                ReDim strPrinterOption(1)
                            End If
                        End If
                    Case Else
                End Select

            Loop

            PrinterOptions = lstPrinterOptions

        End Function





    Then you get the default print ticket and just make the updates you need:

                  stm = pq.DefaultPrintTicket.GetXmlStream
                    strInputBinForDefaultTicket = ReturnOptionAsStringFromMemStream(stm, "psk:JobInputBin")

                    memDefPrintTicket = pq.DefaultPrintTicket.GetXmlStream

                    streReader = New System.IO.StreamReader(memDefPrintTicket)

                    If streReader.Peek() >= 0 Then
                        strDefaultPrintTicket = strDefaultPrintTicket & streReader.ReadToEnd()
                    End If



        xpsWriter = PrintQueue.CreateXpsDocumentWriter(pq)
                            vxpsd = xpsWriter.CreateVisualsCollator
                            vxpsd.BeginBatchWrite()

    'more code here doing other things.



    'Then when the time comes, you can just replace the section you need in the print ticket:

    strPrintTicket = Replace(strDefaultPrintTicket, strInputBinForDefaultTicket, strArr(0))

    'where strInputBinForDefaultTicket = "psk:AutoSelect"
    'strArr(0)) = ns0000Surpriseption3 'from lstListOfPrinterTrays



    Sorry for the hard coded string, but we were at a loss of how else to get round this issue.

    Hope this helps.

    Friday, May 25, 2007 10:09 AM
  • Thanks. It helped me a lot!
    Tuesday, May 29, 2007 7:04 PM
  • I solved it that way, one method to read all inputbins and the values for it and one method to modify the printticket, which could be used for other properties as well...

    ___________

    public static class XpsPrinterUtils
    {
        public static Dictionary<string, string> GetInputBins(string printerName)
        {
          Dictionary<string, string> inputBins = new Dictionary<string, string>();
         
          // get PrintQueue of Printer from the PrintServer
          LocalPrintServer printServer = new LocalPrintServer();
          PrintQueue printQueue = printServer.GetPrintQueue(printerName);

         // get PrintCapabilities of the printer
          MemoryStream printerCapXmlStream = printQueue.GetPrintCapabilitiesAsXml();

          // read the JobInputBins out of the PrintCapabilities
          XmlDocument xmlDoc = new XmlDocument();
          xmlDoc.Load(printerCapXmlStream);

          // create NamespaceManager and add PrintSchemaFrameWork-Namespace (should be on DocumentElement of the PrintTicket)
          // Prefix: psf  NameSpace: xmlDoc.DocumentElement.NamespaceURI = "http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
          XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
          manager.AddNamespace(xmlDoc.DocumentElement.Prefix, xmlDoc.DocumentElement.NamespaceURI);

          // and select all nodes of the bins
          XmlNodeList nodeList = xmlDoc.SelectNodes("//psf:Feature[@name='psk:JobInputBin']/psfSurpriseption", manager);

          // fill Dictionary with the bin-names and values
          foreach (XmlNode node in nodeList)
          {
            inputBins.Add(node.LastChild.InnerText, node.Attributes["name"].Value);
          }

          return inputBins;
        }


        public static PrintTicket ModifyPrintTicket(PrintTicket ticket, string featureName, string newValue)
        {
          if (ticket == null)
          {
            throw new ArgumentNullException("ticket");
          }

          // read Xml of the PrintTicket
          XmlDocument xmlDoc = new XmlDocument();
          xmlDoc.Load(ticket.GetXmlStream());

          // create NamespaceManager and add PrintSchemaFrameWork-Namespace hinzufügen (should be on DocumentElement of the PrintTicket)
          // Prefix: psf  NameSpace: xmlDoc.DocumentElement.NamespaceURI = "http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
          XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
          manager.AddNamespace(xmlDoc.DocumentElement.Prefix, xmlDoc.DocumentElement.NamespaceURI);
         
          // search node with desired feature we're looking for and set newValue for it
          string xpath = string.Format("//psf:Feature[@name='{0}']/psfSurpriseption", featureName);
          XmlNode node = xmlDoc.SelectSingleNode(xpath, manager);
          if (node != null)
          {
            node.Attributes["name"].Value = newValue;
          }

         // create a new PrintTicket out of the XML
          MemoryStream printTicketStream = new MemoryStream();
          xmlDoc.Save(printTicketStream);
          printTicketStream.Position = 0;
          PrintTicket modifiedPrintTicket = new PrintTicket(printTicketStream);

          // for testing purpose save the printticket to file
          //FileStream stream = new FileStream("modPrintticket.xml", FileMode.CreateNew, FileAccess.ReadWrite);
          //modifiedPrintTicket.GetXmlStream().WriteTo(stream);

          return modifiedPrintTicket;
        }
    }
    ___________

    the funny smileys above should be "psf : Option" without the spaces... (c;

    maybe it helps also, though I guess and assume the method above works also... (c;

    regards,

    Jo

    Wednesday, May 30, 2007 1:54 PM
  • forgot to mention how to call the method for ModifyPrintTicket... in this case we change feature for Inputbin -> psk:JobInputBin

    // Get Dictionary with Inputbins by calling the other method
    // and get "value" for the desired inputbin you'd like to use...
    // ...
    // desiredTray is then something like "NS0000Surpriseption7" for example
    // defaultPrintTicket is the (Default)PrintTicket you want to modify from the PrintQueue for example

    PrintTicket myPrintTicket = XpsPrinterUtils.ModifyPrintTicket(defaultPrintTicket, "psk:JobInputBin", desiredTray);
    __________

    the funny smileys above should be in this example something like "NS0000 : Option7" then, ofcourse without the spaces... (c;
    Wednesday, May 30, 2007 2:31 PM
  • has anyone tried the option of extending the Print Schema to choose the inputbins?
    Wednesday, July 18, 2007 7:08 PM
  • Thanks for posting this example.  When I google "xps printing input tray" this is about the only relevant result that comes up.  I did, however, have one problem with the posted code.  When trying to specify the input tray on my HP LaserJet 4050, the specified tray would be ignored, and the document would print from whatever the "default" tray is, usually the last tray.

    It turns out that when modifying the print ticket, you have to specify the correct namespace uri for the prefix "ns0000".  This uri is likely to be different for each printer you try to print to.

    To get the correct uri, I added an out parameter to GetInputBins: string namespaceUri.  Then, inside the GetInputBins method, I have the following line:

                namespaceUri = xmlDoc.ChildNodes[1].GetNamespaceOfPrefix("ns0000");

    I then added the same string parameter to the ModifyPrintTicket method (not as out this time).  Then, inside that method, I modified the code block that sets the new value to also add the namespace to the document:

    if (node != null)
                {
                    if (newValue.StartsWith("ns0000"))
                    {
                        // add namespace to xml doc
                        XmlAttribute namespaceAttribute = xmlDoc.CreateAttribute("xmlns:ns0000");                   
                        namespaceAttribute.Value =
    namespaceUri;                   
                        xmlDoc.DocumentElement.Attributes.Append(namespaceAttribute);
                    }
                    node.Attributes["name"].Value = newValue;
                }

    I hope this helps someone else avoid the aggravation that I went through trying to track this information down.  There seems to be zero documentation of this functionality.

    I posted a complete sample on my blog.
    Friday, May 23, 2008 5:00 PM
  • Hi Martin,

    glad you liked my sample code and it was helpful for you... =) however this was just a quick hack of my test-applications when dealing with XPS files. At the time I only did some checks by having a look at the produced PCL code of my HP LaserJet 4050 printer and it looked fine, but thanx for pointing out this "problem" and posting the complete sample on your blog. Hopefully it's helpful for others as well... (c;

    regards from Germany,
    JO
    Saturday, May 24, 2008 11:28 AM
  •  witters wrote:
    ...When trying to specify the input tray on my HP LaserJet 4050, the specified tray would be ignored, and the document would print from whatever the "default" tray is, usually the last tray.

    It turns out that when modifying the print ticket, you have to specify the correct namespace uri for the prefix "ns0000".  This uri is likely to be different for each printer you try to print to.

     

    Martin, I've just checked my code again and printed on a HP Laserjet 5SI to file. And it seems the trays are set correcly in the pcl-code/viewer, though I did not check direct printing.
    And I didn't add the namespaces, but I guess that works because I have modified a ticket which is the default printticket of the desired printer and hence the namespace is already in the xml... like...

     

    Code Snippet

    LocalPrintServer printServer = new LocalPrintServer();

    PrintQueue printQueue = printServer.GetPrintQueue("HP Laserjet 5SI");

    PrintTicket defaultTicket = printQueue.DefaultPrintTicket.Clone();

    PrintTicket newTicket = ModifyPrintTicket(defaultTicket, "psk:JobInputBin", "ns0000:UPPER");

     

     

    I've saved the modified printticket and I saw xmlns:ns0000="http://schemas.microsoft.com/windows/printing/oemdriverpt/HP_LaserJet_5Si_6_0_6000_16438_" in it, so I guess this might happen when you create a printticket from scratch and call the ModifyPrintTicket method then.

     

    Just being curious, which PrintTicket did you use? Default one from the queue or a new instance of  a PrintTicket (created with new)?

     

    regards,

    Jo

    Tuesday, May 27, 2008 3:58 PM
  • I have been using the code provided here to select an input tray not publicly available. This worked ok for my local printer, but on the two network printers I am connected to there it no JobInputBin node in the Printer Capabilities XML. Does anyone have any idea why I do not have this node, or what I can do to select the tray on these network printers? What happens if I just manually append the JobInputBin section into my print ticket?

     

    Any suggestions would be greatly appreciated.

     

    MJ

     

    Wednesday, July 23, 2008 11:46 PM
  • just to keep the information in this thread:

    if you can't find any JobInputBin nodes, try to read also PageInputBin or DocumentInputBin nodes...
    guess that was also M. Judd's problem... the "HP Universal Printerdriver" for example holds the trays in PageInputBin nodes...
    Thursday, November 19, 2009 3:15 PM
  • Hi,

    I´m using your code, but the InputBin Property in the returnTicket is "Unknown" and not "ManualFeed";

    XpsPrinterUtils.GetInputBins(defaultPrintQueue2.FullName);

    from inputbins: [2] = {[Man. Zufuhr in Fach 1, ns0000:ManualFeed]}

    PrintTicket myPrintTicket = XpsPrinterUtils.ModifyPrintTicket(deltaTicket, "psk:JobInputBin", "psk:ManualFeed");

    in myPrintTicket the InputBin Property is unknown.

    in xmlDoc before creating the returnTicket:

    </psf:Feature>

    <psf:Feature name="psk:JobInputBin">

    <psf:Option name="psk:ManualFeed" />

    </psf:Feature></psf:PrintTicket>

     

    >What´s going wrong here?

    >P.S. I´m using a win7 64bit, but that´s not relvant, isn´t it?

     

     

    >Thanks for help to anyone...

    Tuesday, December 07, 2010 2:07 PM
  • Hi Oli001,

    you need to set "ns0000:ManualFeed" instead of "psk:ManualFeed" in the call to the ModifyPrintTicket().

    First parameter is the ticket you want to modify, second is the feature-name and third one is the value you want to set.
    In this case the value of the item you want to use from the inputbin-dictionary.

    However you need to use a cloned default-printticket (like in my example posted above) else the namespace for ns0000-prefix is not in the printticket-xml and you need to add that one manually then... But I guess you've used a cloned printticket...

    hope this helps a bit,
    Jo

    Thursday, December 09, 2010 10:23 AM
  • Hi Jo0815,

    Hi Jo0815,

    I tried:

     

    LocalPrintServer localPrintServer2 = new LocalPrintServer();

    PrintQueue defaultPrintQueue2 = LocalPrintServer.GetDefaultPrintQueue();

    PrintCapabilities cab = defaultPrintQueue2.GetPrintCapabilities();

    PrintTicket deltaTicket = new PrintTicket();

    PageMediaSize paperSize = new PageMediaSize(816, 1056);

    deltaTicket.PageMediaSize = paperSize;

    deltaTicket.PageOrientation = PageOrientation.Landscape;

    deltaTicket.OutputColor = OutputColor.Grayscale;

    deltaTicket.Duplexing = cab.DuplexingCapability[1];

    deltaTicket.InputBin = InputBin.Cassette;

    PrintTicket ticket = deltaTicket.Clone();

    XpsPrinterUtils.GetInputBins(defaultPrintQueue2.FullName);

    PrintTicket myPrintTicket = XpsPrinterUtils.ModifyPrintTicket(ticket, "psk:JobInputBin", "ns0000:ManualFeed");

     

     

    The XML – Stream in your Function ModifyPrintTicket is:

     

      <?xml version="1.0" encoding="UTF-8" ?>

    - <psf:PrintTicket xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework" xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns:ns0000="http://www.hp.com/printschema/2005">

    - <psf:Feature name="psk:PageMediaSize">

    - <psf:Option>

    - <psf:ScoredProperty name="psk:MediaSizeWidth">

      <psf:Value xsi:type="xsd:integer">215900</psf:Value>

      </psf:ScoredProperty>

    - <psf:ScoredProperty name="psk:MediaSizeHeight">

      <psf:Value xsi:type="xsd:integer">279400</psf:Value>

      </psf:ScoredProperty>

      </psf:Option>

      </psf:Feature>

    - <psf:Feature name="psk:PageOrientation">

      <psf:Option name="psk:Landscape" />

      </psf:Feature>

    - <psf:Feature name="psk:PageOutputColor">

      <psf:Option name="psk:Grayscale" />

      </psf:Feature>

    - <psf:Feature name="psk:JobDuplexAllDocumentsContiguously">

      <psf:Option name="psk:TwoSidedLongEdge" />

      </psf:Feature>

    - <psf:Feature name="psk:JobInputBin">

      <psf:Option name="ns0000:ManualFeed" />

      </psf:Feature>

      </psf:PrintTicket>

     

     

    But in myPrintTicket the InputBin – Property is „Unknown“.

     

    It was very important for me to solve this problem. Maybe you can help me with that. It was very great if you could contact me. My E-Mail is oli2802@googlemail.com

     

    Of course you don´t have to do that at no charge. Please help. Thanks a lot.

     

    Oli

     

    Thursday, December 16, 2010 10:13 AM
  • Hi Oli,

    sorry, just saw your post today...

    Always use the default printticket from your queue you're using, because you need the private namespace (that ns0000:) in your ticket...

    try

    PrintTicket deltaTicket = defaultPrintQueue2.DefaultPrintTicket.Clone();

    instead of

    PrintTicket deltaTicket = new PrintTicket ();

    just a wild guess...

     

    btw, don't wonder if you see in the objectinspector 'Unknown' on property Inputbin, that is correct! It will show only the public ones and the printschema doesn't know anything about the inputbins of your printer, as they're private/printer dependent and hence the private namespace...

    if you remove comments on the lines:

          //FileStream stream = new FileStream("modPrintticket.xml", FileMode.CreateNew, FileAccess.ReadWrite);
          //modifiedPrintTicket.GetXmlStream().WriteTo(stream);

    you can save the modfied printticket xml and check if your inputbin is set...
    you should have something like:

      <psf:Feature name="psk:JobInputBin">
        <psf:Option name="ns0000:ManualFeed " />
      </psf:Feature>

    I see you've already saved the modified printticket xml and to me it looks good with the inputbin-settings (except that you've used new printticket())
    However best test if you print out a file using this modified ticket, to see if that bin is used then...

    let me know if it still doesn't work...
    regards from snowy Germany,
    Jo

    Monday, December 20, 2010 11:33 AM
  • I had same problem and this was the answer from Daniel Emerson, Microsoft:

    The PrintCapabilities object only supports the publicly defined values for the *InputBin keyword. To get the full set of input bins supported by the device there are several options:

    1. You can query the PrintCapabilities XML (using System.Printing.PrintQueue.GetPrintCapabilitiesAsXml()) and then parse the returned XML for the full list of Options until the *InputBin keyword. You can see some examples to get you started here: http://msdn2.microsoft.com/en-gb/library/system.printing.printcapabilities.aspx.

    2. Alternatively, you could extend the Print Schema objects to support more private values. Some examples of how to do this are shown here: http://msdn2.microsoft.com/en-us/library/aa970573.aspx.

    __________

    I have tried out method 1 to get the paperbins and I was able to read the ("missing" private) paperbins, but haven't tried out yet to extend the PrintSchema due to other issues/time.... but the samples/links should guide you into the right direction....

    hope this helps anyway, good luck...

    It is exactly what I need, Thanks for your sharing!
    Tuesday, January 18, 2011 12:06 AM
  • Hi all, I want to print a XPS file, but before I want to decide what tray of the printer choose. Everything programatically, without asking the user.

    I copy the code from the above topics to change the tray, but i think I miss something. Can you help me?

    My class is like this:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Printing;
    using System.Xml;
    using System.IO;
    using System.Collections.Generic;
    
    namespace lastTest
    {
      public class XpsPrinterUtils
      {
        public static Dictionary<string, string> GetInputBins(string printerName)
        {
          Dictionary<string, string> inputBins = new Dictionary<string, string>();
    
          // get PrintQueue of Printer from the PrintServer
          LocalPrintServer printServer = new LocalPrintServer();
          PrintQueue printQueue = printServer.GetPrintQueue(printerName);
    
          // get PrintCapabilities of the printer
          MemoryStream printerCapXmlStream = printQueue.GetPrintCapabilitiesAsXml();
    
          // read the JobInputBins out of the PrintCapabilities
          XmlDocument xmlDoc = new XmlDocument();
          xmlDoc.Load(printerCapXmlStream);
    
          // create NamespaceManager and add PrintSchemaFrameWork-Namespace (should be on DocumentElement of the PrintTicket)
          // Prefix: psf NameSpace: xmlDoc.DocumentElement.NamespaceURI = "http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
          XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
          manager.AddNamespace(xmlDoc.DocumentElement.Prefix, xmlDoc.DocumentElement.NamespaceURI);
    
          // and select all nodes of the bins
          XmlNodeList nodeList = xmlDoc.SelectNodes("//psf:Feature[@name='psk:JobInputBin']/psfption", manager);
    
          // fill Dictionary with the bin-names and values
          foreach (XmlNode node in nodeList)
          {
            inputBins.Add(node.LastChild.InnerText, node.Attributes["name"].Value);
          }
    
          return inputBins;
        }
    
    
        public static PrintTicket ModifyPrintTicket(PrintTicket ticket, string featureName, string newValue)
        {
          if (ticket == null)
          {
            throw new ArgumentNullException("ticket");
          }
    
          // read Xml of the PrintTicket
          XmlDocument xmlDoc = new XmlDocument();
          xmlDoc.Load(ticket.GetXmlStream());
    
          // create NamespaceManager and add PrintSchemaFrameWork-Namespace hinzufügen (should be on DocumentElement of the PrintTicket)
          // Prefix: psf NameSpace: xmlDoc.DocumentElement.NamespaceURI = "http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
          XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
          manager.AddNamespace(xmlDoc.DocumentElement.Prefix, xmlDoc.DocumentElement.NamespaceURI);
    
          // search node with desired feature we're looking for and set newValue for it
          string xpath = string.Format("//psf:Feature[@name='{0}']/psfption", featureName);
          XmlNode node = xmlDoc.SelectSingleNode(xpath, manager);
          if (node != null)
          {
            node.Attributes["name"].Value = newValue;
          }
    
          // create a new PrintTicket out of the XML
          MemoryStream printTicketStream = new MemoryStream();
          xmlDoc.Save(printTicketStream);
          printTicketStream.Position = 0;
          PrintTicket modifiedPrintTicket = new PrintTicket(printTicketStream);
    
          // for testing purpose save the printticket to file
          FileStream stream = new FileStream("C:\\teste Xps\\modPrintticket.xml", FileMode.Create, FileAccess.ReadWrite);
          modifiedPrintTicket.GetXmlStream().WriteTo(stream);
    
          return modifiedPrintTicket;
        }
    
        public static void PrintXPS () 
        {
          LocalPrintServer prServer = new LocalPrintServer();
          String printer = "ImpressoraTeste";
          PrintQueue prQueue = prServer.GetPrintQueue(printer);
          FileInfo f = new FileInfo("C:\\teste Xps\\Fodasse.xps");
          PrintSystemJobInfo xpsPrintJob = prQueue.AddJob(f.Name, "C:\\teste Xps\\Fodasse.xps", false);
        }
      }
    }
    
    

     

    And i've 1 button to do this.

    protected void Button1_Click(object sender, EventArgs e)
        {      
          XpsPrinterUtils.GetInputBins("ImpressoraTeste");
          LocalPrintServer printServer = new LocalPrintServer();
          PrintQueue printQueue = printServer.GetPrintQueue("ImpressoraTeste");
          PrintTicket defaultPrintTicket = printQueue.DefaultPrintTicket.Clone();
          PrintTicket myPrintTicket = XpsPrinterUtils.ModifyPrintTicket(defaultPrintTicket, "psk:JobInputBin", "ns0000:Tray2");
          
          Thread printingThread = new Thread(XpsPrinterUtils.PrintXPS);
          printingThread.SetApartmentState(ApartmentState.STA);
          printingThread.Start();
    }
    

    The xml document generated by the function modifyPrintTicket() has the default value I define in the printer ("AutoSelect").

    Any help would be apreciated.

    Thanks, Tiago (Portugal).

    Thursday, January 20, 2011 1:12 PM
  • Hello Tiago,

    first, my GetInputBins() reads all available names and their associated values you need for the ModifyPrintTicket. The dictionary can be used to let a user select a tray by name, so if your user doesn't select and you always use the "AutoSelect" bin, you ofcourse don't need to call the method...

    Anway, I guess the problem is in your thread-function "PrintXPS", which just adds a new job to the queue, without the printticket.
    So you have to pass either "myPrintTicket" to your thread-function (you can also pass objects to your thread) or you have to create/modify PrintTicket in the thread-function and then instead of

    FileInfo f = new
     FileInfo("C:\\teste Xps\\Fodasse.xps"
    );
    PrintSystemJobInfo xpsPrintJob = prQueue.AddJob(f.Name, "C:\\teste Xps\\Fodasse.xps" , false );

    try to print the document via a XpsDocumentWriter, passing your modified printticket to the writer, like for example:

    LocalPrintServer prServer = new
     LocalPrintServer();
    String printer = "ImpressoraTeste" ;
    PrintQueue prQueue = prServer.GetPrintQueue(printer);

    XpsDocumentWriter xpsWriter = PrintQueue.CreateXpsDocumentWriter(prQueue);
    using (XpsDocument xpsDoc = new XpsDocument("C:\\teste Xps\\Fodasse.xps ", FileAccess.Read))
    {
    FixedDocumentSequence fixedDocumentSequence = xpsDoc.GetFixedDocumentSequence();
    xpsWriter.Write(fixedDocumentSequence, myPrintTicket);
    }

    where myPrintTicket is your modifed PrintTicket from the Button1_Click handler...

    I haven't tested the code, but I think it should work...

    hope this helps a bit...

    Regards from Germany,
    Jo

     

    Thursday, January 20, 2011 3:22 PM
  • Thanks for your help JO815,

    Look, I don't want to create a new document, i just want to print a existing .xps file. Is that possible with your code?

    I get an error when in XpsDocument, and in FixedDocumentSequence.

    I just import System.Windows.Xps, is that other one necessary?

     

    Thanks,

    Regards!!

    Thursday, January 20, 2011 4:19 PM
  • Tiago,

    with the code above you don't create a new document, you just open an existing XPS-file for reading (see that FileAccess.Read??)
    You then get the FixedDocumentSequence from it and pass it to the XpsDocumentWriter (which was created by the PrintQueue, hence connected to your queue) for printing...

    XpsDocument should be in namespace System.Windows.Xps.Packaging (c:\programs\Reference Assemblies\Microsoft\Framework\v3.0\ReachFramework.dll)

    and

    FixedDocumentSequence should be in namespace System.Windows.Documents (c:\programs\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll)

    regards,
    Jo

    Thursday, January 20, 2011 4:51 PM
  • Ok, I understand what you're saying. I add all references,  but i can't figure out how to define the structure of my code, i'm confused.

    So, in the function of Button i have to create a printServer, printQueue, and send printTicket to the modifyPrintTicket(). Rigth?

    Now i need to pass the modifyPrintTicket when I call my function .PrintXPs(). How i do that if I'm creating a Thread?

    In the .PrintXPs() I recieve the modifyPrintTicket and create another time a new PrintServer, PrintQueue and execute the code you gave me:

    XpsDocumentWriter xpsWriter = PrintQueue.CreateXpsDocumentWriter(prQueue);
          using (XpsDocument xpsDoc = new XpsDocument("C:\\teste Xps\\Fodasse.xps", FileAccess.Read))
          {
            FixedDocumentSequence fixedDocumentSequence = xpsDoc.GetFixedDocumentSequence();
            xpsWriter.Write(fixedDocumentSequence, myPrintTicket);
          }

    And now, i had to execute the job right? With this code?

    PrintSystemJobInfo xpsPrintJob = prQueue.AddJob(f.Name, "C:\\teste Xps\\Fodasse.xps", false);

    Sorry, I'm to confused. Help me!!

    Thanks for your time, regards.

    Tiago

    Thursday, January 20, 2011 5:18 PM
  • You can either

    a) create the modified PrintTicket in your Button-handler and then you have to pass it to your thread. You can pass an object (in your case myPrintTicket) in the printingThread.Start() and that object you'll get in your thread-function then, typecast it back from object to a PrintTicket... see the documentation about threading, there should be also example for that...

    or

    b) you create the modified PrintTicket also in your thread-function...

    Depends on where you have the informations about bin etc.

    My Code above prints the Xps-Document, so you don't need your code anymore to execute the printjob...

    So you were almost right, execept prQueue.AddJob() is not needed anymore...

    Thursday, January 20, 2011 5:39 PM
  • My code is like this:
    public static void PrintXPS () 
        {
          LocalPrintServer printServer = new LocalPrintServer();
          PrintQueue prQueue = printServer.GetPrintQueue("ImpressoraTeste");
          PrintTicket defaultPrintTicket = prQueue.DefaultPrintTicket.Clone();
          PrintTicket myPrintTicket = XpsPrinterUtils.ModifyPrintTicket(defaultPrintTicket, "psk:JobInputBin", "ns0000:Tray2");
          XpsDocumentWriter xpsWriter = PrintQueue.CreateXpsDocumentWriter(prQueue);
          using (XpsDocument xpsDoc = new XpsDocument("C:\\teste Xps\\Fodasse.xps", FileAccess.Read))
          {
            FixedDocumentSequence fixedDocumentSequence = xpsDoc.GetFixedDocumentSequence();
            xpsWriter.Write(fixedDocumentSequence, myPrintTicket);
          }
        }
    
     protected void Button1_Click(object sender, EventArgs e)
        {
          Thread printingThread = new Thread(XpsPrinterUtils.PrintXPS);
          printingThread.SetApartmentState(ApartmentState.STA);
          printingThread.Start();
        }
    

    What i'm missing?

    Another question, my first objective is control the printer, and I can do it just with Jobs, if I don't have one, how can I control my printing?

    Many thanks for your time Jo, regards!!

    Thursday, January 20, 2011 5:54 PM
  • yes, that code seems ok to me and should print the xps with your modified PrintTicket,  though I haven't tested...

    What do you mean with "control the printer"?? What do you want to control on printing??

    Thursday, January 20, 2011 6:11 PM
  • In the xml document the JobInputBin is AutoSelect, is what I define on the printer defaults. So it's not working.

    I can control if my printer is printing, if is out of paper, with a job i can have access at all this information.

    Thursday, January 20, 2011 6:22 PM
  • In the xml document the JobInputBin is AutoSelect, is what I define on the printer defaults. So it's not working.

    I can control if my printer is printing, if is out of paper, with a job i can have access at all this information.


    It's printing but not in the rigth tray!!

    What can I do to solve this?

    Regards Jo

    Thursday, January 20, 2011 6:22 PM
  • did you try printing the xps-file on a real printer? Did you check the xml of the printticket if "ns0000:Tray2" is set on the "psk:JobInputBin"-node?
    the printticket is only used for printing that xps, it does not change any settings on the printerdriver's property-page. If you want to do you need to change default- or user-PrintTicket on the PrintQueue..

    Also you can use the PrintQueue to "control" your printer. You can pause/resume printing, purge printjobs and it has a lot of properties to find out if it's printing, out of paper/toner, if theres a a paper jam and lot's more... You even can set a even progress-eventhandler to display the progress of printing etc. Also you can get your PrintJobInfo with the GetJob() for example...

     

     

    Thursday, January 20, 2011 6:41 PM
  • maybe post the xml of your modified printticket... In my code I added lines for saving it to "modPrintTicket.xml" for testing purposes...
    Also what printerdriver/version are you using, may I can have a look at it tomorrow...
    Thursday, January 20, 2011 6:56 PM
  • Yes, i test it in a real printer.

    I call the function modifyPrintTicket this way:

    PrintTicket myPrintTicket = XpsPrinterUtils.ModifyPrintTicket(defaultPrintTicket, "psk:JobInputBin", "ns0000:Tray2");
    
    <span style="font-size:x-small"><p>My function ModifyPrintTicket() is like this:</p><pre>public static PrintTicket ModifyPrintTicket(PrintTicket ticket, string featureName, string newValue)
        {
          if (ticket == null)
          {
            throw new ArgumentNullException("ticket");
          }
    
          // read Xml of the PrintTicket
          XmlDocument xmlDoc = new XmlDocument();
          xmlDoc.Load(ticket.GetXmlStream());
    
          // create NamespaceManager and add PrintSchemaFrameWork-Namespace hinzufügen (should be on DocumentElement of the PrintTicket)
          // Prefix: psf NameSpace: xmlDoc.DocumentElement.NamespaceURI = "http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
          XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
          manager.AddNamespace(xmlDoc.DocumentElement.Prefix, xmlDoc.DocumentElement.NamespaceURI);
    
          // search node with desired feature we're looking for and set newValue for it
          string xpath = string.Format("//psf:Feature[@name='{0}']/psfption", featureName);
          XmlNode node = xmlDoc.SelectSingleNode(xpath, manager);
          if (node != null)
          {
            node.Attributes["name"].Value = newValue;
          }
    
          // create a new PrintTicket out of the XML
          MemoryStream printTicketStream = new MemoryStream();
          xmlDoc.Save(printTicketStream);
          printTicketStream.Position = 0;
          PrintTicket modifiedPrintTicket = new PrintTicket(printTicketStream);
    
          // for testing purpose save the printticket to file
          FileStream stream = new FileStream("C:\\teste Xps\\modPrintticket.xml", FileMode.Create, FileAccess.ReadWrite);
          modifiedPrintTicket.GetXmlStream().WriteTo(stream);
    
          return modifiedPrintTicket;
        }
    

    I think it's everything like in the above topics.

    The generated XML file by the ModifyPrintTicket, show me that my code isn't doing nothing:

    psf:Feature name="psk:JobInputBin">
     <psf:Option name="psk:AutoSelect" /> 
    

    What can I do to solve this??

    Yeah, I think i would use PrintQueue options to control the printer, but now my real problem is to manage trays!! Help me pls.

     

    Many thanks Jo, Regards

     

    Thursday, January 20, 2011 7:00 PM
  • there seems to be a bug in the forum when I have posted the code or when they have migrated forum-posts...

    the line

    string
    xpath = string .Format("//psf:Feature[@name='{0}']/psfption" , featureName);

    is incorrect, it should be "//psf:Feature[@name='{0}']/psf:Option" and not psfption.

    Because of that it doesn't find the xml-node and therefor it does not change anything... try it out, hope it helps!

    Thursday, January 20, 2011 7:18 PM
  • Omg, I can't imagine I don't see that, LOL!

    Many thanks Jo!!! It works great, now I'm gonna find a way to control all the printer!

    Can you give me your e-mail? We can talk on the messenger.

     

    Many thanks dude,

    Regards

    Friday, January 21, 2011 12:17 PM
  • there seems to be a bug in the forum when I have posted the code or when they have migrated forum-posts...

    the line

    string
    xpath = string .Format("//psf:Feature[@name='{0}']/psfption" , featureName);

    is incorrect, it should be "//psf:Feature[@name='{0}']/psf:Option" and not psfption.

    Because of that it doesn't find the xml-node and therefor it does not change anything... try it out, hope it helps!

    Hi again Jo0815,

    The code works great in my HP LaserJet 4100, but in my Xerox Phaser 5500 it doesn't work.

    The xml generate is diferent. Can you have a look at this?

    XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <psf:PrintTicket xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns:ns0000="http://schemas.microsoft.com/windows/printing/oemdriverpt/Xerox_Phaser 5550DN PCL6/6.1.7600.16385/" xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords">
     <psf:Feature name="psk:JobNUpAllDocumentsContiguously">
      <psf:Option>
       <psf:ScoredProperty name="psk:PagesPerSheet">
        <psf:Value xsi:type="xsd:integer">1</psf:Value>
       </psf:ScoredProperty>
      </psf:Option>
     </psf:Feature>
     <psf:Feature name="ns0000:JobXrxTrueTypeFontDlOption">
      <psf:Option name="ns0000:TTF_DOWNLOAD_AS_TRUETYPE" />
     </psf:Feature>
     <psf:Feature name="ns0000:JobXrxEdgeToEdge">
      <psf:Option name="ns0000:EDGE_TO_EDGE_OFF" />
     </psf:Feature>
     <psf:Feature name="ns0000:PageXrxHalftone">
      <psf:Option name="ns0000:XRX_NORMAL_HT" />
     </psf:Feature>
     <psf:Feature name="ns0000:JobXEROX_JOB_SETUP_BEGIN">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:JobXEROX_JOB_SETUP_END">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:DocumentXEROX_DOC_BEGIN">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:DocumentXEROX_DOC_SETUP_END">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:PageXEROX_PAGE_SETUP_BEGIN">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:PageXEROX_PAGE_SETUP_END">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:PageXEROX_PAGE_FINISH_BEGIN">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:PageXEROX_PAGE_FINISH_END">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:DocumentXEROX_DOC_FINISH_BEGIN">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:DocumentXEROX_DOC_FINISH_END">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:JobXEROX_JOB_FINISH_BEGIN">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="ns0000:JobXEROX_JOB_FINISH_END">
      <psf:Option name="ns0000:CB" />
     </psf:Feature>
     <psf:Feature name="psk:PageOrientation">
      <psf:Option name="psk:Portrait" />
     </psf:Feature>
     <psf:Feature name="psk:DocumentCollate">
      <psf:Option name="psk:Collated" />
     </psf:Feature>
     <psf:Feature name="psk:JobDuplexAllDocumentsContiguously">
      <psf:Option name="psk:OneSided" />
     </psf:Feature>
     <psf:Feature name="psk:PageResolution">
      <psf:Option name="ns0000:Res600x600">
       <psf:ScoredProperty name="psk:ResolutionX">
        <psf:Value xsi:type="xsd:integer">600</psf:Value>
       </psf:ScoredProperty>
       <psf:ScoredProperty name="psk:ResolutionY">
        <psf:Value xsi:type="xsd:integer">600</psf:Value>
       </psf:ScoredProperty>
      </psf:Option>
     </psf:Feature>
     <psf:Feature name="psk:PageOutputColor">
      <psf:Option name="psk:Grayscale">
       <psf:ScoredProperty name="psk:DeviceBitsPerPixel">
        <psf:Value xsi:type="xsd:integer">24</psf:Value>
       </psf:ScoredProperty>
       <psf:ScoredProperty name="psk:DriverBitsPerPixel">
        <psf:Value xsi:type="xsd:integer">24</psf:Value>
       </psf:ScoredProperty>
      </psf:Option>
     </psf:Feature>
     <psf:Feature name="psk:PageDeviceFontSubstitution">
      <psf:Option name="psk:On" />
     </psf:Feature>
     <psf:Feature name="psk:PageTrueTypeFontMode">
      <psf:Option name="psk:DownloadAsOutlineFont" />
     </psf:Feature>
     <psf:Feature name="psk:PageMediaType">
      <psf:Option name="psk:AutoSelect" />
     </psf:Feature>
     <psf:Feature name="psk:PageMediaSize">
      <psf:Option name="psk:NorthAmericaLetter">
       <psf:ScoredProperty name="psk:MediaSizeWidth">
        <psf:Value xsi:type="xsd:integer">215900</psf:Value>
       </psf:ScoredProperty>
       <psf:ScoredProperty name="psk:MediaSizeHeight">
        <psf:Value xsi:type="xsd:integer">279400</psf:Value>
       </psf:ScoredProperty>
      </psf:Option>
     </psf:Feature>
     <psf:Feature name="psk:PageOutputQuality">
      <psf:Option name="psk:Automatic" />
     </psf:Feature>
     <psf:ParameterInit name="ns0000:JobXeroxDriverData">
      <psf:Value xsi:type="xsd:string">yBQBHUQXAAAxTlJYAQAAAAwXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAldYK9wUAAQC6BhAAAAABAAcgwhPoAwAAAABNU0NGAAAAAJ0GAAAAAAAALAAAAAAAAAADAQEAAQAAADkwAABSAAAAAQABADMeAAAAAAAAAAAAAAAAAAAvL1VuY29tcHJlc3NlZC1EYXRhLy8Ancjm5UMGMx5DS8WZa2wUVRTH/zO7LS3lUdISgZayUioFinS3222riaYtVoFSmy4mNVFMpYugtOVpwJj4wWh8JCTGxBgfoIkfUIeET6ASE20iQR4qBUuLkag10BAxCCYaYoLnnHtnOt3ZUlBmdye798y9c2d/95xzz5yzW9/QEu8tGA6AXvUNy5rrG9qacw06yQPuDnJfW7M5j85NBPtKqClT8otzqFlIcpDPF9FHADzNXKzGS6dTc6eSK1iOKrmT5ZiSD4WoabHv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JdCtfa7KZdvqW+ZvRRhAM8X7N8nHFuq4+pH4fTd5e4Is2SMsIUramh1rjmQ+fmUYxRjEKkqpLxPXoutyNToZRsz1pOQ8yA+uEpwRpj20HyvG4bIzC8WiMouIT5lFIfoxg+zYlQss0P6VmqsF+3TMUt5fIc9M27PqbnEkK8NpDJDfb6LYuuS6XCtJ6hb/X0NFg+3xtRQxbLaaW8iWS0dyfm/p/B4Zze9zPPm9pfN7ZDS/z/Pk95bO75HR/H6SJ7+3JI9Wu0/lh0yR7vx+sie/t5z83s2V3vy+iI7keG+NGe+Rxnhf7In31pjxHmmM9yWeeG+NGe+RtnjfREdynWbpOg0ZrdPaPXWa8vtYkt+nu04zPHUac7l/zUJG6rQsT51mcz1BT8MNdE1m6rRsT53GXHGpzFhfXZKbbhW+dNZpEzx1mpWiTkvILkhnnTbFU6cxVxPFhw1SpSFDddo0T53GXOzd26UeQ0bqtEI6kvPV1HG1VOyGtOWrZZ581bqBfBU+56s76Uiua5krSt/EET9TdS0H1uQ8ep/+HaCL3t2kmx5dz24mRqUz3hHPUNsp+8KPl5ktP+//Rp8vHH9taMHB9nP8j8BUer9cwI9JDhQMFhejJnAeQ3I+Rjg0gD+K+DHGS+IN86T8QBUeL7zTvMsp5kXGmRekeVdSzKsab9khWTZnIhcKe/vrho0l1wzInyr8mjp/RI7od2EJsCvvbP6OQF/A/OsaT+d/gC6d7L56buX8ftOxMxk2qN5hSQMrJYAoKUSMG8moN5Eo6D9SY/pOsf94n38BAv////8AAB4zQ09NNQIAKAB3AGUAYgBkAGUAdgAuAHcAZQBiAHMAZQByAHYAZQByAC4AZQB4AGUABAAKAFQAaQBhAGcAbwAMAAQAAAAAAA0ABgABAG8I6go=</psf:Value>
     </psf:ParameterInit>
    </psf:PrintTicket>
    
    Regards, Tiago.
    Thursday, February 17, 2011 10:12 AM
  • Hello Tiago,

    hm!? There seems to be no xml-node for the inputbin (f.e. JobInputBin) in the printticket, which is strange...
    I hope the drive is not storing this in the private devmode-snapshot!?

    Did the call to GetInputBins() return some values in the dictionary??
    which printer-driver version are you using? maybe post a download-link...

    regards, Jo

    Thursday, February 17, 2011 5:14 PM
  • Hi Jo,
    I don't use GetInputBins() in my code because I know what tray I want to print, but I can test it to see if it is return values.
    My printer is Xerox Phaser 5550
    I'm using the driver "PCL6 Driver", version: 5.58.10 for Windows 7, 32 bits.
    http://www.support.xerox.com/support/phaser-5550/downloads/enus.html

    Thanks

    Thursday, February 17, 2011 5:40 PM
  • Hi Tiago, the installed driver (Xerox Phaser 5550B PCL6/Xerox Phaser 5550N PCL6) does not return any inputbins in the PrinterCapabilities when using GetInputBins() method. Therefor I guess the default printticket doesn't have a xml-node for the printticket, hence the ModifyPrintTicket() doesn't change it. Where did you get the values from you use for the inputbin? btw, remember that you'll always have to use values which the GetInputBins() returns, as inputbin differs on name or used namespaces etc. from printer to printer... regards, Jo
    Friday, February 18, 2011 10:13 AM
  • Hi Jo,
    I've done the function GetInputBins(), but how can I save the return of the function??

    regards

    Friday, February 18, 2011 10:46 AM
  • Hi Tiago, the installed driver (Xerox Phaser 5550B PCL6/Xerox Phaser 5550N PCL6) does not return any inputbins in the PrinterCapabilities when using GetInputBins() method. Therefor I guess the default printticket doesn't have a xml-node for the printticket, hence the ModifyPrintTicket() doesn't change it. Where did you get the values from you use for the inputbin? btw, remember that you'll always have to use values which the GetInputBins() returns, as inputbin differs on name or used namespaces etc. from printer to printer... regards, Jo


    I think the GetInputBins() doesn't return any value. What can I do?

     

    Thanks JO, regards

    Friday, February 18, 2011 3:15 PM
  • Hi Tiago, the installed driver (Xerox Phaser 5550B PCL6/Xerox Phaser 5550N PCL6) does not return any inputbins in the PrinterCapabilities when using GetInputBins() method. Therefor I guess the default printticket doesn't have a xml-node for the printticket, hence the ModifyPrintTicket() doesn't change it. Where did you get the values from you use for the inputbin? btw, remember that you'll always have to use values which the GetInputBins() returns, as inputbin differs on name or used namespaces etc. from printer to printer... regards, Jo


    Hi again Jo,

    I install the Global Print Driver and now my xml return the trays but when I print, the printer don't assume the trays that I sent in my code.

     

    Regards, Tiago

    Monday, February 21, 2011 10:54 AM
  • Hi Tiago,

    sorry being busy these days with my current project...

    So the GetInputBin() returns some inputbins now and you did use those values? Did you check if the ModifyPrintTicket() finds the node in the printticket-xml and modifies it?
    Does the XPS maybe contain printtickets on Job-,Document-, or Page-Level??
    You know that those getting merged during printing... have a look at the WritingPrintTicketRequired event handler, where you could provide printtickets for different levels (job-/document-/page-level) on-the-fly... see for example in "Reading and Printing XPS Documents" (PrintCapabilites and PrintTicket Usage)
    You could also attach the event-handler and check the tickets on the different levels...

    regards,
    Jo

    . 12

    Monday, February 21, 2011 12:05 PM
  • Hi Tiago,

    sorry being busy these days with my current project...

    So the GetInputBin() returns some inputbins now and you did use those values? Did you check if the ModifyPrintTicket() finds the node in the printticket-xml and modifies it?
    Does the XPS maybe contain printtickets on Job-,Document-, or Page-Level??
    You know that those getting merged during printing... have a look at the WritingPrintTicketRequired event handler, where you could provide printtickets for different levels (job-/document-/page-level) on-the-fly... see for example in "Reading and Printing XPS Documents" (PrintCapabilites and PrintTicket Usage)
    You could also attach the event-handler and check the tickets on the different levels...

    regards,
    Jo

     

    . 12

     

    Hi Jo, no problem, I appreciate your help!!

    The only diference between the XML of my HP to my XEROX is that in the XEROX the node is PageInputBin instead of JobInputBin, i can modify it with the correct values. But my printer does not assume the tray.

    The xml is OK, Maybe the problem are in my printer?? Some option...

    Regars, Tiago

    Monday, February 21, 2011 12:33 PM
  • In the PrintCapabilities-xml there can be JobInputBin-, PageInputBin- or DocumentInputBin-nodes depending on the printer... like I have already stated in one of the  posts above... So you have to enhance the GetInputBin()... I did it by reading all nodes...

    Did you check if the printticket xml getting modified correctly? does it find a node and change value? just debug it and see...maybe post a default-printticket xml...

    Did you also check if your XPS may contain other printtickets (at Job-/Document- or Page-level), so they may got merged with your modified printticket and override your inputbin setting... (you could rename XPS to .zip and extract content and see if you find printtickets inside)...how did you create the XPS?

    Remember that elements in lower-level PrintTickets override corresponding elements of higher-level PrintTickets...maybe that's the problem... just a wild guess.. just read the posted link for more informations... when printing your modified printticket is at job-level, means it can be overwritten by document or page-level printtickets, which could be in your xps...

     

    Monday, February 21, 2011 1:41 PM
  • In the PrintCapabilities-xml there can be JobInputBin-, PageInputBin- or DocumentInputBin-nodes depending on the printer... like I have already stated in one of the  posts above... So you have to enhance the GetInputBin()... I did it by reading all nodes...

    Did you check if the printticket xml getting modified correctly? does it find a node and change value? just debug it and see...maybe post a default-printticket xml...

    Did you also check if your XPS may contain other printtickets (at Job-/Document- or Page-level), so they may got merged with your modified printticket and override your inputbin setting... (you could rename XPS to .zip and extract content and see if you find printtickets inside)...how did you create the XPS?

    Remember that elements in lower-level PrintTickets override corresponding elements of higher-level PrintTickets...maybe that's the problem... just a wild guess.. just read the posted link for more informations... when printing your modified printticket is at job-level, means it can be overwritten by document or page-level printtickets, which could be in your xps...

     


    Yes Jo, it modify the printTicket. When I call the ModifyPrintTicket I save the xml, and I get the tray that I specified on code in the PageInputBin.

    Here it's my modified printTicket:

    <?xml version="1.0" encoding="UTF-8" ?> 
    - <psf:PrintTicket xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns:ns0000="http://schemas.microsoft.com/windows/printing/oemdriverpt/Xerox_Global_Print Driver PCL6/6.1.7600.16385/" xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords">
    - <psf:ParameterInit name="ns0000:PageDevmodeSnapshot">
     <psf:Value xsi:type="xsd:string">WABlAHIAbwB4ACAARwBsAG8AYgBhAGwAIABQAHIAaQBuAHQAIABEAHIAaQB2AGUAcgAgAFAAQwBMADYAAAAAAAEEAAbcAAgcQ/+ABwEACQCaCzQIZAABAA8AWAIBAAEAWAIDAAEAQQA0AAAAdABlAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</psf:Value> 
     </psf:ParameterInit>
    - <psf:ParameterInit name="psk:JobCopiesAllDocuments">
     <psf:Value xsi:type="xsd:integer">1</psf:Value> 
     </psf:ParameterInit>
    - <psf:Feature name="psk:JobNUpAllDocumentsContiguously">
    - <psf:Option>
    - <psf:ScoredProperty name="psk:PagesPerSheet">
     <psf:Value xsi:type="xsd:integer">1</psf:Value> 
     </psf:ScoredProperty>
     </psf:Option>
     </psf:Feature>
    - <psf:Feature name="psk:PageOutputColor">
    - <psf:Option name="psk:Grayscale">
    - <psf:ScoredProperty name="psk:DeviceBitsPerPixel">
     <psf:Value xsi:type="xsd:integer">24</psf:Value> 
     </psf:ScoredProperty>
    - <psf:ScoredProperty name="psk:DriverBitsPerPixel">
     <psf:Value xsi:type="xsd:integer">24</psf:Value> 
     </psf:ScoredProperty>
     </psf:Option>
     </psf:Feature>
    - <psf:Feature name="ns0000:PageXrxHalftone">
     <psf:Option name="ns0000:XRX_NORMAL_HT" /> 
     </psf:Feature>
    - <psf:Feature name="psk:PageOrientation">
     <psf:Option name="psk:Portrait" /> 
     </psf:Feature>
    - <psf:Feature name="psk:DocumentCollate">
     <psf:Option name="psk:Collated" /> 
     </psf:Feature>
    - <psf:Feature name="psk:PageDeviceFontSubstitution">
     <psf:Option name="psk:On" /> 
     </psf:Feature>
    - <psf:Feature name="psk:PageTrueTypeFontMode">
     <psf:Option name="psk:DownloadAsOutlineFont" /> 
     </psf:Feature>
    - <psf:Feature name="psk:JobDuplexAllDocumentsContiguously">
     <psf:Option name="psk:OneSided" /> 
     </psf:Feature>
    - <psf:Feature name="psk:PageInputBin">
     <psf:Option name="ns0000:tray-3" /> 
     </psf:Feature>
    - <psf:Feature name="psk:PageOutputQuality">
     <psf:Option name="psk:Normal" /> 
     </psf:Feature>
    - <psf:Feature name="psk:PageMediaType">
    - <psf:Option name="psk:Plain">
    - <psf:ScoredProperty name="psk:BackCoating">
     <psf:Value xsi:type="xsd:QName">psk:None</psf:Value> 
     </psf:ScoredProperty>
    - <psf:ScoredProperty name="psk:FrontCoating">
     <psf:Value xsi:type="xsd:QName">psk:None</psf:Value> 
     </psf:ScoredProperty>
    - <psf:ScoredProperty name="psk:Material">
     <psf:Value xsi:type="xsd:QName">psk:Paper</psf:Value> 
     </psf:ScoredProperty>
    - <psf:ScoredProperty name="psk:PrePrinted">
     <psf:Value xsi:type="xsd:QName">psk:None</psf:Value> 
     </psf:ScoredProperty>
    - <psf:ScoredProperty name="psk:PrePunched">
     <psf:Value xsi:type="xsd:QName">psk:None</psf:Value> 
     </psf:ScoredProperty>
    - <psf:ScoredProperty name="psk:Recycled">
     <psf:Value xsi:type="xsd:QName">psk:None</psf:Value> 
     </psf:ScoredProperty>
     </psf:Option>
     </psf:Feature>
    - <psf:Feature name="psk:PageMediaSize">
    - <psf:Option name="psk:ISOA4">
    - <psf:ScoredProperty name="psk:MediaSizeWidth">
     <psf:Value xsi:type="xsd:integer">210000</psf:Value> 
     </psf:ScoredProperty>
    - <psf:ScoredProperty name="psk:MediaSizeHeight">
     <psf:Value xsi:type="xsd:integer">297000</psf:Value> 
     </psf:ScoredProperty>
     </psf:Option>
     </psf:Feature>
     </psf:PrintTicket>
    
    Monday, February 21, 2011 2:51 PM
  • Hi JO,

    Problem Solved, the problem was on the driver, I remove all and install the driver for Xerox Phaser 5400, and it works fine.

    Many thanks again!!

    Can you help me it something.. I want to create a XPS File with text, like "Hello World". How can I do this?

     

    Regards, Tiago

    Monday, February 21, 2011 4:34 PM
  • Hi Tiago,

    glad it works now and was a driver-issue... (:

    to create an XPS with text you can do like this for example:

       
       // create a XPS package
       using (Package package = Package.Open(@"c:\temp\test.xps", FileMode.Create, FileAccess.ReadWrite))
       {
        // create new XPS document and a document-writer
        XpsDocument xpsDocument = new XpsDocument(package);
        XpsDocumentWriter xpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
    
        // create DrawinVisual and get drawing context
        DrawingVisual visual = new DrawingVisual();
        using (DrawingContext ctx = visual.RenderOpen())
        {
         // draw some blue text in Verdana 24 point
         FormattedText text = new FormattedText("Hello World!",
           System.Globalization.CultureInfo.CurrentCulture,
           System.Windows.FlowDirection.LeftToRight,
           new Typeface("Verdana"), 24 * 1.5,
           new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 0, 0, 255))
           );
         ctx.DrawText(text, new System.Windows.Point(250, 250));
        }
        // write the visual to the XPS document
        xpsDocumentWriter.Write((Visual)visual);
        // close document
        xpsDocument.Close();
       }
      }
    
    

    just a quick hack but should work... ofcourse you can place also images or draw lines/rectangles etc. on the drawing context of a visual, but I think you'll get the idea...

    regards,
    Jo

    Monday, February 21, 2011 4:55 PM
  • It's exactly what I want, now I just want to know the atributtes and how to use them, like I don't want a A4 page, I want A5(for example) how can I do this?

    I need to create a new PageSize or something like that inside of FormattedText or the other, right?

    Where can I read more about this?

    Many thanks JO, your help has been very helpful.

     

    Regards,

    Tiago

    Monday, February 21, 2011 5:37 PM
  • Hi Jo,

    Thanks for all the support, I had done it with the PrintTicket, maybe that can solve my problem.

    Regards, Tiago

    Tuesday, February 22, 2011 10:20 PM
  • Hi all!!

    If I have a XPS document witth 5 pages, and I want to print the first page to a printer, and the others pages to other print. Is that possible??

     

    Regards, Tiago


    Wednesday, March 23, 2011 10:34 AM