W_K
W_K

Reputation: 33

Loading a pdf file in Visual Basic Windows form?

I have seen tutorials on how to open pdf files into the windows form, but they show how to open it by creating a button that will find it from the directory. I want the pdf file to be displayed already, as soon as the user loads that Window form. I have installed the Adobe pdf reader in the component toolbox, and put the following code with the load function of the form: Public Class Adding_Worksheet

    Private Sub Adding_Worksheet_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Call AxAcroPDF1.LoadFile(0, "D:\Mixed_Addition_1.pdf")

    End Sub
End Class

I have adapted this from when I added an swf file, which had no problems in loading. I know the zero is incorrect above, but i am not sure what to write there. the additional code i had for the swf file was AxShockwaveFlash1.Play(). would i need to do something like AxAcroPDF1.Load()?

Upvotes: 0

Views: 22289

Answers (2)

Tim
Tim

Reputation: 1

Maybe he didn't want to use a web browser to open a PDF file. Right click the item in toolbox, when designer is active, select choose items, select COM components, and select Adobe. Then add code to new form. Printer will be active. You can disable "Toolbar" in properties tab.

Imports AxAcroPDFLib Imports AcroPDFLib Public Class TripSheet

'
'AxAcroPDF1
'

Public Sub New()

    ' This call is required by the designer.
    InitializeComponent()
    AxAcroPDF1.Location.Equals(AxAcroPDF1.LoadFile("C:\path\file.pdf"))
    AxAcroPDF1.LoadFile("C:\path\file.pdf")
    ' Add any initialization after the InitializeComponent() call.

End Sub

Upvotes: 0

Gojira
Gojira

Reputation: 3051

If all you want to do is display a PDF and nothing else, why not use a System.Windows.Forms.WebBrowser control, and make the URL "D:\Mixed_Addition_1.pdf" ?

Upvotes: 3

Related Questions