Search code examples
c#crystal-reports

CrystalReports PrintToPrinter do not print anything


My problem is a bit strange. I have code as below:

    private bool print(int copies)
    {
        const string nameMethod = "print";
        try
        {
            LogHandler.Start(nameMethod);
            m_objMyRepDoc.ReadRecords();
            m_objMyRepDoc.PrintToPrinter(copies, false, 0, 0);
            return true;
        }
        catch (Exception ex)
        {
            LogHandler.LogError(nameMethod, ex);
            return false;
        }
        finally
        {
            LogHandler.Finish(nameMethod);
        }
    }

and this is used for couple different rpt files. For 9 out of 10 it prints. For 1 do not. I tried this on other pc and there it prints 10/10. Same version of crystal report runtime.

I also tried adding

m_objMyRepDoc.ExportToDisk(ExportFormatType.PortableDocFormat, "test"+DateTime.Now.Millisecond+".pdf");

before PrintToPrinter to check how this report looks and on this faulty machine generated pdf is correct.

Does anyone have any idea how to find one why this machine has problem with one of 10 reports? There is no errors. Method is ending without exception.


Solution

  • In case of this issue please check page setup under file menu in the crystal reports.

    There you can find a No Printer flag. After disabling this my report begin to print. Don't know why it was being printed on other machines although using same rpt file.