cancel
Showing results for 
Search instead for 
Did you mean: 

call (from script) which Tray is the Paper Source to be used when printing a report.

Former Member
0 Kudos

I need to be able to call (from script) which Tray is the Paper Source to be used when printing a report.  We have several printers which have multiple trays which are 8 1/2 x 11.  Different color paper is held in each and the setup lists the trays as "auto" , "manual feed", "Tray 1", "Tray 2", etc...  I need to be able to call from script (C#) that I want it to use "Tray 5".  In the Crystal Reports if you go to [File][Print] you can see all of the Trays listed under Printer Paper  |  Source:  How can I pass this to the report from C#?

            crReportDocument.PrintOptions.PaperSource = PaperSource("Tray 5");

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Don, You sent me an email (below) which I responded to begging for help.


Removed, that was personal...

I still have not heard anything.  What can I do to get help with this?

Pat McLaughlin

Message was edited by: Don Williams

0 Kudos

Hi Pat,

I had a chat with Sales and it was their mistake. Until we finish our version of the EStore software the will create a case for you.

Please call them again.

Thanks

Don

Former Member
0 Kudos

I just contacted them (AGAIN and AGAIN) so maybe, if anyone is answering their emails, they will contact one of us about my problem.

0 Kudos

Hi Pat,

Someone from the CIC team did ask me about you and I told them to just create the case for you yesterday.

They should have called you by now...

Don

Former Member
0 Kudos

Hi Don,

                I did get their ‘Auto Reply’ message last week, but nothing since. It said they would check on it and contact me but….  

What is frustrating is that I believe we are very close to a solution but nothing I try seems to make a difference. It is holding up a program that we have paid over ½ Million dollars to have created from being placed into production. Any help would be appreciated!

0 Kudos

Hi Pat,

Lets get back to the issue.... I did sent you a direct e-mail, did you not get it?

So for PrintToPrinter ( P2P ) it will not use the printer settings, it always uses the defaults or likely the first tray in the ENUM.

Try using the POC API to set the info, see my updated app for how to.

We will not change the default behavior of P2P, for custom changes you must use POC.

Don

Former Member
0 Kudos

Hi Don,

     I believe you are describing what I am seeing.  My ignorance is showing, What is a POC API?  How would I know it if I saw it?  How do I call it?

0 Kudos

Hi Pat,

POC is PrintOutputController. In my test app attached to KBA 2163438 I updated it recently, you can set the print button to use the POC API to do the printing.

One issue with that new property though is it does not use the paper tray as selected and saved in the RPT file. SP 15 will have this fixed and should be release end of this month.

It uses the same printer dialog box that CR Designer uses and should select the same printer as saved in the RPT file when any user tries to print ( except the tray is wrong )

See if that works for you.

Don

Former Member
0 Kudos

Good Morning Don,

     We are at least one step closer...  I stepped it through the code (after making my first try to change it to match your example) and when I got to the line 'rptClientDoc.PrintOutputController.PrintReport(rasPROOpts);', I could see that it in fact captured and was going to use the Tray Value and not default to the first one.  (I know I have a lot of clean up in the code yet).  However when it was stepped through this line it threw the error: "The document has not been opened"  I added 'rptClientDoc = crReportDocument.ReportClientDocument;' to the code.  It now lists out like it is passing the tray value etc. but it does not change trays.  I further tested the code adding: rasPROpts.NumberOfCopies = 2;.  It printed 2 copies but still only to tray 1 (even though tray 2 (enum - 259) was called.

Pat

Former Member
0 Kudos

Below you will find my code to date.  On top is a list of the variables passed into this segment and an example of the values passed.  This works fine as long as you always want tray 1.  The tray enums are derived from a sql table that was populated with the values shown in your RAS2010 program.  I am again at your mercy as I do not know what else to try.

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using CrystalDecisions.ReportAppServer.ClientDoc;

using CrystalDecisions.ReportAppServer.Controllers;

using CrystalDecisions.ReportAppServer.ReportDefModel;

lxReportXml = C:\WORK\PS0025P.XML  // Location/Name of XML file containing data for the report

lcFileName = C:\WORK\PS_PACKL.PDF  // Location/Name of PDF to produce if exported to PDF

lcPrinter = is3rd1  // Printer Name

lnCopies = 2  // Number of copies of the report to be printed

lnTrayVal = 259  // ENUM Value for the tray to be used (PaperSource)

lnDuplex = 0  // Printer Simplex/Duplex etc.

lcReportName = CR_Tow_Pack_List  // Name of Crystal Report file to use

lcOrientation = L  //(L)andscape or (P)ortrait

******************************************************************************************************************************

        public bool PrintReport(string lxReportXml, string lcFileName, string lcPrinter, int lnCopies, int lnTrayVal, int lnDuplex, string lcReportName, string lcOrientation)

        {

            bool PrintSuccessful = false;

            bool llError = false;

            DataSet ds = new DataSet();

            string filePath = lxReportXml;

            ds.ReadXml(filePath, XmlReadMode.Auto);

            if (lcFileName == "")

            {

                ServiceLogger.Instance.log("Error : No PDF file specified", LogEntryType.Debug);

                llError = true;

            }

            if (lxReportXml == "")

            {

                ServiceLogger.Instance.log("Error : No XML file specified", LogEntryType.Debug);

                llError = true;

            }

            if (lcReportName == "")

            {

                ServiceLogger.Instance.log("Error : No Crystal Report file specified", LogEntryType.Debug);

                llError = true;

            }

            if (lcPrinter == "")

            {

                ServiceLogger.Instance.log("Error : No Printer specified", LogEntryType.Debug);

                llError = true;

            }

            else

            {

                if (lcPrinter == "CCXCLR1")

                {

                    if (lnDuplex == 1)

                    {

                        //do nothing

                    }

                    else

                    {

                        lcPrinter = lcPrinter + lnDuplex.ToString();

                    }

                }

            }

            if (llError == false)

            {

                string strErrorMessage = string.Empty;

                string strReportPath_UNC = CommonUtilities.GetUNCPath(CommonUtilities.CrystalFilesPath) + lcReportName + ".rpt";

                if (!(File.Exists(strReportPath_UNC)))

                {

                    ServiceLogger.Instance.log("Crystal Report File [" + strReportPath_UNC + "] does not exist.Error message:", LogEntryType.Debug);

                    ServiceLogger.Instance.log("Crystal Report File [" + strReportPath_UNC + "] does not exist.Error message:", LogEntryType.Error);

                    PrintSuccessful = false;

                }

                else

                {

                    System.Drawing.Printing.PrintDocument crPrintDocument = new System.Drawing.Printing.PrintDocument();

                    CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();

                    CrystalDecisions.CrystalReports.Engine.ReportDocument crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                    crReportDocument.Load(strReportPath_UNC);

                    crReportDocument.SetDataSource(ds);

                    crReportDocument.SummaryInfo.ReportTitle = lcReportName;

                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                    CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions RASPO = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();

                    pSettings.PaperSource.RawKind = (lnTrayVal);

                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                    rasPROpts.PrinterName = lcPrinter;

                    rasPROpts.PaperSource = (CrPaperSourceEnum)lnTrayVal;

                    RASPO.DissociatePageSizeAndPrinterPaperSize = true;

                    CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

                    rptClientDoc = new CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument(crReportDocument); // ReportClientDocumentClass();

                    rptClientDoc = crReportDocument.ReportClientDocument;

                    rasPROpts.PrinterDuplex = (CrystalDecisions.ReportAppServer.ReportDefModel.CrPrinterDuplexEnum)lnDuplex;

                    switch (lcOrientation)

                    {

                        case "L":

                            {

                                rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationLandscape);

                                break;

                            }

                        case "P":

                            {

                                rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationPortrait);

                                break;

                            }

                        default:

                            {

                                rptClientDoc.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationDefault);

                                break;

                            }

                    }

                    rasPROpts.JobTitle = lcReportName;

                    rasPROpts.NumberOfCopies = 1;

                    rasPROpts.PaperSource = (CrPaperSourceEnum)lnTrayVal;

                    try

                    {

                        //Added loop to keep all pages together when multiple copies are requested

                        for (int i = 1; i <= (lnCopies); i++)

                        {

                        rptClientDoc.PrintOutputController.PrintReport(rasPROpts);

                        }

                    }

                    catch (CrystalReportsException ex)

                    {

                        ServiceLogger.Instance.log("Unable to create file [" + lcFileName + "].Error message:" + ex, LogEntryType.Debug);

                        throw ex;

                    }

                    catch (Exception ex)

                    {

                        ServiceLogger.Instance.log("Unable to create file [" + lcFileName + "].Error message:" + ex, LogEntryType.Debug);

                        throw ex;

                    }

                    finally

                    {

                        ServiceLogger.Instance.log("File [" + lcFileName + "] created Successfully", LogEntryType.Debug);

                        PrintSuccessful = true;

                    }

                }

            }

            return PrintSuccessful;

        }

