Print Directly

hiii alex

for example i am at invoice form once the invoice is made i want to print the invoice directly on a button click without showing the preview without showing the print dialogbox or anything AS FAST AS POSSIBLE I NEED TO PRINT INVOICE from printer

how can i do that and for this i am sure that i have to set printer how to do that also ??


with regards
k

Comments

  • edited 8:36AM
    Hello,

    Use the following code:

    Report report = new Report();
    report.Load(...);
    report.RegisterData(...);
    report.PrintSettings.ShowDialog = false;
    report.Print();
  • edited 8:36AM
    Hi Alex,

    Webform app can print directly as you mentioned?


    Rgds,
    Viery

  • edited 8:36AM
    Hello,

    No, WebForms app cannot print directly. You need to export your report to PDF.
    You may use the following code:
            protected void Button1_Click(object sender, EventArgs e)
            {
                FastReport.Utils.Config.WebMode = true;
    
                using (Report report = new Report())
                {
                    report.Load("your_report.frx");
                    report.RegisterData(...);
                    report.Prepare();
    
                    // Export report to PDF stream
                    FastReport.Export.Pdf.PDFExport pdfExport = new FastReport.Export.Pdf.PDFExport();
                    using (MemoryStream strm = new MemoryStream())
                    {
                        report.Export(pdfExport, strm);
    
                        // Stream the PDF back to the client as an attachment
                        Response.ClearContent();
                        Response.ClearHeaders();
                        Response.Buffer = true;
                        Response.ContentType = "Application/PDF";
                        Response.AddHeader("Content-Disposition", "attachment;filename=report.pdf");
    
                        strm.Position = 0;
                        strm.WriteTo(Response.OutputStream);
                        Response.End();
                    }
    
                }
            }
    

    In this case, you don't need WebReport component.
  • khhkhh
    edited June 2010
    In web:
    How to print current page?
    How to bring adobe reader print dialog automatically?
    Dose interactive charts works?
  • edited 8:36AM
    Hello,

    It's all not possible in webreport.
  • edited August 2010
    This one issue is keeping me from using FastReport.NET in my web applications. To print a page using FastReport.NET there are really 5 steps.

    Once a FastReport.NET report is on the screen:
    1. Press FastReport.NET PRINTER icon.
    2. In the File Download dialog box press "OPEN"
    3. File opens in a new window for Adobe Reader. (yes this is a step because the widow has to be closed when done)
    4. Click PRINT icon in Adobe Acrobat Reader.
    5. Click OK in the print dialog

    That's 5 steps to print a single page.

    However, Developer Express ExtraReports has it down to the following 2 steps:
    1. Print Current Page (there is a button to print current page or entire report)
    2. OK in the print dialog button.

    Only two steps for a web report. FastReport is a great product and I use it for all my VCL reports. But there has to be a way to improve the product in this one area. My customers wouldn't accept my products if I gave them 5 steps to print a web based report.
  • khhkhh
    edited 8:36AM
    Same with me!

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.