Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1158
  • Last Modified:

How to print PDF directly to printer in ASP.NET

What I really need to do is print a report done in SQL Server Reporting Services directly to printer but it doesn't have a print option.  So what I did was export the report to a PDF file then print it directly to a printer.

I had this working before with this code:

        Dim FileName As String = "c:\InetPub\wwwRoot\HSAdminDev\PDFReports\BarCodes.PDF"
        Dim p As New System.Diagnostics.ProcessStartInfo
        p.Verb = "print"
        p.WindowStyle = Diagnostics.ProcessWindowStyle.Hidden
        p.FileName = FileName
        p.UseShellExecute = True
        Try
            System.Diagnostics.Process.Start(p)
        Catch ex As Exception
            PrintSuccessMsg = ex.Message
        End Try

It suddenly stopped working and couldn't get it to work again.  It also opens up a process for adobe acrobat, but nothing happens.

Anyone knows of another method of printing a PDF file directly to printer in ASP.NET?
0
n0ell
Asked:
n0ell
  • 3
1 Solution
 
AerosSagaCommented:
0
 
AerosSagaCommented:
Theres a .NET Library for that as well here:

http://sourceforge.net/projects/report/

Regards,

Aeros
0
 
ncacnioCommented:
Thanks Aeros.

The code was actually working though.  It was printing to a different printer - it just chooses the first printer installed on the server.

0
 
AerosSagaCommented:
Dim wrdApp As New Word.Application
    wrdApp.Documents.Open("C:\temp\temp.doc")
    wrdApp.Dialogs.Item(Word.WdWordDialog.wdDialogFilePrint).Show()
    wrdApp.Visible = False
    wrdApp.ActiveDocument.PrintOut = False
    wrdApp.ActiveDocument.Close()
    wrdApp.Quit()

ps this also does pdf
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now