晚上好 。
estoy realizando una exportancion a pdf para eso estoy usando iTextSharp por lo cual lo que yo quisiera esque la cabecera sea centrado por la que ya lo realice:
号码费
截止日期
分享
摊销资本
- 兴趣
- 平衡
其余的必须来自正确的位置
这是我当前的代码:
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();
}
}
}
好吧,我将头球放在中心,但一切都在中心,但我希望身体是直的。
用这段代码做
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;
这让我到现在
要使任何单词居中,我们必须创建一个变量并添加对齐属性:
到要导出的文档