on 07-19-2015 7:38 PM
Hello,
I have a created an application that prints a Crystal Report straight from it.
This is used by a client of mine.
We have found that on certain printers, the report will print PJL code in between the report.
For example:
EDDI
111 Tester Road
Jackson, TX 11111
@PJL SET JOBNAME="Crystal Reports - Report Name"
EDDI
111 Tester Road
Jackson, TX 11111
@PJL SET COMMENT="HP Photosmart 6510 series; Windows Vista 6.3 " | |
This should only show the first three lines and then continue with the Crystal report.
Does anyone know what could be causing this? Is it the printer, the Crystal Report or the program?
Thanks for your help in advance!!
Eddi Rae
Hi Eddie
Not knowing what CR SDK you are using, I moved your query to the SAP Crystal Reports, version for Visual Studio SCN Space.
So, the 1st question obviously would be; what CR SDK are you using?
What development language
What version of CR - please be precise, including any updates.
What printer drivers do you see this behavior with?
Win or web app?
Can you reproduce the issue?
Can you post the code used in your app?
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow me on Twitter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What CR SDK are you using? - I am not sure where to look for this.
What development language - Visual Basic 2010
What version of CR - please be precise, including any updates. - Crystal Reports for .NET Framwork
What printer drivers do you see this behavior with? - some HP printers. The HP Photosmart 6510 mentioned above is the one we are working with
Win or web app? - Win
Can you reproduce the issue? - I don't have the printer with me, but the consultant that I am working with has the printer and, yes, we can reproduce the error.
Can you post the code used in your app? - Here is my code below. This is what is used for the ReportViewer.
Imports System
Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Imports System.Math
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Windows.Forms.SaveFileDialog
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports OMI_Reports.modOMIData
Imports OMI_Reports.modOMI_Reports
Imports OMI_Reports.frmOMI_Reports
Public Class frmReportViewer
'Dim Settings As System.Drawing.Printing.PrinterSettings
Private Sub frmReportViewer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objRpt As New ReportDocument
Dim objRpt1 As New ReportDocument
Dim objRpt2 As New ReportDocument
Dim objRpt3 As New ReportDocument
Dim sDefaultPrinter As String
sDefaultPrinter = DefaultPrinterName()
Hide()
Text = strVersion
Select Case UCase(sReport)
Case "OPER", "LIST"
objRpt = New rptOPER
objRpt.SetDataSource(dsOper)
objRpt.SummaryInfo.ReportTitle = "Client List" & strReportHeader & vbCrLf & strContactPhone
strReportComments = ""
objRpt.SummaryInfo.ReportComments = strReportComments
Case ("HISTORY")
objRpt = New rptHISTORY
objRpt.SetDataSource(dsHistory)
objRpt.SummaryInfo.ReportTitle = "History Report" & strReportHeader & vbCrLf & strContactPhone
strReportComments = "Pre-FVC Test History Report W/ Deviations from Previous Test."
objRpt.SummaryInfo.ReportComments = strReportComments
Case "ENL"
objRpt = New rptENL
objRpt.SetDataSource(dsHistory)
objRpt.SummaryInfo.ReportTitle = strReportHeader & vbCrLf & strContactPhone
strReportComments = ""
objRpt.SummaryInfo.ReportComments = strReportComments
Case "OVERVIEW", "OVERVIEWD"
objRpt = New rptOVERVIEW
objRpt.SetDataSource(dsOverview)
objRpt.SummaryInfo.ReportTitle = "Overview Report" & strReportHeader & vbCrLf & strContactPhone
strReportComments = strVersion
objRpt.SummaryInfo.ReportComments = strReportComments
Case "BAR"
objRpt = New rptBARCHART
objRpt.SetDataSource(dsOverview)
objRpt.SummaryInfo.ReportTitle = "Bar Chart" & strReportHeader & vbCrLf & strContactPhone
strReportComments = ""
objRpt.SummaryInfo.ReportComments = strReportComments
Case "DETAIL"
objRpt = New rptDETAIL
objRpt.SetDataSource(dsDetail)
objRpt.SummaryInfo.ReportTitle = "Detail Report" & strReportHeader & vbCrLf & strContactPhone
strReportComments = ""
objRpt.SummaryInfo.ReportComments = strReportComments
Case "TRENDGRAM"
objRpt = New rptTRENDGRAM
objRpt.SetDataSource(dsHistory)
objRpt.SummaryInfo.ReportTitle = "TrendGram - Absolute Values" & strReportHeader
strReportComments = strContactPhone
objRpt.SummaryInfo.ReportComments = strReportComments
Case "TRENDGRAM1"
objRpt = New rptTRENDGRAM1
objRpt.SetDataSource(dsHistory)
objRpt.SummaryInfo.ReportTitle = "TrendGram - Percent Predicted" & strReportHeader
strReportComments = strContactPhone
objRpt.SummaryInfo.ReportComments = strReportComments
Case "TRENDGRAM2"
objRpt = New rptTRENDGRAM2
objRpt.SetDataSource(dsHistory)
objRpt.SummaryInfo.ReportTitle = "TrendGram - Percent Deviations from Baseline" & strReportHeader
strReportComments = strContactPhone
objRpt.SummaryInfo.ReportComments = strReportComments
Case "COMBO"
If sOverviewRpt = "TRUE" Then
objRpt2 = New rptOVERVIEW
objRpt2.SetDataSource(dsOverview)
objRpt2.SummaryInfo.ReportTitle = "Overview Report" & strReportHeader & vbCrLf & strContactPhone
'objRpt2.PrintOptions.PrinterName = sDefaultPrinter
objRpt2.PrintToPrinter(1, False, 0, 0)
End If
If sDetailRpt = "TRUE" Then
objRpt1 = New rptDETAIL
objRpt1.SetDataSource(dsDetail)
objRpt1.SummaryInfo.ReportTitle = "Detail Report" & strReportHeader & vbCrLf & strContactPhone
' objRpt1.PrintOptions.PrinterName = sDefaultPrinter
objRpt1.PrintToPrinter(1, False, 0, 0)
End If
If sENLRpt = "TRUE" Then
objRpt3 = New rptENL
objRpt3.SetDataSource(dsHistory)
objRpt3.SummaryInfo.ReportTitle = strReportHeader & vbCrLf & strContactPhone
'objRpt3.PrintOptions.PrinterName = sDefaultPrinter
objRpt3.PrintToPrinter(1, False, 0, 0)
End If
Me.Close()
Exit Sub
Case Else
Exit Sub
End Select
If sPrinter = "YES" Then
Hide()
objRpt.PrintOptions.PrinterName = sDefaultPrinter
objRpt.PrintToPrinter(1, True, 0, 0)
Me.Close()
Else
Show()
crvReportViewer.ReportSource = objRpt
crvReportViewer.Refresh()
End If
'WindowState = FormWindowState.Maximized
End Sub
Public Shared Function DefaultPrinterName() As String
Dim oPS As New PrinterSettings
Try
DefaultPrinterName = oPS.PrinterName
Catch ex As System.Exception
DefaultPrinterName = ""
MsgBox("Error in getting Default Printer")
Finally
oPS = Nothing
MsgBox("Default Printer: " & DefaultPrinterName)
End Try
End Function
End Class
Thanks for your help in advance!!
Eddi Rae
Hi Eddi
" Crystal Reports for .NET Framwork" is not quite what I meant by precise
Look at the crpe32.dll (C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86). It will have a version of 13.0.xx. If it is not 13.0.14, I'd like you to go here: and update to SP 14 - both your dev system and runtime computer. On dev, make sure to use the install executable, not the MSI. Recompile the app and redeploy.
I'd also like you to check if there are any updates for the HP Photosmart 6510 driver. Also, make sure you are using the correct driver for the OS.
- Ludek
When I go here:
HP Software and Driver Downloads for HP Printers, Laptops, Desktops and More | HP® Support
it looks like the latest driver is from Aug 2014. If you agree can you update to that driver version?
- Ludek
Sorry for the long delay.
I now have the printer in my possession. I am adding the drivers as we speak.
In fact, the printer is an HP Photosmart 5525.
Where would the driver be placed? I am seeing a UNIDRV.dll in the C:\Windows\System32\spool\drivers\x64\3 folder, but I don't think that is where it has been installed.
I am on a Windows 8 PC now.
Hi Eddi,
Does this happen every time you print or randomly?
Does it only happen in your application or does it also happen when printing from CR Designer?
If you preview the report and then print it does it happen also?
In SP 14 you can now set the Viewers Print button to use the PrintOutputController (POC) rather than the default PrintToPrinter (P2P) which is the same API you are using in code.
See if printing using POC stops this happening.
And then search for KBA 2163438 and download the sample app I attached and see if you get the same results. It's in C# but should be relatively easy to understand. Open the report, Select the printer on the top left area, click Set Printer button and then try using both P2P and POC buttons to print.
Then preview the report with saved data, no log on option, and see if changing the Viewers print mode makes any difference.
Also did a google search on that error and found multiple hits. One suggestion is to look in the event logs to see if the driver is generating an error. Anything in your logs?
Don
Couple of other things Don asked me to tack on after he did his reply:
1) Try the app attached to this KBA:
2163438 - How do I make Crystal Reports for Visual Studio print my reports?
2) Create a new test report. No DB connection, just add a textbox with "Hello World" in the Page Header. See how that prints.
- Ludek
Hello Don,
I have created an application that adds data into a dataset and then takes that dataset and places it into a Crystal Report that hides the report viewer and the use can either print it directly to the printer or preview.
The customer sends this application out to his customers which most printers work properly, but some don't. The printer that I have is one of his printers that is having the issue. He does have other printers that do not print the PJL code at all. It prints correctly.
This printer, no matter if I print directly to the printer or preview the report and then print seems to add the PJL code and not any of the report.
I just previewed the report without running the program and the preview print worked perfectly.
I changed the report viewer PrintMode to use the PrintOutputController and it still printed the PJL.
I have attached the application code so that you can see how I have coded it.
It's funny that this is not happening on all printers; just a few.
============================================================================================================
Hello Ludek,
I already had the current version of Crystal Reports installed.
I created a new project in VS 2010 and added a new report that just had a textbox with the text of "Hello World". I previewed the report and printed it and it didn't have any of the PJL code like my report has.
Okay ... We have part of this working.
My son had a 5520 printer and we printed with preview and it works great!! When we print without preview is when we now get the PJL code.
So, it seems that it is when I print it directly to the printer.
We are getting somewhere!!
Thanks again for all of your help!!
Eddi Rae
Hi Eddi
Thanks for sticking with this . This is a rather interesting issue that we've never seen before. So, to continue. The fact that a simple report prints fine indicates that the problem report has some object in it that the CR engine is misinterpreting. Now the hard work starts...
To try and figure out what object is causing issues, you will have to back up the report. Then, start removing sections from the report, one at a time, doing a printing after each section is removed, until there is no PJL Code printed. Then you have to go back to the back up rpt and start removing objects one at a time from the section in question. Again, print the report after each object is removed, until the report prints as expected. This will isolate the object causing us grief. Unfortunately, no other way of troubleshooting this that I can think of.
- Ludek
Hello Ludek,
I finally found the time to start on stripping the report to see when the report creates the PJL code.
I removed everything except for the header and it is printing the PJL code.
The header has the current date and time and the Report title.
I even removed the report title for one test and then removed the date and time. It still printed the PJL code.
I am using a dataset as the datasource, but I am not placing any of it on the report for my test.
I am not sure what else to do with this.
Thanks for all of your help!!
Eddi Rae
Okay ... I started from scratch and only added the datasource as the datatable.
It still printed the PJL code.
I did find what it is, though. It is the ReportTitle. I commented out the line with the reporttitle and it printed properly. When I uncommented the reporttitle, that is when the PJL code printed instead of the report.
Case "OVERVIEW", "OVERVIEWD"
objRpt = New rptOVERVIEW
objRpt.SetDataSource(dsOverview)
objRpt.SummaryInfo.Dispose()
objRpt.SummaryInfo.ReportTitle = "Overview Report" & strReportHeader & vbCrLf & strContactPhone
strReportComments = strVersion
objRpt.SummaryInfo.ReportComments = strReportComments
Can you think of any reason why?
Thanks for all of your input!!
Eddi Rae
Ludek,
I did a little more research on the reporttitle field and found that it is the "vbCrLf" that I have in that field.
This field, depending on the report is set to be multiple lines by using the vbCrLf between the lines.
I tried using the vbNewLine as well as the chr(10) & chr(13). Those didn't work either.
I removed the field strReportHeader and the vbCrLf and just had the words Overview Report and the phone number in the field and it worked. The reason that I removed the strReportHeader is that I also place vbCrLf in that field.
When I moved the code to the objRpt.SummaryInfo.ReportComments, then it printed fine. It seems that you cannot use a new line function in the objRpt.SummaryInfo.ReportTitle field.
Thanks for all your help again!!
Eddi Rae
Hi Eddi,
Great find the source of the issue...
I'll ping DEV and see if they have anything to say and if there is for some reason why our text editor is interpreting the escape sequence as a PJL code command.
No looking back at your first post we should have looked in the Summary Title first.
Thanks
Don
Hi Eddi,
I'm curious if this happened the same way in an earlier version of CR for VS. SP 8 I had DEV extended the amount of data able to be saved in the Summary info. So curious if it was a problem back then also? It will tell us if the fix they did is the cause or if it's always been that way.
Would you be willing to test this for me?
Here's a link to SP 7:
http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_7.exe
One thing you need to consider also, That field is used when Printing and Exporting, it gives the output job/file name a title. So there is a good possibility you will not be able to use anything other that a single line of text in that property.
Can you use a different field of the summary info, Comments will/should accept those control escape sequences....
Thanks again
Don
In my application, the user can select any one of the 9 reports that come from the application. The ReportTitle gives the report name and the company name and address for that report.
Remember, having these fields in the ReportTitle worked for most printers. I had to move to the ReportComments to get it to work on the printers that were printing the PJL code.
Hi Eddi,
Ah, so there is no specific requirement to have to using the Title then.... Just for display purposes only....
All I can suggest is to not add a LF or CR to the Title because that field is used internally by CR and BOE and does not allow those control codes.
What CR is doing with those characters is stripping them out, if you save/export the report to RPT format and then open them in CR Designer you'll see the tab has removed the characters, simply no allowed.
You cannot added them in CR Designer so you should not add then using the SDK.
A good thing I like to do when coding is to test it in CR Designer first, if it's possible then use the same work flow in code, if you can't do it in CR Designer then do not do it in code....
I suggest changing your template reports then, use the Summary Info Title for the name of the report ONLY and add all other info to the Comments, then simply build the info for displaying purposes only...
Thanks again
Don
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.