views:

28

answers:

2

I've designed a crystal report that will be sent to a specific (barcode) printer through a web interface. Allowing the report to be generated in the standard crystal report viewer was causing issues, so I am now using the code-behind to send the report directly to the printer.

ReportDocument Report = new ReportDocument();                      
ParameterDiscreteValue Order = new ParameterDiscreteValue();

Order.Value = Convert.ToInt32(txtOrder);
Report.Load(reportPath);
Report.SetParameterValue("OrderNo", Order);

PageMargins margins;
margins = Report.PrintOptions.PageMargins;
margins.bottomMargin = 0;
margins.leftMargin = 0;
margins.rightMargin = 0;
margins.topMargin = 0;

Report.PrintOptions.ApplyPageMargins(margins);
Report.PrintOptions.PrinterName = "\\\\printserver\\Zebra  Z6M Plus (300dpi)";                
Report.PrintToPrinter(1, false, PageNum, PageNum);

Report.Close();

When printed from the designer (CRXI) everything works fine but when the web interface sends the job to a printer (any printer) it changes the font to Times New Roman which messes up all of the field sizes. If I use the standard .NET report viewer it uses the correct font, so I'm pretty sure the change is being caused by creating/using the ReportDocument.

How can I send the report directly to a print without it defaulting the fonts back to Times New Roman?

A: 

This idea occured to me:
Instead of sending the report straight from Crystal to the printer, what if you use some kind of middleman, i.e. export the .rpt to .pdf first, then print the PDF?

(Yes, it would be a very "wooden tables" tables approach, but if it works, it works.)

PowerUser
I run into the same issue sending it to a PDF as I do when I allow it to be generated in the .NET report viewer (which I believe processes it into a PDF to display).It does keep the correct font, but the barcodes I've added to the report are not processed correctly. One barcode displays incorrectly and the other two don't even show up at all.
wham12
A: 

While it seemed like the special font I was using had been included on every server imaginable, I was never able to get it to work through the web interface. I ended up finding a standard windows font that mostly suited the needs of this project and have given up on trying to beat this problem.

wham12