views:

48

answers:

2

I am using flyingsaucer together with iText in an asp.net application(using IKVM) to convert HTML into PDF's. If I put a style directly in the html it works fine (even styles put between style tags) but when I link a style sheet it fails to notice it and produces the pdf without the styles.

Any reason why this is happening?

This is the code that I am using

        Dim renderer As New ITextRenderer
        Dim buf As New StringBuffer
        buf.append(HTML)
        Dim builder As DocumentBuilder = DocumentBuilderFactory.newInstance.newDocumentBuilder()
        Dim doc As Document = builder.parse(New StringBufferInputStream(buf.toString))

        renderer.setDocument(doc, Nothing)
        renderer.layout()

        renderer.createPDF(os)

And this is link to the stylesheet

<link rel="stylesheet" href="stylemove.css" type="text/css"  />
A: 

from the FAQ:

My PDF isn't picking up my CSS!

PDF is treated as "print" media; see the CSS 2.1 specification section on media types. Make sure you have specified the media type for your CSS when you link or embed it; use type "print" or "all".

pstanton
A: 

Hi,

If you are using https then flying saucer would fail to read .css files until you make java's keystore include the certificate of your web server.

I have the same problem too... see this discussion

https://code.google.com/p/jmesa/issues/detail?id=182

If you solved it any other way, please let me know!!!

Thanks.

hese