Good afternoon.
I'm doing an export to pdf for that I'm using iTextSharp so what I would like is the header be centered by the one who already does it:
-
NumeroCuota
-
Expiration Date
-
quota
-
AmortizacionCapital
- Interesting
- Balance
and the rest should be of the right position
this is my current code:
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
//To Export all pages
GridView1.AllowPaging = false;
this.BindGrid();
GridView1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 10f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
Font LineBreak = FontFactory.GetFont("Arial", size: 14);
// pdfDoc.Add(img);
// img.ScaleAbsolute(159f, 159f);
pdfDoc.Add(new Paragraph("SIMULADOR DE CREDITOS"));
pdfDoc.Add(new Paragraph("\n\n", LineBreak));
pdfDoc.Add(new Paragraph("CRONOGRAMA DE CREDITOS"));
pdfDoc.Add(new Paragraph("\n\n", LineBreak));
htmlparser.Parse(sr);
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Simulador_Credito.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
}
}
Well the header will order it to the center but everything is centered but I would like the body to be right.
do it with this code
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells[5].HorizontalAlign = HorizontalAlign.Center;
This is generating me to the present