Forum Discussion

ArneVer's avatar
ArneVer
Frequent Visitor
1 month ago
Solved

Convert HTML files to PDF

Hi   I'm currently looking for a technique to convert HTML files stored in a Microsoft Fabric Lakehouse into PDF files. The goal is to preserve both the content and the original formatting/lay...
  • Murtaza_Ghafoor's avatar
    1 month ago

    ArneVer 
    AS per my understanding and findings, Fabric runs in managed environment so there is no built in fabric API that converts HTML to PDF.

    Workaround for this problem:
    Fabric NoteBook     ---->(Read HTML from Lakehouse) ----> Azure Function (PlayWrtie +Chromium) ----> Convert HTML to PDF  ----> Save PDF to ADSL /OneLake

    2nd Option similar approach but use Power Auomate Flow instead Azure Function.

    Lakehouse ----> Power Automate ---->HTML to PDF converter ---->Onelake / Sharepoint

    Please let me know how this goes on.


    If this helps, 
    ✓ Mark as Kudos | Help Others



  • Prince0011's avatar
    1 month ago

    Hi User,

    Preserving the original HTML layout (especially with complex CSS frameworks like Bootstrap) typically requires a browser-based rendering engine. Libraries such as xhtml2pdf are suitable for simple HTML but often struggle with modern CSS features.

    Based on your findings, here are a few approaches you could consider:

    • Use Playwright or Puppeteer in an environment that supports Chromium (such as Azure Functions, Azure Container Apps, Azure App Service, or a VM). Your Fabric Notebook can then invoke this service to generate high-fidelity PDFs.

    • If you're already using Azure, consider building a lightweight HTML-to-PDF microservice and calling it from a Fabric Pipeline or Notebook. This keeps the rendering separate from Fabric's runtime limitations.

    • If your HTML is generated from a reporting process, another option is to render the PDF outside Fabric before storing it in the Lakehouse.

    Unfortunately, Fabric Notebooks currently don't expose the OS-level dependencies required by tools such as WeasyPrint, nor are they designed to run headless Chromium reliably. Because of this, browser-based rendering directly inside Fabric isn't officially supported today.

    For more information:

    Could you also clarify:

    • Are the HTML files generated within Fabric, or are they imported from another application?

    • Is the PDF generation required entirely inside Microsoft Fabric, or would calling an external Azure service be an acceptable solution?

    • Approximately how many HTML files do you need to convert (e.g., tens, hundreds, or thousands per day)?

    This information will help determine the most suitable and scalable approach for your scenario.

    💡 Helpful? Give a Kudos 👍 — keep the community growing.

    Solved your issue? Mark this as the Accepted Solution ✔️

    Best regards,
    Prince Singh | Data Science & Microsoft Fabric Enthusiast