Results 1 to 12 of 12

Thread: [RESOLVED] Printer settings not working???

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Resolved [RESOLVED] Printer settings not working???

    I am having an issue where printer settings are not working correctly, i.e. they have no effect when output to the printer.

    Basically I am setting a heap of options but only these work:
    • Printer
    • Tray
    • Page range
    • Copies
    • Collate


    But I cannot get these working:
    • Resolution (PrintQuality is a selection from Document.PrinterSettings.PrinterResolutions): Document.DefaultPageSettings.PrinterResolution = PrintQuality.Resolution
    • Color (Document.PrinterSettings.SupportsColor reports correctly): Document.DefaultPageSettings.Color = chkColor.Checked
    • Duplex (Document.PrinterSettings.CanDuplex reports correctly): Document.PrinterSettings.Duplex = If(chkDuplex.Checked, Printing.Duplex.Simplex, Printing.Duplex.Default)


    What am I doing wrong??

    Thanks in advance,
    Kris

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Printer settings not working???

    It might be worth your while to send a PM to Merrion and asking whether he has time to view this thread. He's the local printing expert and is the most likely to be able to address your issue. Not to say that others won't be able to but he's your best bet and he might not see the thread otherwise.

  3. #3

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Printer settings not working???

    Thanks ... have sent him a PM ... fingers crossed

  4. #4
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Printer settings not working???

    Hmm - mysterious. What printer are you using and where are you setting the properties?
    Maybe (long shot) try setting these settings in the QueryPageSettings event?

    Have a read of Printing - a .NET developer's guide to see if that helps.

  5. #5

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Printer settings not working???

    Hi thanks for the reply ... and sorry about the delay...

    the printer is a Epson Workforce 633

    Code is as follows:
    vb Code:
    1. Private Sub ApplyPrintSettings()
    2.         Document.PrinterSettings.DefaultPageSettings.PrinterSettings.PrintToFile = False
    3.  
    4.         'Printer
    5.         'printer is already set...
    6.         'tray:
    7.         Dim PaperSource = TryCast(cboSource.SelectedItem, Printing.PaperSource)
    8.         If PaperSource IsNot Nothing Then
    9.             Document.DefaultPageSettings.PaperSource = PaperSource
    10.         End If
    11.  
    12.         'Quality
    13.         Dim PrintQuality = TryCast(cboQuality.SelectedItem, PrintQuality)
    14.         If PrintQuality IsNot Nothing Then
    15.             Document.DefaultPageSettings.PrinterResolution = PrintQuality.Resolution 'qwertyuiop - not working
    16.         End If
    17.         Document.DefaultPageSettings.Color = chkColor.Checked 'qwertyuiop - not working
    18.  
    19.         'Page Range
    20.         If rbPageAll.Checked Then
    21.             Document.PrinterSettings.PrintRange = Printing.PrintRange.AllPages
    22.         ElseIf rbPageRange.Checked Then
    23.             Document.PrinterSettings.PrintRange = Printing.PrintRange.SomePages
    24.             Document.PrinterSettings.FromPage = Math.Min(CInt(nudPageFrom.Value), CInt(nudPageTo.Value))
    25.             Document.PrinterSettings.ToPage = Math.Max(CInt(nudPageFrom.Value), CInt(nudPageTo.Value))
    26.         ElseIf rbPageSelection.Checked Then
    27.             If SelectionPageRange IsNot Nothing Then
    28.                 Document.PrinterSettings.PrintRange = Printing.PrintRange.SomePages
    29.                 Document.PrinterSettings.FromPage = SelectionPageRange.From
    30.                 Document.PrinterSettings.ToPage = SelectionPageRange.To
    31.             Else
    32.                 'shouldn't happen as rbPageSelection will be disabled... but just incase...
    33.                 Document.PrinterSettings.PrintRange = Printing.PrintRange.AllPages
    34.             End If
    35.         End If
    36.  
    37.         'Copies
    38.         Document.PrinterSettings.Copies = CShort(nudCopies.Value)
    39.         Document.PrinterSettings.Collate = chkCollate.Checked
    40.         Document.PrinterSettings.Duplex = If(chkDuplex.Checked, Printing.Duplex.Simplex, Printing.Duplex.Default) 'qwertyuiop - not working
    41.  
    42.     End Sub

    Thanks,
    Kris

  6. #6
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Printer settings not working???

    very curious - I can't see where (in the PrinterSettings) you would specify the actual resolution if you choose PrinterResolution.Custom ??

    (I do most of this kind of thing with API calls as I had written them before the PrinterSettings class came along)

  7. #7

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Printer settings not working???

    Quote Originally Posted by Merrion View Post
    very curious - I can't see where (in the PrinterSettings) you would specify the actual resolution if you choose PrinterResolution.Custom ??

    (I do most of this kind of thing with API calls as I had written them before the PrinterSettings class came along)
    They appear to be pre-sets I think ... Have a look at the one-note printer below:

    Name:  Print.png
