简体   繁体   中英

How to convert HTML with CSS to xsl-fo?

I want convert HTML with Css to xsl-fo. Anyone can suggest to me how to convert this.

I have 2 file one html file and once css file. I want to generate xsl-fo file with these 2 files so that I can easily generate pdf, rtf and other format easily.

HTML file 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css"/> *--> css file* 
<title></title>
</head>
<body>
<div class="cw-default">
<p><span class="sans"><b>Short title</b></span> this is text for testing<i>italic text</i>.</p>
<p class="center">this is test</p>
</div>
</body>
</html>

style.css file will add property into the html, I want this property values will come in generated FO file also.

/* Style Sheet */

.cw-default { font-size: 1em; }
.sans  { font-family: arial,helvetica }
.center   {text-align: center;}

We have used this in many projects:

Werner Donne's CSS to XSL FO

This is XSL plus code to convert CSS, CSS2 to XSL FO.

Converting HTML to xsl-fo is a transformation from one Markup Language to another. The difference between them is that HTML is used to be displayed with Browsers and xsl-fo is used to turned into PDF by Renderers.
CSS is not a tool to transform a Markup Language but to style it. You can use it with both HTML and xsl-fo, but that does not mean that it is able to do a transformation. The Language built for transformations is XSLT. This is the right tool for what you want to achieve. Be aware that XSLT works with XML input and most HTML isn't valid XML, but XHTML is. Just be sure to close your tags ;-)
Here is an example: Xslt to xsl-fo transformation

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