Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #26405

    I have the following scenario.

    1) Create html content using Velocity and store as a string.
    2) Instantiate StringReader with html string.
    3) Instantiate PD4ML and call render like so:
    <br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.render(new StringReader(html), os);<br />
    in this case os is the ServletOutputStream from the HttpServletResponse object. For some reason I can’t get the CSS to be applied. I looked into adding styles and there really aren’t any examples. I tried calling

    <br /> pd4ml.addStyle(styles)<br />

    but that doesn’t seem to work. Is there anyone who has also gone this route and successfully applied CSS and if so can they provide an example?

    Thanks inadvance.

    #28058

    > pd4ml.render(new StringReader(html), os);

    If your CSS stylesheet is referenced from the HTML as a standalone file, probably render() method with base URL should help.

    In any case pd4ml.enableDebugInfo() should help to detect external resource loading problems.

    > pd4ml.addStyle(styles)

    The method is available only in PD4ML Pro (and derived volume licenses). Do you use Std or Pro?

    #28059

    Thanks for your help PD4ML.

    I followed your instructions and am now passing the base URL to the render method. I also have debugging turned on. BTW, I am using the Pro version.

    Now when I do the conversion I get the following in the logs:

    <br /> version: PD4ML 351 Pro<br /> loading CSS file http://<someURL>/css.css<br /> not yet in cache: http://<someURL>/css.css<br /> image not yet in cache: http://<someURL>/images/<imagePath.image.gif><br /> not yet in cache: http://<someURL>/images/<imagePath.image.gif><br /> <br /> image size: 391<br /> done in 1938ms.<br />

    These logs would seem to me that everything was a success but the rendered PDF still doesn’t have the styles applied.

    There are also inline styles applied plus the CSS file. Is this disabling the application of the styles?

    Thanks for any help with this.

    #28060

    Any resolution to this? I’m having the exact same problem today.

    I’ve had success in the past using the JSP transform tag and it handled all references to CSS perfectly. But now, I’m trying to solve a problem that requires that I perform programmatic conversion of an HTML string in the same manner stated by the original poster and no matter what I try my CSS is ignored.

    These are the things that I have tried:

    1) Used the pd4ml.addStyle(,true), where was a fully qualified path to the resource. Debugging showed that the css resource was found and brought into the cache, yet the styles were not applied.

    2) Used the pd4ml.addStyle(, true), where held all of the styles in my CSS file. Styles were not applied.

    3) Included a stylesheet link tag in the head element of my HTML string with a fully qualified path to the CSS resource. Again, debug says that the css was found and brought into the cache, but styles were not applied.

    Steph.

    Steph.

    #28061

    Sorry Steph. No luck so far. The latest things that I’ve tried is to update to 360fx1 Pro as well as some of the things you’ve mentioned and nothing, zilch. I was able to load an image but no CSS.

    I’m beginning to think from the little I’ve found on the forum about developers trying this approach that it doesn’t really work. I am hoping to hear back from a PD4ML devleoper.

    I will keep you posted and please do the same.

    thanks

    #28062

    Finally.

    using useServletContext() and absolute paths resolved my issues.

    #28063

    I’m having the same problem. Will you please give details on where you used absolute paths? Thanks.

    #28064

    Try to switch PD4ML into debug mode with pd4ml.enableDebugInfo() and inspect STDOUT/server’s log which URL it actually tries to load.

    If in your HTML document references are defined as /path/to/stylesheet.css and in the debug output they appear prefixed with file:, pd4ml.useServletContext() call should help.

    But it is a better idea to reference CSS stylesheets with relative paths (like ../mycss/stylesheet.css).

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.