on ‎2011 Feb 10 10:18 PM
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
Request clarification before answering.
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://www.vbdotnetheaven.com/UploadFile/mgold/PrintinginVBNET04202005015906AM/PrintinginVBNET.aspx
- Ludek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
fterIs there any way to get around this, or is this some sort of weird bug? Thanks again.
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
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
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
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)
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.