0 Kudos

Hi Pat,

Did you get the e-mail from the system from me?
If you did please reply and I'll create a case for you.

Try adjusting this test app, Demo_Print...zip.txt, it uses no CR runtime and simply uses the framework to do the printing. See if you can use it to set the paper tray. This will tell us if it the printer or framework causing the problem.

Unzip it and then remove the txt extension and then you can unzip the project.

Another way is to try this CopyTo API test app, you can copy the printer info to and CopyFrom the report and it should also take what ever is on your PC.

Don

Former Member
0 Kudos

Good Morning Don,

     No email... (just the notification of your post here)

     Where would I find the Demo_Print.zip.txt?  There are no attachments or links. 

0 Kudos

HI Pat,

Try a different Browser, both are in my reply:

Former Member
0 Kudos

Demo_PrintDocument.zip.txt.zip worked as you described to open but a file is missing (PaperSizeGetter.cs) in the code.  RasCopyTest unzips to the .zip.txt but when you remove the .txt you get the following when you try to extract the files. Did you get a chance to look at the code I sent previous?  Anything pop out for a massive error?

0 Kudos

Sorry about that... I just notice it also....

Create the cs file and copy this into it:

using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.InteropServices;

namespace Unmanaged_RAS10_CSharp_Printers

{

    class PaperSizeGetter

