cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Generic / Text Only Driver does not work through CRVS2010 Runtime?

Former Member
0 Likes
1,460

I am having trouble printing to a Cypress printer. The Cypress printer uses the Microsoft Generic / Text Only Driver. The issue is that if I preview and print the report via the Crystal Reports for Visual Studio 2010 IDE in Visual Studio, the special Cypress codes print perfectly to the printer. If I run the same report through the CR for VS2010 runtime and do a PrintToPrinter, the codes get complete garbled and ruined. I am doing no formatting through the runtime, simply loading the report and then printing it directly. This issue does not happen with other printers (e.g. HP, Brother, etc).

Sample Cypress Codes:

^{form = TEST_FORM}

^{var note = "This is a note"}

Sample Print From VS2010 IDE to File (or printer):

^{form = TEST_FORM}

^{var note = "This is a note"}

Sample Print FROM Runtime:

^{for=SmEST_FORM}

^{var n=Tohei = "This is a }note"

Sample Print to file from Runtime using Generic/Text Only:

^{for

=m

T

EST_FORM}

^{var n

=o

T

t

"h

ei

s is

"a note

Does anyone have any suggestions? It works perfectly from the IDE, but fails every time from the runtime. Thanks!

Kyle

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

I suspect the issue here is that the framework may not support this printer driver(?). E.g.; when using the CR designer in the .NET IDE, you are using a viewer that does not depend on the framework. When you runt he report in your app, the print engine uses the framework. So, the question would be; can you print to that printer using .NET? E.g.; does something like what is described in the following work?

http://stackoverflow.com/questions/2417550/how-to-find-a-string-pattern-and-print-it-from-my-text-fi...

http://www.vbdotnetheaven.com/UploadFile/mgold/PrintinginVBNET04202005015906AM/PrintinginVBNET.aspx

- Ludek

Former Member
0 Likes

Yes, I have tested printing using straight .net 4 printing. I am using the Windows "Generic / Text Only" driver and printing to a file printer (text output). Printing outside of Crystal works perfectly and the lines work great. Printing in Crystal from the VS2010 works perfectly, too. But, printing through the CR2010 .net 4 runtime always garbles the output.

Thank you for the assistance in fixing this. It has become a critical issue for our customer.

Output using straight .net text printing to printer:

^{form = TEST_FORM}

^{var note = "This is a note"}

Test test test

Former Member
0 Likes

Just to add more notes, if I export to PDF it exports perfectly. If I export to a text file, it exports perfectly. Only printing to the printer using a Generic / Text Only printer driver messes up.

Former Member
0 Likes

Something to understand is that the CR engine sends pictures, not actual text strings to the printer. Also, the CR engine requires that any printer driver is Unicode compliant. From your descriptions, I think you may have to export the report to txt, then send that to the printer.

- Ludek

Former Member
0 Likes

I have isolated the issue down to the '=' character. This character causes the statements to really get messed up. Depending on the font it is better or worse.

Arial
befo=
    ra
     efter

Times New Roman
befo=r
     ae
      fter

Fixedsys
before
     =after

Courier New
before
     =after

Courier
before
     =after

Tahoma
befo=
    ra
     efter
Arial Unicode MS
befo=
    ra
     efter
 Modem
 befo=
     ra
      efter
 OCR A Extended
 before
      =after
 Roman
 befo=
     r
     ae
      fter

Is there any way to get around this, or is this some sort of weird bug? Thanks again.

0 Likes

Hi Kyle,

PrintToPrinter method is the basic print engine and it doesn't have full functionality nor is it "fixed"

Try using RAS and the PrintOutputController. This uses the common dialog Printer box but you can hard the values.



using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.ReportDefModel;
using CrystalDecisions.ReportAppServer.CommonControls;
using CrystalDecisions.ReportAppServer.CommLayer;
using CrystalDecisions.ReportAppServer.CommonObjectModel;
using CrystalDecisions.ReportAppServer.ObjectFactory;
using CrystalDecisions.ReportAppServer.DataSetConversion;
using CrystalDecisions.ReportAppServer.DataDefModel;

	public class frmMain : System.Windows.Forms.Form
	{
        CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

...

		private void btnSetPrinter_Click(object sender, System.EventArgs e)
		{
			System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
            CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();

            CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions MYPRTOpts = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();
			if (rdoCurrent.Checked) 
			{
				pDoc.PrinterSettings.PrinterName = cboCurrentPrinters.Text;

                MYPRTOpts.PrinterName = cboCurrentPrinters.Text;
                MYPRTOpts.PaperSize = (CrPaperSizeEnum)
					pDoc.PrinterSettings.PaperSizes[cboCurrentPaperSizes.SelectedIndex].Kind;
                MYPRTOpts.PaperSource = (CrPaperSourceEnum)
					pDoc.PrinterSettings.PaperSources[cboCurrentPaperTrays.SelectedIndex].Kind; 
				// added the below line to verify the changes work.
                MYPRTOpts.PaperOrientation = CrPaperOrientationEnum.crPaperOrientationLandscape;
			}
			else 
			{
				pDoc.PrinterSettings.PrinterName = cboDefaultPrinters.Text;

                MYPRTOpts.PrinterName = cboDefaultPrinters.Text;
                MYPRTOpts.PaperSize = (CrPaperSizeEnum)
					pDoc.PrinterSettings.PaperSizes[cboDefaultPaperSizes.SelectedIndex].Kind;
                MYPRTOpts.PaperSource = (CrPaperSourceEnum)
					pDoc.PrinterSettings.PaperSources[cboDefaultPaperTrays.SelectedIndex].Kind; 
			}
            rptClientDoc.PrintOutputController.ModifyPrintOptions(MYPRTOpts);
			MessageBox.Show("Printer set.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information ); 

			rptClientDoc.PrintOutputController.PrintReport(rasPROpts);
			MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information ); 

		}

Thank you

Don

Former Member
0 Likes

Thanks Don, that works! Now I have a few questions. What is the different between using the ReportAppServer ClientDoc printing and the normal PrintToPrinter? Can I export through it? Is there a number of things I need to implement to essentially create full PrintToPrinter() functionality again? I ask because we have a report manager that handles printing and exporting of 300 reports in our system and I don't want to change the full functionality of print for all reports unless it is absolutely necessary. Our report manager can set parameters, formulas, record select formulas, change databases, change table names, change print page settings, copies, etc, export to multiple formats on disk, and print to multiple printers. I do not want to introduce issues into the system. Would the settings from the ReportDocument be carried over to the ReportClientDocument option?

Thanks!

Edited by: kmfisher on Feb 14, 2011 6:18 PM

0 Likes

Hi Kyle,

It should have worked for You.... Don't load or view printer options off the report object, you may be loading the defaults saved in the RPT file again and overwriting the changes you did make.

RAS is the replacement for everything, the Engine was the report engine used in CR Basic for Visual Studio. It's very limited on what it can do. RAS can do everything, or what we've allowed so far.

I suggest you use that method always and not use PrintToPrinter, it's not much more code and has much better control. Also note that it is the RAS controllers that allow you to make changes other than basic stuff...

If you add those assemblies to your project and then use the Object browser and search on Controllers you'll find all of their abilities. Use the SDK help file also, some of the functions are private and should not be used. Everything public is listed in the help file.

Thank you

Don

Former Member
0 Likes

Don,

I have gotten it working with the full version of CR2010 for Visual Studio, but not with the runtime. It looks like the runtime has COM issues. We've tried this on multiple machines and the same error is always present. Is this a known issue and is there a workaround? Will SP1 correct the issue when it is released? Thanks.

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80040154): Class not registered - CrystalPrintControl
   at CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.PrintReport(PrintReportOptions options)
   at ReportPrinter.ReportPrinterForm.manualPrintButton_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

0 Likes

Hello,

New issue, please mark this as answered and then search for distribution issues and if you don't find the answer then post a new question.

Thank you

Don

Answers (2)

Answers (2)

former_member200290
Contributor
0 Likes

If this was demonstrated in other printer drivers we could definitely look at this as an issue, if it only happens with one particular printer driver, then the odds of this being our issue is pretty slim.

We use the printer driver to lay out the report, the metrics we get from the printer can cause line feeds if the text is no longer able to fit on the same line in the text box.

The problem is that if we go ahead and track this as an issue it will be a lower priority unless we can duplicate this with another printer. If we can confirmed that it is our issue it may be looked at by our developers. However this does not mean the printer driver is going to recognize what we send as the escape codes, after it is fixed. Nothing we print should be picked up by the printer driver as a code, and stripped, if it does this is considered incorrect behaviour on our part, and should be fixed so the printer no longer recognizes them.

Trevor

Former Member
0 Likes

Don Williams solution to use the RAS works. However, with COM Interop registration issues for the CR2010 32-bit runtime, it is not a viable solution that can be redistributed to users.

0 Likes

If it works in DEV then it will work for distribution. Check your Microsoft help file on how to distribute runtime.

Former Member
0 Likes

I concur with Don. Search these forums, use the search box in the top right corner of this web page. The solution is here. If you don't find anything that helps you, create a new thread. Remember the [rules of engagement|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagemen]; one issue per thread.

- Ludek

former_member200290
Contributor
0 Likes

As Don has mentioned for this new issue we need to work on a new thread.

However I do want to have a clear warning here that printer codes/printer escape codes have not been supported in our product since version 7 or 8 due to the way we changed our printing.

If you get this working we cannot guarantee that it will continue to work, as technically this is incorrect behaviour.

Kind Regards,

Trevor

Former Member
0 Likes

Trevor,

The escape codes may not be supported, but do text fields with text in them count as actual escape codes? From what I can tell, the codes are simply text fields in the reports at the top of the document. The fields are picked up by the Cypress Imaging system and stripped from the print document.

E.g. Cypress sees this: ^{FORM=MyForm} and strips this code off and overlays an image onto the print based on "MyForm".

The issue is that when using the Microsoft Generic / Text Only printer, the equal symbol in Crystal forces a line break, even though there is no linebreak in the text object. Depending on the font, a number of line breaks could be generated (Arial is particularly bad, Courier is only a single break). This seems to be a bug in the rendering engine when printing. Thanks.