vb.net 以 Visual Basic Windows 形式加载 pdf 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15233619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:37:48  来源:igfitidea点击:

Loading a pdf file in Visual Basic Windows form?

vb.netpdf

提问by W_K

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

我看过有关如何将 pdf 文件打开到 windows 窗体中的教程,但它们显示了如何通过创建一个可以从目录中找到它的按钮来打开它。我希望 pdf 文件已经显示,只要用户加载该窗口表单。我已经在组件工具箱中安装了Adobe pdf reader,在表单的加载函数中放入如下代码:Public ClassAdding_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()?

我在添加 swf 文件时对此进行了调整,该文件在加载时没有问题。我知道上面的零是不正确的,但我不确定在那里写什么。我为 swf 文件添加的附加代码是AxShockwaveFlash1.Play(). 我需要做类似的事情AxAcroPDF1.Load()吗?

回答by GojiraDeMonstah

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" ?

如果您只想显示 PDF 而没有其他内容,为什么不使用 System.Windows.Forms.WebBrowser 控件,并将 URL 设为 "D:\Mixed_Addition_1.pdf" ?

回答by Tim

Maybe he didn't want to use a web browser to open a PDF file, Right click 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

也许他不想使用网络浏览器打开PDF文件,右键单击工具箱中的项目,当设计器处于活动状态时,选择选择项目,选择COM组件并选择Adobe。然后将代码添加到新表单。打印机将处于活动状态,您可以在属性选项卡中禁用“工具栏”

Imports AxAcroPDFLib Imports AcroPDFLib Public Class TripSheet

导入 AxAcroPDFLib 导入 AcroPDFLib 公共类 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