    {

        public static string OutputPort = String.Empty;

        public static string paperName = String.Empty;

        [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

        public static extern int DeviceCapabilities(string pDevice, string pPort, short fwCapabilities, IntPtr pOutput, IntPtr pDevMode);

        public static int[] Get_PaperSizes(string printer, string paperName)

        {

            string text1 = printer;

            //string paperName;

            int num1 = FastDeviceCapabilities(0x10, IntPtr.Zero, -1, text1);

            if (num1 == -1)

            {

                return new int[0];

            }

            int num2 = Marshal.SystemDefaultCharSize * 0x40;

            IntPtr ptr1 = Marshal.AllocCoTaskMem(num2 * num1);

            FastDeviceCapabilities(0x10, ptr1, -1, text1);

            IntPtr ptr2 = Marshal.AllocCoTaskMem(2 * num1);

            FastDeviceCapabilities(2, ptr2, -1, text1);

            IntPtr ptr3 = Marshal.AllocCoTaskMem(8 * num1);

            FastDeviceCapabilities(3, ptr3, -1, text1);

            int[] sizeArray1 = new int[num1];

            for (int num3 = 0; num3 < num1; num3++)

            {

                string text2 = Marshal.PtrToStringAuto((IntPtr)(((long)ptr1) + (num2 * num3)), 0x40);

                int num4 = text2.IndexOf('\0');

                if (num4 > -1)

                {

                    text2 = text2.Substring(0, num4);

                    paperName = text2;

                }

                short num5 = Marshal.ReadInt16((IntPtr)(((long)ptr2) + (num3 * 2)));

                int num6 = Marshal.ReadInt32((IntPtr)(((long)ptr3) + (num3 * 8)));

                int num7 = Marshal.ReadInt32((IntPtr)((((long)ptr3) + (num3 * 8)) + 4));

                sizeArray1[num3] = System.Convert.ToInt32(num5);

            }

            Marshal.FreeCoTaskMem(ptr1);

            Marshal.FreeCoTaskMem(ptr2);

            Marshal.FreeCoTaskMem(ptr3);

            return sizeArray1;

        }

        public static int FastDeviceCapabilities(short capability, IntPtr pointerToBuffer, int defaultValue, string printerName)

        {

            int num1 = DeviceCapabilities(printerName, OutputPort, capability, pointerToBuffer, IntPtr.Zero);

            if (num1 == -1)

            {

                return defaultValue;

            }

            return num1;

        }

    }

}

I'll check the other file.

Don

0 Kudos

File extracts for me...

Download it, extract it to a folder and then remove the .txt extension so it's a zip file again and then unzip that and it should have the whole project...

And nothing obvious in your code. When I get a chance I'll try copying it into my main test app and see what happens.

Don

PS - I'll reply once again, it should have my e-mail address in it.

Answers (1)

Answers (1)

0 Kudos

Hi Pat,

See this new test app I am working on on how to set the various printer properties.

How you convert that to a Command line tool is up to you. Try Googling on how to create a Console application that uses variables.

For my latest version Top right corner search for KBA: 2163438

But it looks like you are using the correct API...

Use the Set Printer code to update the value each time.

You could use PrintOutputController and print Page 1, 2, 3, .... and set the tray to use for each either by hard coding the ENUM for the paper tray ( dynamically actually because each printer may have a unique ENUM for each Tray ) and then send each page to the printer as a separate print job.

How you save this info and where is up to you...

Don

Former Member
0 Kudos

Good Morning Don,