Views: 2930
Size:  47.9 KB

  8. #8
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Printer settings not working???

    I notice that the settings you are having trouble with come from the DeviceMode ... I wonder if that is not saving correctly.

  9. #9

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Printer settings not working???

    Sorry ... I don't quite get what you mean???

    This is my code to load the Quality settings:

    vb Code:
    1. Private Class PrintQuality
    2.         Public Property Resolution As Printing.PrinterResolution
    3.  
    4.         Public Overrides Function ToString() As String
    5.             If Resolution.Kind = Printing.PrinterResolutionKind.Custom Then
    6.                 Return "Custom (" & Resolution.X & " x " & Resolution.Y & " DPI)"
    7.             Else
    8.                 Return Resolution.Kind.ToString
    9.             End If
    10.         End Function
    11.  
    12.         Public Sub New(Resolution As Printing.PrinterResolution)
    13.             Me.Resolution = Resolution
    14.         End Sub
    15.     End Class
    16.  
    17. '....
    18. 'This happens on printer change:
    19.  
    20.         cboQuality.DataSource = Document.PrinterSettings.PrinterResolutions.OfType(Of Printing.PrinterResolution).Select(Function(x) New PrintQuality(x)).ToArray
    21.         cboQuality.Enabled = cboQuality.Items.Count > 0
    22.         cboQuality.SelectedItem = cboQuality.Items.OfType(Of PrintQuality).FirstOrDefault

    ... and still doesn't explain why colors not working, may be an issue with my printer driver (is that what you meant)??

    Thanks,
    Kris

  10. #10
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Printer settings not working???

    Yes - it may well be an issue with the printer driver or rather the way that the System.Drawing.Printing library is coded against it.

    Maybe try using the PrintQueueWatch component to set the .Colour setting for the printer and see if that works?

  11. #11
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Printer settings not working???

    Or maybe try using the PrinterSettings.GetHDevMode and SetHDevMode functions?

    vb.net Code:
    1. /// <summary>
    2.     /// Creates a handle to a DEVMODE structure that corresponds to the printer and the page settings specified through the <paramref name="pageSettings"/> parameter.
    3.     /// </summary>
    4.     ///
    5.     /// <returns>
    6.     /// A handle to a DEVMODE structure.
    7.     /// </returns>
    8.     /// <param name="pageSettings">The <see cref="T:System.Drawing.Printing.PageSettings"/> object that the DEVMODE structure's handle corresponds to. </param><exception cref="T:System.Drawing.Printing.InvalidPrinterException">The printer named in the <see cref="P:System.Drawing.Printing.PrinterSettings.PrinterName"/> property does not exist. </exception><exception cref="T:System.ComponentModel.Win32Exception">The printer's initialization information could not be retrieved. </exception><PermissionSet><IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" version="1" Unrestricted="true"/></PermissionSet>
    9.     public IntPtr GetHdevmode(PageSettings pageSettings);
    10.  
    11.     /// <summary>
    12.     /// Copies the relevant information out of the given handle and into the <see cref="T:System.Drawing.Printing.PrinterSettings"/>.
    13.     /// </summary>
    14.     /// <param name="hdevmode">The handle to a Win32 DEVMODE structure. </param><exception cref="T:System.ArgumentException">The printer handle is not valid. </exception>
    15.     public void SetHdevmode(IntPtr hdevmode);

    ?

  12. #12

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Printer settings not working???

    Got it working .. was actually working originally... just not on my printer ... tried it on another and all working w/o problems

    Kris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width