看到这个链接将html转换为pdf我在webconfig中得到了这个版本错误让一些天才找到并解决了qustion.
我的模特
public class Customer
{
public int CustomerID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的控制器这是正常的代码
public ActionResult Index()
{
List<Customer> customers = new List<Customer>();
for (int i = 1; i <= 10; i++)
{
Customer customer = new Customer
{
CustomerID = i,
FirstName = string.Format("FirstName{0}", i.ToString()),
LastName = string.Format("LastName{0}", i.ToString())
};
customers.Add(customer);
}
return View(customers);
}
Run Code Online (Sandbox Code Playgroud)
这是为pdf转换控制器
public ActionResult PDF()
{
List<Customer> customers = …Run Code Online (Sandbox Code Playgroud) 我想要像 2015 年 5 月 14 日这样的输出格式日期。第14 天它应该带有 sup 标签,但 sup 标签没有在此处访问。我在 ph102 变量中得到的输出。Getsuffix(csq.EventDate.Value.Day) 在这个只有我得到 th st 和 rd 的日期后缀
我的代码:
PdfPTable table9 = new PdfPTable(4);
table9.WidthPercentage = 99;
table9.DefaultCell.Border = 0;
table9.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
Phrase ph101 = new Phrase("Event Date & Time", textFont2);
PdfPCell cellt1 = new PdfPCell(ph101);
cellt1.Border = PdfPCell.BOTTOM_BORDER + PdfPCell.LEFT_BORDER + PdfPCell.RIGHT_BORDER;
cellt1.PaddingTop = 0F;
cellt1.VerticalAlignment = Element.ALIGN_MIDDLE;
cellt1.HorizontalAlignment = Element.ALIGN_LEFT;
DateTime eventTime = DateTime.Today;
if (!string.IsNullOrEmpty(Convert.ToString(csq.EventTime)))
eventTime = DateTime.Today.Add(csq.EventTime.Value);
Phrase ph102;
if (!string.IsNullOrEmpty(csq.EventDate.ToString())) …Run Code Online (Sandbox Code Playgroud)