Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26894

    Hi Support,

    we are using pd4ml to generate pdf from html . but we are facing performance issue
    at render method .. its taking 7 mins for 5MB file .below is my code please help us to overcome this issue .

    =============================
    java.io.FileOutputStream fos = new java.io.FileOutputStream(fileName);
    PD4ML pd4ml = new PD4ML();

    PD4PageMark header = new PD4PageMark();

    header.setAreaHeight(-1);

    header.setHtmlTemplate(pdfHeader);

    PD4PageMark footer = new PD4PageMark();

    footer.setAreaHeight(-1);

    footer.setHtmlTemplate(footer);
    pd4ml.setPageSize(PD4ML.A4);

    pd4ml.interpolateImages(true);
    pd4ml.overrideDocumentEncoding(“UTF-8”);
    pd4ml.generatePdfa(true);
    pd4ml.generatePdfForms(true, “Courier New”);
    pd4ml.enableImgSplit(false);
    pd4ml.setPageInsets(new Insets(10,40,10,40));
    pd4ml.setHtmlWidth(1080);
    pd4ml.adjustHtmlWidth();
    pd4ml.useTTF( “java:Fonts”, true );//./WebContent/WEB-INF/lib/fonts
    pd4ml.setDefaultTTFs(“Segoe UI”, “Arial”, “Courier New”);

    pd4ml.generateOutlines(true);
    pd4ml.enableImgSplit( false );

    pd4ml.setPageHeader( header );
    pd4ml.setPageFooter(footer);

    pd4ml.render(new StringReader(pdfString),fos);

    ==================

    Thanks & Regards,
    Vinay Choudhary

    #29449

    A conversion duration primarily depends on HTML/CSS file size and its structure. So an HTML sample would help to analyze the issue in details.

    Typical reasons of such performance issues:

    – Huge CSS stylesheet: as we seen a couple of times, some “web optimised” HTML documents may include 2-3 Mb CSS style, tuned to suppress known banner exchange engines. The style makes no sense for HTML document layout, but makes CSS parser/runtime to spend quite a lot of resources to maintain the styles and it significantly slows down style resolving for a particular HTML element. Unfortunately CSS parser we use is not optimised to deal with extra big stylesheets.

    – The entire document layout is built as a single table with tens or hundred thousands of cells. If the table is nested to another table – rendering takes 3 times longer; 2 levels of nesting – 9 times longer etc. For big documents we recommend to split a huge table to a sequence of smaller ones and avoid a table nesting.

    If you are interested, a technical background of that is following: each cell width is calculated 3 times for MIN, MAX and optimal values. So every nesting level multiplies the “layouting” approaches to 3. If, lets say a content of a cell of a particular table row does not fit a column width calculated before, it needs to start table layouting again, taking into account a new condition.

    #29450

    Hi Support,

    i have attached the html file which we are using to generate pdf . please have a look and guide me to solve the problem .

    Thanks,
    Vinay

    #29451

    I checked the document sources.

    Well, as I suspected the document layout is built as a single table. The table cells also include multi-nested tables (up to 4 nesting levels).

    It should help a lot if by the HTML document generation (hopefully you have a control over the process) you can omit the “main table” – just output its nested content.

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

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