4

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;}
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
user2331011
  • 41
  • 1
  • 1
  • 3
  • 1
    Hi Param, welcome to SO. Can you please add the code sample of something that you have tried? This way we can see what is going wrong and perhaps can help you better. – Bazzz Apr 29 '13 at 06:49
  • See also http://stackoverflow.com/a/21345708/287948 – Peter Krauss Dec 05 '15 at 13:23

2 Answers2

4

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.

Kevin Brown
  • 8,805
  • 2
  • 20
  • 38
0

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

Community
  • 1
  • 1
Andreas
  • 1,220
  • 8
  • 21
  • I am able to convert html to xsl-fo by xslt but I want css also which has all attributes like alignment, padding, color etc. To achive css style in xsl-fo I want sone suggestion. – user2331011 Apr 29 '13 at 07:28
  • In classes do trigger css you can use attributes to drive the transformation. An idea gives http://stackoverflow.com/questions/977874/is-there-something-like-css-built-into-xsl-fo – Andreas Apr 29 '13 at 07:33