简体   繁体   English

这是什么样的标记?

[英]What kind of markup is this?

I am trying to generate some PDFs from an MVC view and it's been quite a ride. 我试图从MVC视图生成一些PDF,这是一个很好的旅程。 I eventually came across this and am trying to use it but it has this strange markup as shown below (it's based on ITextSharp): 我最终遇到了这个并试图使用它,但它有如下所示的奇怪标记(它基于ITextSharp):

<row>
    <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true">User Name</cell>
    <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true">Description</cell>
    <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true" horizontalalign="right">Lucky Number</cell>
    <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true" horizontalalign="right">Doubled</cell>
</row>

Source 资源

All I am really trying to do at this point is set the width of the column (cell, as it's called here) but cell isn't accepting my style: width or width or anything. 我在这一点上真正想做的就是设置列的宽度(单元格,就像在这里调用的那样)但是cell不接受我的style: widthwidth或任何东西。

How can I use this thing? 我该怎么用这个东西? Are there any better ways to render PDF from MVC view? 有没有更好的方法从MVC视图呈现PDF?

The simplest thing to do would be to create your view in html and convert it to a pdf then send that as your action result. 最简单的方法是在html中创建视图并将其转换为pdf,然后将其作为动作结果发送。

Simple way to get the html of a razor template http://razorengine.codeplex.com/ 获取剃刀模板html的简单方法http://razorengine.codeplex.com/

string template = "Hello @Model.Name! Welcome to Razor!";
string result = Razor.Parse(template, new { Name = "World" });

Pdf conversion http://www.essentialobjects.com/Products/EOPdf/Default.aspx Pdf转换http://www.essentialobjects.com/Products/EOPdf/Default.aspx

Like others have said this is iTextSharp xml. 像其他人一样说这是iTextSharp xml。 Here is a post that posts list the valid XML elements. 这是一篇帖子列出了有效的XML元素。 How to create tables in a PDF document using XML and iTextSharp? 如何使用XML和iTextSharp在PDF文档中创建表格?

It looks like you could potentially use CDATA tags to set the width. 看起来你可能会使用CDATA标签来设置宽度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM