Print direct to printer

Hello everyone!

I'm using FastReport.Net with Visual Studio 2012, VB language and have the following code:
wrote:
Private Sub PovoaRelatorio(ByVal pParametro As String, ByVal pOrdem As String)
Dim pSQL As String
pSQL = " SELECT * FROM v_empresas "
If Trim(pParametro) <> DBNull.Value.ToString Then pSQL = pSQL & " WHERE " & pParametro
If Trim(pOrdem) <> DBNull.Value.ToString Then pSQL = pSQL & " ORDER BY " & pOrdem Else pSQL = pSQL & " ORDER BY Empresa_RazaoSocial "

SqlDataSource1.SelectCommand = pSQL
SqlDataSource1.DataBind()

WebReport1.ReportFile = Server.MapPath("reEmpresas.frx")
WebReport1.Refresh()


End Sub


But when you click the print button, it asks to download the report in pdf. How do I go straight to the printer without downloading any files?

grateful,

Ilano Caldas

Comments

  • edited August 2014
    Could make the local printing using the code below:

    Protected Sub BtnImprimir_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles BtnImprimir.Click
    WebReport1.Report.PrintPrepared()
    WebReport1.Report.Print()

    End Sub

    However, by posting on the server is returning the following error:

    Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

    How to solve this problem?

    Just remember that it is WebForm!
  • Paulo FreirePaulo Freire S??o Paulo - Brasil
    edited 5:44AM
    Ol?? Ilanocf

    Bem, eu uso C#, n??o deve ser diferente

    Clique do bot??o

    pNumero = Convert.toInt32(txtPedido.Text);

    WebReport report = new WebReport();
    report.Width = 600;
    report.Height = 800;
    report.ReportFile = Server.MapPath("~/relatorios/pedidos_nro.frx");
    report.Report.SetParameterValue("@nro_pedido";, pNumero);

    report.Report.Prepare();
    report.ToolbarIconsStyle = ToolbarIconsStyle.Black;

Leave a Comment