emichelli / flying-saucer

Automatically exported from code.google.com/p/flying-saucer
0 stars 0 forks source link

Connection timed out while generating pdf from html string #236

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write a code to generate pdf.
2. It will work fine if system is connected to network.
3. throws java.net.ConnectException: Connection timed out if not connected to 
internet.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
9.0.4

Please provide any additional information below.

try {
        String table = getHtmlAsString();//returns html string which contains reference to external CSS
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = builder.parse(new ByteArrayInputStream(table.getBytes("UTF-8")));//Here exception occur

        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(doc, null);

        ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
        renderer.layout();
        renderer.createPDF(byteArray);
        byte[] pdf = byteArray.toByteArray();
        byteArray.close();
        writeByteArrayToFile(pdf);
    } catch (Exception e) {
        e.printStackTrace();
    }

Original issue reported on code.google.com by anu20...@gmail.com on 1 Jul 2014 at 11:09