Taking Too Much Time on generating docx and converting to PDF



  • Subject: Performance Optimization Request for DOCX to PDF Conversion Using LibreOffice/Unoconv
    Description:
    We are currently generating PDF files from DOCX templates using both JSReport and a custom Node.js script that utilizes LibreOffice (via libre.convert) and unoconv. Below are the two approaches we've tested:
    Approach 1: JSReport Configuration

    {
    "template": {
    "recipe": "docx",
    "engine": "handlebars",
    "unoconv": {
    "format": "pdf"
    },
    "docx": {
    "templateAsset": {
    "content": "<base64-encoded-wordDocumentBuffer>"
    }
    }
    },
    "data": "Objects"
    }
    

    Approach 2: Node.js Script Using LibreOffice (LibreOffice Convert)

    function convertDocxToPdf(docxBuffer) {
    return new Promise((resolve, reject) => {
    const extend = ".pdf";
    libre.convert(docxBuffer, extend, undefined, (err, pdfBuffer) => {
    if (err) {
    return reject(
    new Error("Error during DOCX to PDF conversion: " + err?.message)
    );
    }
    resolve(pdfBuffer);
    });
    });
    }
    

    Issue Observed:
    On Linux systems, the conversion is fast and works as expected.
    On Windows systems with high configuration (e.g., 16GB+ RAM, SSD), the performance is acceptable.
    However, on Windows systems with lower specs (e.g., 8GB RAM), both methods take around 15–20 seconds for a single DOCX to PDF conversion.
    We have tested with:
    LibreOffice direct CLI conversion
    Unoconv package
    JSReport with unoconv recipe
    But in all cases, the conversion time is consistently slow on low-end Windows systems.
    Here, We are looking to consistently reduce conversion time to under 10 seconds on all environments.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.