View PDF document windows Forms

Asked

Viewed 753 times

0

Is there any property of viewing a file . PDF from the event Click on Picturebox without having to create a new modal?

Example:

I have this Picturebox, where I created the code below, as soon as it is clicked it of the option to print the file, however I would like to leave more dynamic, viewing the . PDF and the user chooses whether or not to print.

inserir a descrição da imagem aqui

Code:

private void picPDF_Click(object sender, EventArgs e)
        {
            try
            {
                NotasFiscais objNotasFiscais = new NotasFiscais();
                Pedido objPedido = new Pedido();
                if (objPedido.ConsultarNFPedido(Metodos.empresa, txtNumPedido.Text) > 0)
                {
                    objNotasFiscais.NFEmpresa = Metodos.empresa;
                    objNotasFiscais.NFNumero = objPedido.pedNFNumero;
                    objNotasFiscais.NFSerie = objPedido.pedNFSerie;
                    objNotasFiscais.NFCliente = Convert.ToInt32(txtCodigo.Text);
                    objNotasFiscais.NFTipo = objPedido.pedNFTipo;
                }
               if (objNotasFiscais.ConsultarNotaFiscal(Metodos.empresa, objNotasFiscais.NFNumero, objNotasFiscais.NFSerie, objNotasFiscais.NFTipo) > 0 )
                {
                   // if (objNotasFiscais.NFStatus == "I")
                   // {
                        Operacoes operacoes = new Operacoes();
                        string danfe = operacoes.ConsultarDanfePdf(objNotasFiscais.NFEmpresa, objNotasFiscais.NFNumero, objNotasFiscais.NFSerie, objNotasFiscais.NFCliente.ToString(), objNotasFiscais.NFTipo, true);
                        string Filepath = danfe;
                        new PrintPDF(danfe);
                    //}
                }
                else
                {
                    MessageBox.Show("PDF da Danfe não encontrado.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }

1 answer

1


I had a similar problem recently and I’ve been researching something to view PDF in a Windowsforms application and ended up finding this project Moon PDF.

This is a WPF control so you will need to use a WPF control in your Windows Forms application.

I did an example project on Github and you take a look at this link.

This used library is available in the nuget gallery on bundle.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.