     I have read and reread dozens of posts and followed your links.  It appears I have not communicated my needs well enough.  Maybe this will zero in on what I need...

All trays hold 8 1/2 x 11 paper.  The user may have green paper in 4, yellow in 5, white in 2.  The Visual Studio program needs to be able to choose which color (tray) is used with each report.  In Crystal Reports 9, we used:

     loReport.PaperSize = lnTray      {lnTray was a numeric variable i.e. 5}

 

Obviously this is not valid in the current version.

0 Kudos

Hi Pat,

Try my new Printer test app I have in this KBA article: 2163438

It is the same thing I believe...

I get the Tray ENUM value also and list it in the box so you can see what it should be:

In the SetPrinter routine it uses this to set the paper tray and strip out the rest of the text so the final value is the paper ENUM value only:

Also note that if you have no printer saved in the report you must use and clone a dummy report with a printer attached to it. Then you can alter the tray.

Hope this helps?

Don

Former Member
0 Kudos

Hello Don,

     You are very close to my answer however I still have not found how to use it.  Let me explain what I am trying to accomplish...  We have an application (VS - C#)  that will be used on a computer that has in excess of 50 printers attached.  They are of different Manufacturers, different models, and different tray configurations.  In this application the user can call for a print from any one of over 100 Crystal Report files.  The user may have from 1 to 8 different trays on his printer and needs to be able to specify which one to use in each instance.  For example, he has 4 trays holding 8 1/2 x 11 paper and he has a different color in each.  When he calls for 'ReportX.rpt' he will specify that he wants it to print from 'Tray 3' (It has yellow paper).  User 2 from across the complex may call for 'ReportX.rpt' to print from 'Tray 2' (his yellow paper).  (The users have totally different printers)  I need to be able to designate in the program the correct tray for each.  In our old program (Foxprow) which we are replacing, we set up a table where we determined what the (to use your example) Enum for each printer and printer tray.  Then swapped the tray number with its value in the script.  Even though it worked, it is very cumbersome to maintain so we are trying very hard to find a way to query the printer for the values when the report is called for.  What I envision is a temporary dataset with columns of "Tray 1" "Tray 2" "Tray 3" ...  and filling a row of data to correspond with the current reality.  Is this possible?  If so, how do I get all possible Enum values to fill the data for the printer called for?

     In your example, it is looking for a combobox.SelectedValue  Is the whole script available somewhere or is that the SDK that is not available - Under Construction?

     Thank you for your help.

          Pat

0 Kudos

Hi Pat,

See the sample attached to this post: View the full discussion

Or search for KBA 2163438 same sample, KBA will be updated as I update the app, and it has a app that gets and sets tray values.

How you document or keep track of what tray has what color is up to you and then set the tray at runtime.

If you want to be able to configure each report for each user and allow them to select printers and trays you will need to create an interface to save that info and then save it in a database somewhere that can be queried per user/report.

CR can hold info about one printer and possible with page ranges but not all of them.

Open a report up in CR Designer and click the print button, that UI now allows you to change the printer properties and it is saved in the RPT if you save the report after making changes. But that is for anyone who opens the report. To have individual users default values you will nee to manage it yourself.

Don

PS - Script error is because it's based on SP 14, just comment out that line noted in the Forum post. It's new to SP 14 which I'm hoping will be release tomorrow.

Former Member
0 Kudos

Good Morning Don,

     I read your discussion and attempted to follow (download) your link.  What I got was a .txt file called RAS2010_Printing.txt.  When opened (in 4 different programs) I get this...

What program do I use to view it?

Thank you.

Pat

Former Member
0 Kudos

In one of your replys above you had...

Try my new Printer test app I have in this KBA article: 2163438

It is the same thing I believe...

I get the Tray ENUM value also and list it in the box so you can see what it should be:

Is this screen shot from Crystal Reports and if so, how can I get the ENUM value to display like this?  It would take a lot of the hassle out of making the DataTable for the individual printers!

Thanks,

Pat

0 Kudos

Hi Pat,

SP 14 is out now so that test app of mine should work fine now... Look at the code, I get the ENUM's this way:

Use KBA to get the application, I'll keep it up to date. And Forums does not allow zip file to be attached so we usually rename the zip to *.txt, System then zips it. Unzip the download, rename the txt to *.zip and then upzip that and you should get the project.

private void cboCurrentPrinters_SelectedIndexChanged(object sender, System.EventArgs e)
{
cboCurrentPaperSizes.Items.Clear();
cboCurrentPaperTrays.Items.Clear();
System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
    System.Drawing.Printing.PageSettings pPage = new PageSettings();

    pDoc.PrinterSettings.PrinterName = this.cboCurrentPrinters.Text;

foreach(System.Drawing.Printing.PaperSize myPaperSize in pDoc.PrinterSettings.PaperSizes)
{
        cboCurrentPaperSizes.Items.Add(myPaperSize.RawKind + ": " + myPaperSize.PaperName);
}
if (cboCurrentPaperSizes.Items.Count > 0)
{
  cboCurrentPaperSizes.SelectedIndex = 0;
}
foreach(System.Drawing.Printing.PaperSource  myPaperSource in pDoc.PrinterSettings.PaperSources)
{
  cboCurrentPaperTrays.Items.Add(myPaperSource.RawKind + ": " + myPaperSource.SourceName);
}
    if (cboCurrentPaperTrays.Items.Count > 0)
    {
        cboCurrentPaperTrays.SelectedIndex = 0;
    }
    CurrentUserDuplex.Text = pDoc.PrinterSettings.Duplex.ToString();
}

NOTE: - none of this is CR API's, all off the System.Drawing collections...

Don

Former Member
0 Kudos

I am obviously not looking at the right place.  Of my two previous posts, in the first one you see what I get when I go to your example... jibberish!

In the second, your answer seems to be correct, but in what script do I place that code?   Is it somewhere in Crystal Reports?  Is it somehow in my program?  I do not understand.

0 Kudos

Hi Pat,

Sorry I missed your gibberish reply... SCN will not allow you to attach zip files so what we do is rename the zip file to *.txt and then attach it. When you download unzip it because SCN zips the file. Now rename the *.txt to *.zip and unzip it again.

Use SP 14 and it should work for you now.

Or even easier is to go this this KBA and get the test app...

KBA number is 2163438, search for it in the upper right corner on this page.

PS - I just updated it again but I have not updated the KBA yet.

I added a check box to select P2P or POC when printing from the Viewer.

Don

PS - app is updated in KBA

Former Member
0 Kudos

Good Morning Don,

I am very close to an answer to my problem...  If I may, one more push and we are there.  Here is what I have.

           

crReportDocument = My Crystal Report document I am trying to print

lnTray = the Enum for the desired tray. (i.ex. 260)

I have tried many variations but cannot find the right way to pass this to the report. 

I have the following using statements in the process, am I missing one?

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

This is my latest failure...

 

           

crReportDocument.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Enum(lnTray);

What am I missing?

0 Kudos

Hi Pat,

Did you look at my code for setting the paper tray:

btnSetPrinter_Click

Notice also I am using RAS Document o be able to update the property. It could be the Engine is not capable.

    // this will return false if enum cannot be converted
    myNum = Int32.TryParse(MySTRTemp, out MyENUM1);
    newOpts.PaperSource = (CrPaperSourceEnum)MyENUM1;
}

CrNoPrinter.Checked = false;
CRPrinterName.Text = newOpts.PrinterName;
CRPaperTray.Text = cboCurrentPaperTrays.SelectedItem.ToString();
               
// using RAS to update the Printer properties
try
{
    rptClientDoc.PrintOutputController.ModifyPrintOptions(newOpts);
}

Don

Former Member
0 Kudos

Thank you for your patience Don...  I am down to one word!

This is what you said:

rptClientDoc.PrintOutputController.ModifyPrintOptions(newOpts);

changed to

crReportDocument.PrintOutputController.ModifyPrintOptions(lnTrayVal);

In my program it does not like .PrintOutputController

Error   'CrystalDecisions.CrystalReports.Engine.ReportDocument' does not contain a definition for 'PrintOutputController' and no extension method 'PrintOutputController' accepting a first argument of type 'CrystalDecisions.CrystalReports.Engine.ReportDocument' could be found (are you missing a using directive or an assembly reference?)



I also tried...

