edraw-max-horizontal
Guia
O que há de novo?
EdrawMax online
Download Grátis
Compre Agora

Incorporar PDF em um Formulário VB.NET Usando Adobe Reader Component

> Basic Diagram How-Tos > Incorporar PDF em um Formulário VB.NET Usando Adobe Reader Component
foto do autor
Ana Sophia | 2024-03-05 21:53:39
O componente visualizador de PDF é uma solução fácil e confiável para desenvolvedores incorporarem PDF em um formulário VB.NET usando o Adobe Reader Component.

Qual é a melhor maneira de incorporar um documento adobe pdf em um formato VB.Net com 100% de compatibilidade? Acredito que muitos de vocês se lembrem da boa tecnologia de componentes adobe reader que permitia carregar um arquivo pdf no formato Visual Basic Windows. Mas todas essas tecnologias não oferecem suporte para fazer mais limitação de arquivos PDF de modificação.

O artigo a seguir mostrará como carregar arquivos PDF em um aplicativo VB.NET passo a passo.

Se você não tiver o componente visualizador de PDF, precisará instalar o pacote primeiro.

Como exibir documento PDF no aplicativo VB6

Abra o Visual Studio e crie um novo aplicativo VB.NET.

Clique com o botão direito na solução. Em seguida, clique no item de menu Adicionar Referência ....

VB.Net Add Reference

Na caixa de diálogo pop-up, escolha o arquivo pdfviewer.ocx na guia Navegar.

browse pdf viewer

Ou escolha o componente PDF Viewer na guia COM.

Clique em OK. As referências do componente PDF Viewer foram adicionadas no novo projeto vb.net.

vb reference

Mude para a janela de design de formulário do Form1.

Switch to the Form design window

Arraste o componente PDF Viewer do painel da caixa de ferramentas para o formulário1.

Add PDF Component

Digite os seguintes códigos VB.NET para novo, abrir, salvar como, fechar e imprimir um documento do Word parecido com este:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadPDF.Click
With OpenFileDialog1
.DefaultExt = "pdf"
.Filter = "PDF File Formats (*.pdf)|*.pdf|All Files (*.*) | *.* ||"
.FilterIndex = 1
End With
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
AxPDFViewer1.LoadFile(OpenFileDialog1.FileName)
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub PDFInstalled_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PDFInstalled.Click
If AxPDFViewer1.AdobeReaderIsInstalled = True Then
MsgBox("Ok. Your computer has installed the Adobe Reader", vbYesNo)
Else
MsgBox("Please installed the Adobe PDF Reader before using the component.", vbYesNo)
End If
End Sub

Private Sub ShowToolbars_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowToolbars.Click
If AxPDFViewer1.Titlebar = True Then
AxPDFViewer1.Titlebar = False
Else
AxPDFViewer1.Titlebar = True
End If
End Sub

Private Sub ShowScrollbar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowScrollbar.Click
If AxPDFViewer1.Scrollbar = True Then
AxPDFViewer1.Scrollbar = False
Else
AxPDFViewer1.Scrollbar = True
End If
End Sub

Private Sub ShowTitlebar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowTitlebar.Click
If AxPDFViewer1.Titlebar = True Then
AxPDFViewer1.Titlebar = False
Else
AxPDFViewer1.Titlebar = True
End If
End Sub

Private Sub CloseDoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseDoc.Click
AxPDFViewer1.Clear()
End Sub

Private Sub AboutPDF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutPDF.Click
AxPDFViewer1.AboutPDFViewer()
End Sub

Private Sub First_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles First.Click
AxPDFViewer1.GotoFirstPage()
End Sub

Private Sub Prev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Prev.Click
AxPDFViewer1.GotoPreviousPage()
End Sub

Private Sub NextPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextPage.Click
AxPDFViewer1.GotoNextPage()
End Sub

Private Sub LastPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LastPage.Click
AxPDFViewer1.GotoLastPage()
End Sub

Private Sub PrintOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintOut.Click
AxPDFViewer1.PrintWithDialog()
End Sub

Private Sub DisableToolbarMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisableToolbarMenu.Click
AxPDFViewer1.DisableToolbarRightClickMenu(True)
End Sub

Private Sub DisableViewMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisableViewMenu.Click
AxPDFViewer1.DisableViewRightClickMenu(True)
End Sub

Private Sub DisableCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisableCopy.Click
AxPDFViewer1.DisableHotKeyCopy()
End Sub

Private Sub DisablePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisablePrint.Click
AxPDFViewer1.DisableHotKeyPrint()
End Sub

Private Sub DisableHotkeys_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisableHotkeys.Click
AxPDFViewer1.SetReadOnly()
AxPDFViewer1.DisableHotKeyCopy()
AxPDFViewer1.DisableHotKeyPrint()
AxPDFViewer1.DisableHotKeySave()
AxPDFViewer1.DisableHotKeySearch()
AxPDFViewer1.DisableHotKeyShowBookMarks()
AxPDFViewer1.DisableHotKeyShowThumnails()
AxPDFViewer1.DisableHotKeyShowToolbars()
End Sub
End Class

Abra o Gerenciador de configuração. Alterar a plataforma de solução ativa como opção x86.

x86 option.

Em seguida, construa o projeto VB.NET e execute.

PDF Component in VB.NET

O componente leitor de PDF oferece suporte ao Adobe Reader versão 9, X e XI. Ele pode ser executado no sistema operacional Windows 2000/Xp/Vista/2008/7/8/8.1 de 32 bits ou 64 bits. Para incorporar o arquivo pdf em um aplicativo VB.NET, você não precisa mudar nada, apenas chame o método LoadFile:

public void Open()
{
axPDFViewer1.LoadFile(sPath);
axEDOffice1.Open("");'Open the standard file dialog
}

Com um componente de visualização de PDF, você não só pode visualizar documentos PDF, mas também pode desativar a impressão, desativar a cópia, desativar a edição e alterar as opções da janela de PDF. Aqui está um tutorial do VB.NET para exibir um arquivo PDF na página ou formulário asp.net. Ele usa o software Adobe Reader instalado no sistema para processar os arquivos PDF. Portanto, é 100% compatível com todos os arquivos PDF.

Artigos Relacionados

Comece a Usar! Você Vai Amar Este Software Para Diagramação Fácil de Usar.

O Edraw Max é perfeito não apenas para fluxogramas de aparência profissional, organogramas e mapas mentais, mas também para diagramas de rede, plantas baixas, fluxos de trabalho, design de moda, diagramas UML, esquemas elétricos, ilustrações científicas, e diversos gráficos... e isso é só o começo!