使用vb.net打印图像pdf或文本pdf

时间:2014-02-25 13:10:59

标签: vb.net

我们可以使用acrobat打印图像或文本PDF吗?是否有任何3方dll可以包含在我们的vb.net代码中。

我尝试过使用primopdf软件,但有点混淆了如何添加.net应用程序。 有没有解决方案来处理print pdf。

谢谢

1 个答案:

答案 0 :(得分:0)

Imports System.Runtime.InteropServices
Imports System.IO

Public Class PDFPrinter

#Region " CONSTANTS "
    Private Const SW_SHOWNORMAL As Integer = 2
#End Region

#Region " API "
    <DllImport("shell32")> _
    Public Shared Function ShellExecute(ByVal hWnd As IntPtr, _
                                        ByVal lpOperation As String, _
                                        ByVal lpFile As String, _
                                        ByVal lpParameters As String, _
                                        ByVal lpDirectory As String, _
                                        ByVal nShowCmd As Integer) As IntPtr
    End Function
#End Region

#Region " PUBLIC MEMBERS "
    Public Function PrintPDF(ByVal FilePath As String) As Boolean
        If IO.File.Exists(FilePath) Then
            If ShellExecute(1, "Print", FilePath, "", _
            Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32 <= 32 Then
                Return False
            Else
                Return True
            End If
        Else
            Return False
        End If
    End Function
#End Region
End Class

SOURCE