               crReportDocument.CrystalDecisions.ReportAppServer.ReportDefModel.ReportOptions.PaperSource = lnTrayVal;

It complains with .CrystalDecisions.


Error     'CrystalDecisions.CrystalReports.Engine.ReportDocument' does not contain a definition for 'CrystalDecisions' and no extension method 'CrystalDecisions' accepting a first argument of type 'CrystalDecisions.CrystalReports.Engine.ReportDocument' could be found (are you missing a using directive or an assembly reference?)

crReportDocument = my Crystal Report File I am trying to print

lnTrayVal = Enum of tray I am trying to print to. (261)

Message was edited by: Pat McLaughlin I need to confess my ignorance...  I have no clue what 'RAS' is or means or if necessary what to change.

0 Kudos

I thought you downloaded my printer test app in KBA 2163438?

Until you do this will not make much sense.

Don

Former Member
0 Kudos

I have downloaded, read, reread, and read again KBA 2163438.  I have downloaded your app, gone to all links and read them.  I have searched and read your code.  Unfortunately for me, this still does not make much sense.  With your help on this, I have created a process to be able to determine the Enum for each tray, in each printer, choose and write it to a variable in the code (lnTrayVal).  I just need to pass that to the print process before calling 'PrintToPrinter'.  I have the Duplex choice, Landscape/Portrait Orientations, number of copies etc. handled.  Now if I can get the Trays!!

0 Kudos

Hi Pat,

I'm sorry, you are trying to use P2P and my example is using RAS to set the PaperSource. I did not set that in that function...

So I updated my test app.. see if this works for you:

