Logre realizar la creacion del pdf con itexsharp, e hice que se almacene en el disco d://.
Lo que deseo es que al ejecutar la funcion es que se descargue mediante el navegador a la carpeta de descarga
namespace Web.Controllers
{
public class ReportePDFController : Controller
{
public ActionResult pdfPL()
{
long n = Request.InputStream.Length;
byte[] buffer = new byte[n];
Request.InputStream.Read(buffer, 0, System.Convert.ToInt32(n));
string parametro = Server.UrlDecode(Encoding.Default.GetString(buffer));
var data = JObject.Parse(parametro);
String Titulo = "";
String RazonSocial = "";
String Referencia = "";
String NumeroDocumento = "";
String Subtotal = "";
String igv = "";
String Total = "";
String DiaHoy = "";
Titulo = (data["Titulo"]).ToString();
RazonSocial = (data["RazonSocial"]).ToString();
Referencia = (data["Referencia"]).ToString();
NumeroDocumento = (data["NumeroDocumento"]).ToString();
Subtotal = (data["Subtotal"]).ToString();
igv = (data["igv"]).ToString();
Total = (data["Total"]).ToString();
DiaHoy = (data["DiaHoy"]).ToString();
PdfPCell cell = null;
Document doc = new Document(PageSize.LETTER);
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@"D://" + NumeroDocumento + RazonSocial + ".pdf", FileMode.Create));
doc.AddTitle("Valorizacion de Servicio");
doc.AddCreator("Bureau Veritas Perú");
doc.Open();
iTextSharp.text.Font fnt_titulo_tarifa = FontFactory.GetFont("ArialBold", BaseFont.CP1250, true, 16, iTextSharp.text.Font.UNDERLINE);
iTextSharp.text.Font _standardFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 11, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
iTextSharp.text.Font _headertable = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, BaseColor.WHITE);
PdfPTable tblInicio = new PdfPTable(2);
tblInicio.WidthPercentage = 100;
cell = new PdfPCell(new Paragraph(Titulo, fnt_titulo_tarifa));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.Border = 0;
cell.Colspan = 2;
cell.PaddingTop = 25;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph("Cliente : ", _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 0;
cell.PaddingTop = 25;
cell.Border = 0;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph(RazonSocial, _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 0;
cell.PaddingTop = 25;
cell.Border = 0;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph("Referencia : ", _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 0;
cell.Border = 0;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph(Referencia, _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 0;
cell.Border = 0;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph("Referencia Inspectoria : ", _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 0;
cell.Border = 0;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph(NumeroDocumento, _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 0;
cell.Border = 0;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph("Fecha : ", _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 20;
cell.Border = 0;
tblInicio.AddCell(cell);
cell = new PdfPCell(new Paragraph(DiaHoy, _standardFont));
cell.Padding = 10;
cell.PaddingBottom = 20;
cell.Border = 0;
tblInicio.AddCell(cell);
doc.Add(tblInicio);
PdfPTable tblPL = new PdfPTable(8);
tblPL.WidthPercentage = 100;
PdfPCell clServicio = new PdfPCell(new Phrase("Servicio", _headertable));
clServicio.BorderWidth = 0;
clServicio.BorderWidthBottom = 0.75f;
clServicio.PaddingBottom = 5;
clServicio.BackgroundColor = new BaseColor(165, 0, 33);
clServicio.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell clMaterial = new PdfPCell(new Phrase("Material", _headertable));
clMaterial.BorderWidth = 0;
clMaterial.BorderWidthBottom = 0.75f;
clMaterial.BackgroundColor = new BaseColor(165, 0, 33);
clMaterial.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell clCalidad = new PdfPCell(new Phrase("Calidad", _headertable));
clCalidad.BorderWidth = 0;
clCalidad.BorderWidthBottom = 0.75f;
clCalidad.BackgroundColor = new BaseColor(165, 0, 33);
clCalidad.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell clSubServicio = new PdfPCell(new Phrase("SubServicio", _headertable));
clSubServicio.BorderWidth = 0;
clSubServicio.BorderWidthBottom = 0.75f;
clSubServicio.BackgroundColor = new BaseColor(165, 0, 33);
clSubServicio.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell clCantidad = new PdfPCell(new Phrase("Cantidad", _headertable));
clCantidad.BorderWidth = 0;
clCantidad.BorderWidthBottom = 0.75f;
clCantidad.BackgroundColor = new BaseColor(165, 0, 33);
clCantidad.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell clUm = new PdfPCell(new Phrase("UM", _headertable));
clUm.BorderWidth = 0;
clUm.BorderWidthBottom = 0.75f;
clUm.BackgroundColor = new BaseColor(165, 0, 33);
clUm.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell clMoneda = new PdfPCell(new Phrase("Moneda", _headertable));
clMoneda.BorderWidth = 0;
clMoneda.BorderWidthBottom = 0.75f;
clMoneda.BackgroundColor = new BaseColor(165, 0, 33);
clMoneda.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell clTarifa = new PdfPCell(new Phrase("Tarifa", _headertable));
clTarifa.BorderWidth = 0;
clTarifa.BorderWidthBottom = 0.75f;
clTarifa.BackgroundColor = new BaseColor(165, 0, 33);
clTarifa.HorizontalAlignment = Element.ALIGN_CENTER;
tblPL.AddCell(clServicio);
tblPL.AddCell(clMaterial);
tblPL.AddCell(clCalidad);
tblPL.AddCell(clSubServicio);
tblPL.AddCell(clCantidad);
tblPL.AddCell(clUm);
tblPL.AddCell(clMoneda);
tblPL.AddCell(clTarifa);
var servicios = JArray.Parse(data["Servicios"].ToString());
foreach (JObject jServicios in servicios.Children<JToken>())
{
clServicio = new PdfPCell(new Phrase(jServicios["Servicio"].ToString(), _standardFont));
clServicio.BorderWidth = 0;
clServicio.BorderWidthBottom = 0.75f;
clServicio.PaddingBottom = 5;
clServicio.HorizontalAlignment = Element.ALIGN_CENTER;
clMaterial = new PdfPCell(new Phrase(jServicios["Material"].ToString(), _standardFont));
clMaterial.BorderWidth = 0;
clMaterial.BorderWidthBottom = 0.75f;
clMaterial.HorizontalAlignment = Element.ALIGN_CENTER;
clCalidad = new PdfPCell(new Phrase(jServicios["Calidad"].ToString(), _standardFont));
clCalidad.BorderWidth = 0;
clCalidad.BorderWidthBottom = 0.75f;
clCalidad.HorizontalAlignment = Element.ALIGN_CENTER;
clSubServicio = new PdfPCell(new Phrase(jServicios["SubServicio"].ToString(), _standardFont));
clSubServicio.BorderWidth = 0;
clSubServicio.BorderWidthBottom = 0.75f;
clSubServicio.HorizontalAlignment = Element.ALIGN_CENTER;
clCantidad = new PdfPCell(new Phrase(jServicios["Cantidad"].ToString(), _standardFont));
clCantidad.BorderWidth = 0;
clCantidad.BorderWidthBottom = 0.75f;
clCantidad.HorizontalAlignment = Element.ALIGN_CENTER;
clUm = new PdfPCell(new Phrase(jServicios["Um"].ToString(), _standardFont));
clUm.BorderWidth = 0;
clUm.BorderWidthBottom = 0.75f;
clUm.HorizontalAlignment = Element.ALIGN_CENTER;
clMoneda = new PdfPCell(new Phrase(jServicios["Moneda"].ToString(), _standardFont));
clMoneda.BorderWidth = 0;
clMoneda.BorderWidthBottom = 0.75f;
clMoneda.HorizontalAlignment = Element.ALIGN_CENTER;
clTarifa = new PdfPCell(new Phrase(jServicios["Tarifa"].ToString(), _standardFont));
clTarifa.BorderWidth = 0;
clTarifa.BorderWidthBottom = 0.75f;
clTarifa.HorizontalAlignment = Element.ALIGN_CENTER;
tblPL.AddCell(clServicio);
tblPL.AddCell(clMaterial);
tblPL.AddCell(clCalidad);
tblPL.AddCell(clSubServicio);
tblPL.AddCell(clCantidad);
tblPL.AddCell(clUm);
tblPL.AddCell(clMoneda);
tblPL.AddCell(clTarifa);
}
doc.Add(tblPL);
PdfPTable tblCosto = new PdfPTable(9);
tblCosto.WidthPercentage = 100;
cell = new PdfPCell(new Paragraph("SUBTOTAL : ", _standardFont));
cell.PaddingTop = 25;
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
cell.Colspan = 8;
tblCosto.AddCell(cell);
cell = new PdfPCell(new Paragraph(Subtotal, _standardFont));
cell.PaddingTop = 25;
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
tblCosto.AddCell(cell);
cell = new PdfPCell(new Paragraph("I.G.V. : ", _standardFont));
cell.PaddingTop = 15;
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
cell.Colspan = 8;
tblCosto.AddCell(cell);
cell = new PdfPCell(new Paragraph(igv, _standardFont));
cell.PaddingTop = 15;
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
tblCosto.AddCell(cell);
cell = new PdfPCell(new Paragraph("TOTAL : ", _standardFont));
cell.PaddingTop = 15;
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
cell.Colspan = 8;
tblCosto.AddCell(cell);
cell = new PdfPCell(new Paragraph(Total, _standardFont));
cell.PaddingTop = 15;
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_RIGHT;
tblCosto.AddCell(cell);
doc.Add(tblCosto);
doc.Close();
writer.Close();
return null;
}
}
}