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 7:22PM
    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

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.