简体   繁体   中英

What kind of markup is this?

I am trying to generate some PDFs from an MVC view and it's been quite a ride. 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):

<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.

How can I use this thing? Are there any better ways to render PDF from MVC view?

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.

Simple way to get the html of a razor template 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

Like others have said this is iTextSharp xml. Here is a post that posts list the valid XML elements. How to create tables in a PDF document using XML and iTextSharp?

It looks like you could potentially use CDATA tags to set the width.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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