Forum Bugs

7.0 hangs

box110a
I'm running prince 7(Windows XP intel core2 Duo) from the java API and prince is really slow(or doesn't respond, prince.exe process hangs) when converting
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"xhtml1-transitional.dtd">
<html xmlns="/1999/xhtml">
  <head>
    <meta name="generator"
	  content="HTML Tidy for Java (vers. 2009-08-01), see" />
    <meta http-equiv='Content-Type'
	  content='text/html; charset=utf-8' />
    <title></title>
  </head>
  <body>
    <div id='header'>John</div>
    <div id='footer'>7776665</div>
    <p>John is allergic to Tree nuts (such as almonds, cashews,
    walnuts), Fish (such as bass, codd, flounder), Shellfish (such as
    crag, lobster, shrimp).&nbsp;</p>
    <p>this is a test</p>
    <p>and thus an edit 11:03</p>
    <span class="fn">This report was modified by user on
    September 25, 2009 10:22:07 AM EDT. Please replace any paper copies
    with this new version.</span><span class="fn">This report was
    modified by user on September 25, 2009 11:03:42 AM EDT.
    Please replace any paper copies with this new version.</span>
  </body>
</html>

Sometimes it works, sometimes not. I have to kill the process. We have also run into this issue on a CentOS server (Pentium D CPU)

6.0 has the same issue and it is really starting to hinder development.

When is another beta release expected? are there any workarounds?
box110a
I have a fix, but it requires that you add the following function to the Java API. The system was hanging when it was reading the inputStream into the outputstream. Instead I just make a tempFile and print to the output stream.

@SuppressWarnings("unchecked")
    public boolean convert(String html, OutputStream out) throws IOException {

        File temp = File.createTempFile("tmp_", "_tmp.html");
        // Write to temp file
        BufferedWriter tmpout = new BufferedWriter(new FileWriter(temp));
        tmpout.write(html);
        tmpout.close();

        List cmdline = getCommandLine();

        String pdfPath = temp.getAbsolutePath() + ".pdf";
        cmdline.add("--server");
        cmdline.add(temp.getAbsolutePath());
        cmdline.add(pdfPath);

        Process process = Util.invokeProcess(cmdline);

        if (readMessages(process)) {

            File pdfFile = new File(pdfPath);
            InputStream in = new FileInputStream(pdfPath);

            // Transfer bytes from in to out
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
            in.close();
            out.close();

            temp.delete();
            pdfFile.delete();
            return true;
        }
        return false;
    }
mikeday
So it works when applying convert() to a file, but fails when writing that file directly to the standard input? That sounds like a deadlock situation. Could you try enabling logging and seeing if there are any error messages showing up in the log file?