Operation is not valid due to current state of object

Posted by: sanjeeb.srjm on 19 September 2021, 6:23 pm EST

    • Post Options:
    • Link

    Posted 19 September 2021, 6:23 pm EST

    Dear Sir/Mam,

    Whenever I try to call FlexReport.Print();

    the above error occurs…

    Please help us…

    Regards-

    Sanjeeb

  • Posted 20 September 2021, 9:39 pm EST

    Hello Sanjeeb,

    Would you please use the Generate method of FleReport before printing and try again? If the issue still occurs then, please let us know.

    FlexReport.Generate() 
    FlexReport.Print(result); 
    

    Regards,

    Prabhat Sharma.

  • Posted 20 September 2021, 9:54 pm EST - Updated 3 October 2022, 1:41 pm EST

    Dear Prabhat Sir,

    No error occurred by calling FlexReport.Generate() and printing very well.

    But, It still shows printing dialog as shown in image…

    But we would like to print fully silently…

    kindly suggest some tips like above.

    Regards-

    Sanjeeb

  • Posted 21 September 2021, 9:58 pm EST

    Hello Sanjeeb,

    As per your first post, it seems that you are using the code:

    FlexReport.Print()
    

    But for the case of printing directly, the C1PrintOptions instance is used. When you want to print the reports directly without showing all the settings behind the printing process, the Print methods of FlexReport with C1PrintOptions come to the rescue. So, please use the code snippet given below:

    
    Render(); 
    C1PrintOptions result = new C1PrintOptions();
    result.PrinterSettings = new PrinterSettings();
    result.PrinterSettings.PrinterName = "EPSON L360 Series";
    FlexReport.Generate() 
    FlexReport.Print(result); 
    

    https://www.grapecity.com/blogs/create-custom-print-dialog-print-directly-from-flexreport

    Regards,

    Prabhat Sharma.

  • Posted 21 September 2021, 10:44 pm EST

    Dear Prabhat Sir,

    I have used exactly you suggested like:-

    Render();

    C1PrintOptions result = new C1PrintOptions();

    result.PrinterSettings = new PrinterSettings();

    result.PrinterSettings.PrinterName = “EPSON L360 Series”;

    FlexReport.Generate()

    FlexReport.Print(result);

    But still shows the printing dialog …

    Regards-

    Sanjeeb

  • Posted 22 September 2021, 9:12 pm EST

    Hello,

    It seems that this is happening because of your printer settings, as we do not face the issue at our end. Would you please try with any other printer and see if the same issue persists.

    Also, if you still face the issue, please share a GIF of the process and your printer details.

    Regards,

    Prabhat Sharma.

  • Posted 25 September 2021, 3:58 pm EST

    Dear Prabhat Sir,

    I have tried the same in two printers located at two destination…

    1. EPSON L360 Series
    2. Canon LBP2900

    but same dialog still popups as shown in above snapshot…

    Sir, in this mode We are unable to print in Landscape mode.

    we have tried doing followings but couldn’t :-

    In short, only preview mode works for Landscape, not direct printed by flexreport…

    1. result.PrinterSettings.DefaultPageSettings.Landscape = true;

    2. result.PageSettings.Landscape = true;

    3. Layout l = FlexReport.Layout;

      l.PaperSize = System.Drawing.Printing.PaperKind.A4;

      l.Orientation = OrientationEnum.Landscape;

    4. FlexReport.PageSettings.Landscape = true;

    but nothing working…

    Regards-

    Sanjeeb

  • Posted 26 September 2021, 10:40 pm EST

    Hello Sanjeeb,

    >>but same dialog still popups as shown in above snapshot…

    As per your given screenshot, it seems that you are getting this dialog while printing, so this setting is specific to your printer driver.

    The specific code to print the report in landscape mode via code is given below:

    C1PrintOptions result = new C1PrintOptions();
       result.PrinterSettings = new Printing.PrinterSettings();
       result.PrinterSettings.DefaultPageSettings.Landscape = true;
       C1FlexReport1.Layout.Orientation = C1.Win.FlexReport.OrientationEnum.Landscape;
       C1FlexReport1.Render();
       C1FlexReport1.Print(result);
    

    If this does not help, please let us know why you are using the silent printing mode at your end?

    Regards,

    Prabhat Sharma.

  • Posted 28 September 2021, 1:35 pm EST

    Dear Prabhat Sir,

    Can you please send me the sample project which is printing silently

    and also working in Landscape mode ?

    So, that we can compare the difference with our code and dictate accordingly ?

    Please sir…

    Regards-

    Sanjeeb

  • Posted 28 September 2021, 10:15 pm EST

    Hello,

    Please find the sample attached.

    Regards,

    Prabhat Sharma.

    FlexReportDemo1.zip

  • Posted 29 September 2021, 1:41 am EST

    Dear Prabhat Sir,

    now looking towards your code we achieved landscape but working for only A4 Size not for Bank Cheque Paper Size (3.5X7.2)

    when we set custom size like below no custom size printing is being done…

    C1PrintOptions result = new C1PrintOptions();

    result.PrinterSettings = new Printing.PrinterSettings();

    result.PrinterSettings.DefaultPageSettings.Landscape = true;

    FlexReport.Layout.Orientation = C1.Win.FlexReport.OrientationEnum.Landscape;

    FlexReport.Layout.PaperSize = PaperKind.Custom;

    FlexReport.Layout.Width = 5040; //3.5 inch into twips

    FlexReport.Layout.CustomWidth = 5040;

    FlexReport.Layout.CustomHeight = 10368; //7.2 inch into twips

    FlexReport.Render();

    FlexReport.Generate();

    FlexReport.Print(result);

    Please help to print on custom size …

    Regards-

    Sanjeeb

  • Posted 30 September 2021, 8:33 pm EST

    Hello Sanjeeb,

    We are discussing this with the developers and will get back to you with the updates soon.

    [Internal Tracking ID: C1WIN-25790]

    Regards,

    Prabhat Sharma.

  • Posted 2 February 2022, 8:50 pm EST

    Dear Sir,

    Still waiting your kind support.

    sir, for winform standard silent printing we are using

    printDocument1.PrintController = new StandardPrintController();

    which is perfectly working…

    Regards-

    Sanjeeb

  • Posted 6 February 2022, 10:19 pm EST

    Hello Sanjeeb,

    As per the devs to set the custom page size via code to print silently via FlexReport use the code snippet given below:

    C1PrintOptions result = new C1PrintOptions();
    result.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
    result.PrinterSettings.DefaultPageSettings.Landscape = true;
    PaperSize ps = new PaperSize("Custom", 100, 100);
    result.PrinterSettings.DefaultPageSettings.PaperSize = ps;
    FlexReport.Print(result);
    

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels