cancel
Showing results for 
Search instead for 
Did you mean: 

Setting PaperSource

Former Member
0 Kudos

I am having a difficult time getting our printers to print from a specific tray. I have set the papersource property to Upper, Lower, Middle, even Manual, and I cannot get the printer to choose the tray that I am sending. I have tried checking the No Printer option in Page Setup and checked the Dissociate Formatting Page Size and Printer Paper Size to no avail.

Any thought, Ideas...

Thanks,

Brad clark

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This code works for me:

Public Function GetPaperSizeIndex(ByVal PaperName As String, Optional ByVal Impresora As String = "") As Integer
        If PaperName.Trim.Length = 0 Then Return -1

        If _PaperSizeArrayList Is Nothing OrElse _PaperSizeArrayList.Count > 0 OrElse Impresora <> _ultPrinterName Then
            _PaperSizeArrayList = Me.GetPaperSizeList(Impresora)
            _ultPrinterName = Impresora
        End If

        Try
            For i As Integer = 0 To PaperSizeArrayList.Count
                Dim wcomboitem As clsComboItem = PaperSizeArrayList.Item(i)
                If UCase(PaperName) = UCase(wcomboitem.getDescripcion) Then
                    Return wcomboitem.getValor
                End If
            Next
        Catch ex As Exception
            Throw ex
        End Try

        Return -1

    End Function

and to get de PaperSizeArrayList:

Private _PaperSizeArrayList As New ArrayList

Public Function GetPaperSizeList(Optional ByVal printername As String = "") As ArrayList

        _PaperSizeArrayList.Clear()

        Dim printdoc As New System.Drawing.Printing.PrintDocument

        Try

            If printername <> "" Then
                printdoc.PrinterSettings.PrinterName = printername
            End If

            For Each pksize As PaperSize In printdoc.PrinterSettings.PaperSizes
                _PaperSizeArrayList.Add(New clsComboItem(pksize.RawKind, pksize.PaperName))
            Next

        Catch ex As Exception
            MsgBox("GetPaperSizeList:" & ex.Message)
        End Try

        Return _PaperSizeArrayList

    End Function

Former Member
0 Kudos

I am able to retrieve the various PaperSizes and PaperSources. The problem is no matter which one I print to, it always comes out of the same tray. (Even though we have an application called "Optio" that uses the same driver and can print to either tray...)

Former Member
0 Kudos

I think I just figured it out..

It seems I have to use the Source "Manual Feed in Tray 1"...even though that is the wrong tray...lol. Whatever works I guess.

Answers (2)

Answers (2)

Former Member
0 Kudos

In the spirit of hopefully helping someone out, here's what worked for me:

Within Crystal Reports, the Print Setup was set to use "letter" size paper.  But no matter which PaperSource I selected, the job always printed to the lower tray, which happens to be filled with letter-size paper.

The fix was to also set the PaperSize value...

  1. to match the media in the specified PaperSource,
  2. and to overrule the setting within the RPT file.

So in my case, this failed to take effect:

CReport.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Middle

But this succeeded:

CReport.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLegal

CReport.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Middle

The lesson learned was that if the PaperSize setting in the RPT file does not match up to the actual physical paper size specified PaperSource setting in code, the print job will automatically switch over to another PaperSource that does have the correct media size.  Which will present to you as "no matter what I do, it doesn't work!"

I ended up using this code to achieve what I needed:

CReport.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter

CReport.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Lower

former_member183750
Active Contributor
0 Kudos

You will probably have to find the enum for the tray and set that. Download the devcap utility from here:

https://sapmats-us.sap-ag.de/download/download.cgi?id=8XWQKVKRIOFDVEB813HXKX252LGSM5GPSVZSLOVS7AII3W...

and see what it tells you for the enum. Then set that to the PaperSource property in your code.

Ludek

Former Member
0 Kudos

I had the exact same problem with my HP LaserJet P4015 printers. We just switched from HP LaserJet 4350 printers - and we were setting the PaperSource to print to Tray2 just fine. Now it has no effect. It always prints to Tray 3 instead of the Letterhead tray (Tray2).

To make it work, we switched to using the PrintOptions.CustomPaperSource instead - this allows you to set the RawKind to a number that is returned from the printers PaperSource.RawKind when you find a papersource that matches the one you want to use. This is generic for changes in the tray numbers - which happens every time you change drivers - it also allows us to have the PaperSource for each report in the database - which overrides what is in the RPT file.


System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
pd.PrinterSettings.PrinterName = MyReport.PrinterName;
foreach (System.Drawing.Printing.PaperSource ps in pd.PrinterSettings.PaperSources)
{
//Trim data from Driver, and take the first one that Starts with our PaperSource name (ie: 'Auto' matches 'Automatically Select' and 'Auto Select')
if (ps.SourceName.Trim().StartsWith(MyReport.PaperSource))
{
   MyCrystalReport.ReportDoc.PrintOptions.CustomPaperSource = new System.Drawing.Printing.PaperSource();
   MyCrystalReport.ReportDoc.PrintOptions.CustomPaperSource.RawKind = ps.RawKind;
   break;
  }
}
//If nothing matches MyReport.PaperSource it will use the papersource in the crystal RPT file instead of MyReport.PaperSource.

David

Former Member
0 Kudos

I am having the same problem. It is an HP 2420 printer.

The download link to get the enum doesn't work anymore.

I tried using the "RawKind" suggestion and it always prints to the upper tray.

Any other suggestions?

former_member183750
Active Contributor
0 Kudos

Try [this|https://sapmats-us.sap-ag.de/download/download.cgi?id=DFII1P3U9MKLHDUNEQ4VGFI7RC1LL3411P2IDRAZH0CZLSCLOL] link after 8:30 AM PST. The file should be replicated to the ftp server by then.

Ludek

Former Member
0 Kudos

When I run the program I get the following:

Bin Info:

Supported Bin Types:

15 USER DEFINED

259 USER DEFINED

258 USER DEFINED

257 USER DEFINED

Named bins:

Automatically Select

Cont. Feed - No Break

Cut Sheet

Cont. Feed - With Break

Let me give you a little more detail. I am writing a DOT Net application that calls a Crystal Report and prints it to a defined tray. I need this application to work so we can get rid of a piece of software that we are using called "Optio". This "Optio" software uses the exact same driver (from the same server) as the one I pulled the information from above using the DevCap utility. The Optio application is set to print to "Upper" and it works. Although, no matter what I do everything prints to the Tray 1 manual. They have the printer loaded with White Paper in the manual tray and Yellow paper in the Tray 1 (upper tray).

I have tried the following "PaperSource" values:

PaperSouce.Lower

PaperSouce.Middle

PaperSouce.Upper

PaperSouce.Manual

Then, I tried the values from above:

15

257

258

259

Also, I tried using the other suggestion and setting the "RawKind". I queried the PaperSources using the code provided and retrieved the value for the "Tray 1" and used that.

All of these just send the output to the White Paper in the "flip-out" Tray 1 "Manual" tray...

Any suggestions, anyone?