您好我已经在我的控制器中创建了基本的网格视图到Pdf我遇到的问题是将结果分成两行而不是一行。 我希望City,State和Zip成为新的一线。
谢谢。
`public FileStreamResult GetPdf(int?id){
List<Requisition> all = new List<Requisition>();
using (ClinlabEntities dc = new ClinlabEntities()) {
all = dc.Requisitions.Where(reqId => reqId.ReqId == id).ToList<Requisition>();
}
WebGrid grid = new WebGrid(all);
string gridHtml = grid.GetHtml(
columns: grid.Columns(
grid.Column("FirstName", " "),
grid.Column("LastName", " "),
grid.Column("Address", " "),
grid.Column("City", " "),
grid.Column("State", " "),
grid.Column("Zip", " ")
)).ToString();
string exportData = String.Format("<html><head>{0}</head><body>{0}</body></html>", "<style>table(border-spacing:00px; font-size:8px; border-collapse:seperate;)</style>", gridHtml);
var bytes = System.Text.Encoding.UTF8.GetBytes(exportData);
using (var input = new MemoryStream(bytes)) {
var output = new MemoryStream();
var document = new iTextSharp.text.Document(PageSize.LETTER, 130, 0, 50, 0);
var writer = PdfWriter.GetInstance(document, output);
writer.CloseStream = false;
document.Open();
var xmlWorker = iTextSharp.tool.xml.XMLWorkerHelper.GetInstance();
xmlWorker.ParseXHtml(writer, document, input, System.Text.Encoding.UTF7);
document.Close();
output.Position = 0;
return new FileStreamResult(output, "Application/Pdf");
}
}
}