$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
avatar image
Former Member

CrystalReportsException says that the printer cannot be found.

   Public Function PrintReport() As Boolean
        Dim PrintSuccessful As Boolean = False
        Dim llError As Boolean = False
        Dim ds As New DataSet()
        Dim rowCount As Integer
        Dim filePath As String = lxReportXml
        Dim lcReport As String = ""

        'ds.ReadXml(filePath, XmlReadMode.Auto)

        If lcProcName = "CSPREQ01" Then
            rowCount = TMINVCHD.Rows.Count
            lcReport = "Parts Report Request"
        ElseIf lcProcName = "CSREPR01" Then
            rowCount = tmreprdb.Rows.Count
            lcReport = "Customer Service Repair Request Worksheet"
        End If
#If DEBUG Then
        Dim strReportPath As String = CrystalFilesTesting + lcProcName + ".rpt"
#Else
        Dim strReportPath As String = CrystalFiles + lcProcName + ".rpt"
#End If

        If Not (File.Exists(strReportPath)) Then
            PrintSuccessful = False
            Call writelog("[ERR] Crystal Report File [" + strReportPath + "] does not exist.")
        Else
            Dim crPrintDocument As New System.Drawing.Printing.PrintDocument()
            Dim rasPROpts As New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions()

            Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
            crReportDocument.Load(strReportPath)
            crReportDocument.SummaryInfo.ReportTitle = lcReport

            Dim printerSettings As New System.Drawing.Printing.PrinterSettings()
            Dim pSettings As New System.Drawing.Printing.PageSettings(printerSettings)
            Dim RASPO As New CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions()
            pSettings.PaperSource.RawKind = (lnTrayVal)
            Dim pDoc As New System.Drawing.Printing.PrintDocument()
            Dim PrintLayout As New CrystalDecisions.Shared.PrintLayoutSettings()

            RASPO.DissociatePageSizeAndPrinterPaperSize = True

            Dim rptClientDoc As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument
            rptClientDoc = New CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument(crReportDocument)
            rptClientDoc = crReportDocument.ReportClientDocument


            rasPROpts.PrinterDuplex = DirectCast(lnDuplex, CrystalDecisions.ReportAppServer.ReportDefModel.CrPrinterDuplexEnum)
            rasPROpts.JobTitle = lcReport
            rasPROpts.PrinterName = lcPrinter
            rasPROpts.PaperSource = DirectCast(lnTrayVal, CrPaperSourceEnum)
            rasPROpts.NumberOfCopies = 1
            'rasPROpts.PaperSource = DirectCast(lnTrayVal, CrPaperSourceEnum)
            Try
                'Added loop to keep all pages together when multiple copies are requested
                For i As Integer = 1 To (lnCopies)
                    rptClientDoc.PrintOutputController.PrintReport(rasPROpts)
                Next
            Catch ex As CrystalReportsException
                rptClientDoc.Close()
                crReportDocument = Nothing
                Call writelog("[ERR] Unable to create file [" + lcProcName + "]. Error message:" + ex.ToString)
            Catch ex As Exception
                rptClientDoc.Close()
                crReportDocument = Nothing
                Call writelog("[ERR] Unable to create file [" + lcProcName + "]. Error message:" + ex.ToString)
            Finally
                rptClientDoc.Close()
                crReportDocument = Nothing
                Call writelog("File [" + lcProcName + "] created Successfully")
                PrintSuccessful = True
            End Try
        End If
        'End If
        Return PrintSuccessful
    End Function

**********************************************************************************************
rptClientDoc.PrintOutputController.PrintReport(rasPROpts)
When the line above runs, it throws a CrystalReportsException saying that the printer cannot be found.  The printer is in fact valid and without error.
Add comment
10|10000 characters needed characters exceeded

  • Former Member

    This is a screen shot of the rasPROpts just prior to this line being executed...

    Obviously the printer is defined as well as PaperSource and PrinterDuplex. I'm stumped, can anyone get me going?

    raspropts.png (55.2 kB)
  • Get RSS Feed

9 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 26, 2016 at 05:11 PM

    I think I may have just found the gremlin! The Printer Name is case sensitive and it was installed into the computer as all small letters. This has never been an issue before but can be handled if that is all it is.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 25, 2016 at 05:53 PM

    Hi Pat,

    Code missing, I don't have a declaration for the Printer name or other settings.

    Does the report have a Saved Printer name in it?

    Try my Printer test app in KBA 2163438, needs a report with saved data.

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 25, 2016 at 08:13 PM

    Ah yes, that is the same KBA/App.

    Are you using SP 18?

    Are all of the printer doing the same thing or just 1?

    What framework are you using?

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      SB18... I am using Version 13.0.2000.0

      Are all of the printers doing the same thing... Yes. Some reports will use tray 1 others will use tray 2 etc. but usually for paper color etc.

      Framework 4.0

      I will try to find SP18 for VS 2013

  • Oct 25, 2016 at 10:13 PM

    Hi Pat,

    13.0.2000.0 is the assembly version, it never changes. You can see the version you are using in Programs and Features.

    The Blog to get the updates is now here:

    https://blogs.sap.com/2010/12/07/sap-crystal-reports-developer-version-for-microsoft-visual-studio-updates-runtime-downloads/

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      It has now been updated to sp18 and ran again... I then added a line to ModifyPrinterName in rptClientDoc to try to force the issue but received the same error message. See Below...

      I can print the code to that printer from VS without any problem???!!!

      q8di0.png (45.6 kB)
  • Oct 26, 2016 at 01:10 PM

    Hi Pat,

    You said you get the printer info from a datatable.

    If you run my test app what do you see for the paper size and info, My app is querying the System for the printer info.

    Are you sure the custom paper size is the same on everyone's PC?

    The Seagull Scientific printer drivers have the ability to assign custom paper sizes to specific ENUM's, it is the only one I've seen that has the ability. When creating a new printer Microsoft auto assigns the ENUM so it typically will be different on each persons PC.

    Thanks again

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Here is the screen shot...

      We have used this method of picking trays for many years while using Crystal Reports and have had little problem with them changing.

      omkra.png (52.4 kB)
  • Oct 26, 2016 at 04:08 PM

    mmmm. Can you send me the report and the exact name of the printer you are using? I'll install it and test.

    What OS are you using and what Framework do you have set in your Project?

    Don

    PS - oops, I pointed out the paper size not tray but it does work for me on Windows 10

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member
      csrepr01.txt tmreprdb.xml

      The extention on the report was changed to .txt from .rpt to allow me to attach it. The xml is the data used in that report (copied from my W: drive). The Target framework for the application is .NET Framework 4.5 and I am using Windows 7 Operating System on the computer used to create the program. I have tried printing from your application and done so without error. If I remove the line rasPROpts.PrinterName = lcPrinter it will print to the default printer. (lcPrinter = IS3RD1 which is passed to the program by the file that initiates the process and is stored as a Global String variable. (Also shown in the screen print of your program in the prior post.)

      csrepr01.txt (256.0 kB)
      tmreprdb.xml (16.7 kB)
  • Oct 26, 2016 at 09:49 PM

    Hi Pat,

    Ah good to know... Since my app gets the name from the OS and not manually saved in a DB Field I never run into that problem.

    Thanks for sharing the solution...

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 27, 2016 at 12:39 PM

    The problem was found in that the [PrinterName] is case sensitive. Once they matched, all tested without error.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 28, 2016 at 03:10 PM

    Hi Pat,

    Please mark question as Answered.

    Thanks

    Don

    Add comment
    10|10000 characters needed characters exceeded