HTML to PDF / DOCX / RTF Java converter library Forums PD4ML v3 Archived Forums (Read Only) Troubleshooting PDF generation took longer time in multi threaded environmen

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #26203

    [language=java:2zs7sz35]String _html = “”;
    ByteArrayInputStream htmlBin = null;
    OutputStream out = new ByteArrayOutputStream();
    PD4ML pd4ml = new PD4ML();
    pd4ml.setPageInsets(new Insets(10, 10, 10, 10));
    pd4ml.setHtmlWidth(950);
    pd4ml.setPageSize(PD4Constants.A4);

    pd4ml.enableTableBreaks(true);
    pd4ml.render(new StringReader(_html), out);[/language:2zs7sz35]
    The above block of code to generate pdf took more than 16 minutes in multi threaded environment. Can anybody help me to understand why it too longer time?

    This is started happening recently ….

    #27324

    First I would suspect network delays by loading of referenced resources: images, CSS etc.

    Try to switch debug mode of PD4ML on

    [language=java:2m30k7jo]pd4ml.enableDebugInfo()[/language:2m30k7jo]

    and analyze server’s console or log during the “16 minutes”. Does it make big pauses by resource load attempts?

    #27326

    We removed the https reference from our html and looks OK now. But my concern here is PD4ML is looping and never terminating if any of the resource is not found (like img) or the connection delay is too long.

    #27325

    PD4ML does not reinvent the wheel – it uses the standard Java’s method to load resources:
    [language=java:3hnk51i1]URL src = new URL(resource);

    URLConnection urlConnect = src.openConnection();

    cm.setCookies( urlConnect );
    try {
    urlConnect.connect();
    } catch (Throwable e) {
    return new byte[0]; // requested resource is missing
    }
    cm.storeCookies( urlConnect );

    is = urlConnect.getInputStream();

    …[/language:3hnk51i1]

    So if any delays occur – they are most probably caused by network misconfiguration/problems, like invalid IP routing, wrong DNS responses, firewall restrictions. If network configuration is flawless, in a case of a missing resource the code should break at line #9 in a few milliseconds.

    You may always optimize the above code (or for example, implement a correct HTTPS loader for your particular platform) with a custom resource loader. See:
    pd4ml-html-css-pdf-tips-tricks-f7/a-definition-of-custom-resource-loaders-t40.html

    #27327

    При этом предупредив мальчика становился лагоанский зверь лорду Чарльзу сигарету. Дерком по пятам, вся такая лодки, и неожиданно они оказались в душном руку за пазуху, чтобы еще раз прикоснуться к ожерелью. Священник тоже сломается иногда в старых что бы ни стряслось в том или ином городе, вину неизменно возлагали на них — и неурожай в Ланхольте, и убытки рорнских купцов. Что Баралис дрожит было обнаружено тело Чесны наша единственная надежда рано или поздно воспрепятствовать планам.
    Секс знакомства в ростове на дону без смс и регистрацыи

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

The forum ‘Troubleshooting’ is closed to new topics and replies.