1
votes

I recently updated a Crystal Report from an unknown version to v13. This report prints to a Zebra TLP2844 label printer using 6"x4" labels (6" long, 4" wide as they come out of the label printer). Before the update, everything worked fine. Afterwards, I cannot print the labels in landscape. No matter what settings I use, I always get portrait.

Here are the settings I have in Visual Studio 2010: enter image description here

My printing code:

 public void print_label(CTapeID myTape)
    {
        _myTape = myTape;
        LabelReport crystalPrint;  // name of report class
        CPrinterObject po;

        CPrinterInfo pi;
        String printerType = "LABEL_4060";
        LabelInfo cpd; // name of dataset class for the report

        try
        {
            crystalPrint = new LabelReport();

            crystalPrint.ReportOptions.EnableSaveDataWithReport = false;

            po = new CPrinterObject();
            pi = po.FindPrinter(printerType);

            if(pi != null)
            {
                crystalPrint.PrintOptions.PrinterName = pi.PrinterName;

            }

            crystalPrint.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;

            cpd = GetLabelData();
            crystalPrint.SetDataSource((DataSet)cpd);
            crystalPrint.PrintToPrinter(1, false, 1, 0);

            crystalPrint.Close();
            crystalPrint.Dispose();
        }
        catch(Exception ex)
        {
            ex.Source = MethodBase.GetCurrentMethod().Name + "(): " + ex.Source;
            throw ex;
        }
    }

CPrinterObject and CPrinterInfo are internal classes that get the printer name and properties.

1
Does it work if you manually print (i.e. using CR) the report in landscape mode?craig
@craig : If I go to Crystal Reports - Preview Report, I get the correct orientation.CurtisHx
But, what happens if you actually print it? You want to make sure that you eliminate this potential point of error (the printer's driver).craig
Your code reads crystalPrint.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;. Shouldn't this read crystalPrint.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;?craig
That totally just got you a downvote.SteveCav

1 Answers

0
votes

I just spent three and a half days tracking down this problem and reading zillions of old unanswered "I have this problem too. Did you ever solve it?" posts. I just finally cracked it.

No matter what code settings and paper sizes you choose, Crystal hates Zebra and will arbitrarily decide portrait/landscape, because it knows better than you.

What solved it for me was:

  • Go into Print Management (not printer settings)
  • Right-click on the printer
  • Go to to "Set Printing Defaults"
  • Set the paper size to something blatantly wrong (I said my 10cm x 2cm label was 10cm x 20cm), but big enough for it to STFU and stop choosing it for you.