lunes, 16 de noviembre de 2009

Como leer un archivo pdf desde un aplicativo web form / asp.net

Aquí les dejo un método que les permitirá leer un archivo pdf (adobe) desde un aplicativo Web Asp.NET.

Deben utilizar el siguiente imports:

using System.Net;

A continuación el método:

private void LeerArchivoPdf(string NombreArchivoPDF)
{
string ruta = NombreArchivoPDF;
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(ruta);
if (buffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
}

Hugo Bernachea
MCT - MCSD