Forum How do I...?

external stylesheet

jerry1970
Hi all,

A system our Australian colleagues have made calls Prince to convert an HTML document to PDF. This works OK except that I think their stylesheet makes the results ugly. I cannot change the default.css because it will be replaced on the next update. So I want to include a second stylesheet.

I cannot change the command line, which includes something like this:
-s C:\{long path}\PDF styleheets\default.css


This seems to be the only CSS included. The weird thing is that everything between style tags is disregarded. Using the <?xml-stylesheet href="..."?>, I get a single blank page in the PDF, so that does not work either. What does work in using the style attribute on every HTML element - this is something I would like to avoid... ;)

Does this ring a bell for anyone? Am I missing something?

Thanks!
Jerry
mikeday
What other command-line options are being used? Have you tried <link rel="stylesheet" type="text/css" href="..."/> ?
jerry1970
To answer your question, the only other command line option was -o for output. But I think I've found it...

The original XML file (as installed by our Australian colleagues) looked like this:
<html xmlns:v="urn:schemas-microsoft-com:vml"
	xmlns:o="urn:schemas-microsoft-com:office:office"
	xmlns:x="urn:schemas-microsoft-com:office:excel"
	xmlns="http://www.w3.org/TR/REC-html40"/>
<head>
...
</head>
<body>
...
</body>

I noticed the HTML tag was closed (see the slash at the end) and there was no closing HTML tag at the bottom of the file.

When I changed it to this:
<html xmlns:v="urn:schemas-microsoft-com:vml"
	xmlns:o="urn:schemas-microsoft-com:office:office"
	xmlns:x="urn:schemas-microsoft-com:office:excel"
	xmlns="http://www.w3.org/TR/REC-html40">
<head>
...
</head>
<body>
...
</body>
</html>

Prince gave errors on &nbsp;, saying nbsp was not a valid entity.

When I removed the attributes from the HTML tag, everything went alright:
<html>
<head>
...
</head>
<body>
...
</body>
</html>


No more errors on NBSP tags and also both the <link ...> and <style>...</style> work!

I have no idea what the xmlns attributes mean and am not interested to find out, but removing them did help, so we are happy here. ;)

Thanks,
Jerry
mikeday
Okay, for future reference it comes down to whether your file is XHTML or HTML. If it's XHTML, then it must be well-formed XML, but many people get this wrong, so Prince tries to figure out what you really mean. You can say exactly what you mean by specifying "-i html" or "-i xml" on the command-line.
jerry1970
I will forward this info to our Australian colleagues...

Thanks!