        // Using the P2P - PrintToPrinter or Viewers Print Button to print the report.
        private void btnPrintToPrinter_Click(object sender, EventArgs e)
        {
            System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
            CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();
            System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

            if (rdoCurrent.Checked)
            {
                printerSettings.PrinterName = cboCurrentPrinters.SelectedItem.ToString();

                System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                // Get/Set the Duplex of the printer if it's allowed
                // Set the selected Duplex setting and update the report
                rpt.PrintOptions.PrinterDuplex = (CrystalDecisions.Shared.PrinterDuplex)printerDuplexList.SelectedValue;

                pSettings.PrinterSettings.PrinterName = cboCurrentPrinters.SelectedItem.ToString();

                // parse the enum values from the drop down list boxes
                string MySTRTemp = cboCurrentPaperSizes.SelectedItem.ToString();
                int MyENUM = 0;
                int MyENUM1 = 0;
                MyENUM = MySTRTemp.LastIndexOf(@":");
                MySTRTemp = cboCurrentPaperSizes.Text.Substring(0, MyENUM);

                // this will return false if enum cannot be converted
                bool myNum = Int32.TryParse(MySTRTemp, out MyENUM1);

                string MyPaperSource = cboCurrentPaperTrays.SelectedItem.ToString();
                MySTRTemp = cboCurrentPaperTrays.SelectedItem.ToString();
                MyENUM = MySTRTemp.LastIndexOf(@":");
                MySTRTemp = cboCurrentPaperTrays.Text.Substring(0, MyENUM);

                // this will return false if enum cannot be converted
                myNum = Int32.TryParse(MySTRTemp, out MyENUM1);
                rpt.PrintOptions.PaperSource = (CrystalDecisions.Shared.PaperSource)MyENUM1;

                //pSettings.Margins.Left = 1;

See if that works for you

Don


PS - I just updated the KBA with the compete fix in both Default and User Printer selection area's

Message was edited by: Don Williams

Former Member
0 Kudos

That jumped that hurdle (Yea!!!!!) but the error I get now is...   'System.NotSupportedException' occurred in CrystalDecisions.CrystalReports.Engine.dll

It then goes on to print (From Tray 1)

I appreciate you hanging in there with me, we are now at least on the same page I believe.

0 Kudos

Hi Pat,

No idea what would generate that error. But sounds like it's something you are setting/altering for the System Printer properties.

Possibly the printer driver is not capable...????

Does my test app work for you? Try both P2P and POC.

Don

Former Member
0 Kudos

Good Morning Don,

     Unfortunately the answer to your question is "No, neither works"  In walking your app, I found that your Enum was taken from the Paper Size and not the Paper Source.  I adjusted the code to get it to find the Paper Source Enum but still got Tray 1 only.  In some juggling of the code, I did manage to get it to actually use the correct tray, until it found that the size did not match (11 x 17 paper in print tray instead of 8.5 x 11) and I got the error...

     "PrintScaling must be DoNotScale and Centered must be true when PrintOptions.DissociatePageSizeAndPrinterPaperSize is disabled.  Parameter name: layoutSettings"


(The dissociate is in fact checked)

Choosing a tray on this printer does work using the enum in the script written in Foxprow 9.  It also works with VS2013 when using VB.  The new program is in C#.

Is there any way to buy an "incident help" with this.  I tried to email this question to SAP Support but their answer was that it didn't concern "the portal" so I needed to look elsewhere.  I believe we are close but we need someone smarter than I to get over the top.

Thank you again!

0 Kudos

Hi Pat,

Are you sure about what you did was correct?

I select Paper Tray 1 which is ENUM 259 on the network printer here and it worked in both Set printer and P2P. I do need to fix the tray in the POC print button routine...

But P2P and Set Printer does have the correct number.

Don

0 Kudos

Hi Pat,

Thanks for the heads up on the tray code... I did fix it for all of the routines now and updated the download in the KBA.

P2P did work though...

To purchase a case here's the link -

Crystal Single Case Technical Support - SAP Business Objects US Online Store | SAP Online Store

Don

Former Member
0 Kudos

I just got approval and tried to use this link.  Here was my answer...

the "store.businessobjects.com" e-store has been closed.

Ben W.: as it was run by Digital River and that partnership has ended.

Ben W.: Unfortunately the Single Case is not available, I am sorry Don likely does not know that as he is not on the sales team. I would see if you can continue working with Don and see what workarounds he can help you develop. Our runtimes are meant for VS not C#


Obviously a 'Failure to Communicate' somewhere as I am using VS writing in C#, but if it is closed...

Any suggestions?  I am out of ideas for what to try next. 

0 Kudos

OK, try this link...

https://store.sap.com/sap/cpa/ui/resources/store/html/StoreFront.html?_s_icmp=Q112_eStore_SAPStore


I can't find where either....

Give sales a call and ask - +1-800-877-2340

Don

Message was edited by: Don Williams

Hi Pat,


More updates... I sorted this out, that link to purchase a single case is still valid. The problem was the SAP Sales team was not aware of this so please contact Ben W. again and he can process your request.

Let me know the Incident number and I'll grab it...

Don