Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26861

    I have an HTML document that looks like this:

    <html><br /> <body><br /> <img src="[Portrait]" align=right /><br /> Some other text goes here.<br /> </body><br /> </html><br />

    Then in my Java code, I have a code snippet that does the following:

    <br /> String portraitPath = System.getProperty("user.home") + File.separator + "Desktop" + File.separator + "Test.jpg";<br /> <br /> //Escape backslashes on Windows so replaceAll doesn't take them away<br /> if (System.getProperty("os.name").startsWith("Windows"))<br /> portraitPath = portraitPath.replace("\", "\\");<br /> <br /> outputHTML = outputHTML.replaceAll("(?i)\[Portrait\]", portraitPath);<br /> <br /> FileOutputStream fos = new FileOutputStream(outputFile);<br /> pd4ml.render(new StringReader(outputHTML), fos );<br />

    This generates a PDF document as expected. However, on a Mac the image appears in the rendered PDF. On Windows 8, the image doesn’t, just the text. Copying the value of portraitPath into a web browser on both Mac and Windows shows the image file, so it’s not an error of the file not being available. I’ve also tried replacing the backslashes in portraitPath in favor of forward slashes as well as converting spaces into “%20” but in all cases it still renders fine on a Mac, but not at all on Windows.

    Is this a bug in PD4ML? Or is there something else I’m not considering?

    #29376

    tag expects not a local path, but an URL as a src attribute value.

    The following reformatting should help to workaround:
    [language=java:2pljl47z]String portraitPath = System.getProperty(“user.home”) + File.separator + “Desktop” + File.separator + “Test.jpg”;
    portraitPath = new File(portraitPath).toURI().toString();[/language:2pljl47z]

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

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