0

itextsharp を使用して、html 部分を pdf に変換しています。すべて問題ありませんが、html を pdf に変換した後、画像は常に左に配置されます

<div align="center"><img src="http://www.uaa.alaska.edu/institutionaleffectiveness/Graduation/images/report_1.jpg" width="120"></div>

C# コード:

StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlCertificate.RenderControl(hw);
src = sw.ToString();
AbsolutePath = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath;
src = src.Replace("src=\"/", string.Format("src=\"{0}", AbsolutePath));
StringReader sr = new StringReader(src);
Document pdfDoc = new Document();
pdfDoc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, new FileStream(path + "/" + _CertificatesEntityCollection.First().Name + ".pdf", FileMode.Create));
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
4

2 に答える 2