Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

60 Days of Data Days! Live and on-demand sessions, challenges, study groups and more! And it's all FREE!. Join now. Learn more

Reply
ArneVer
Regular Visitor

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/layout as accurately as possible.

I initially tried using xhtml2pdf, but the HTML files contain a large embedded CSS stylesheet (Bootstrap-like grid, media queries, advanced selectors such as :not() and attribute selectors). This resulted in CSS parsing errors. After removing the styling, the PDF could be generated successfully, but most of the original layout was lost. 

I also evaluated:

  • WeasyPrint, but it requires OS-level libraries (e.g. fontconfig) that are not available in my Fabric environment.
  • Playwright, but running Chromium inside a Fabric Notebook appears to be challenging due to runtime and browser binary limitations.

Since preserving the layout is a hard requirement, I'm looking for recommendations from anyone who has implemented HTML-to-PDF conversion in Microsoft Fabric while maintaining browser-quality rendering.

 

Thanks in advance for any suggestions.

2 ACCEPTED SOLUTIONS
Murtaza_Ghafoor
Super User
Super User

@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



View solution in original post

Prince0011
Solution Sage
Solution Sage

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

 

View solution in original post

4 REPLIES 4
Prince0011
Solution Sage
Solution Sage

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

 

v-abhinavmu
Community Support
Community Support

Hi @ArneVer,

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @Kagiyama_yutaka & @Murtaza_Ghafoor  for sharing valuable insights.

 

Could you please confirm if your query has been resolved by the provided solutions? This would be helpful for other members who may encounter similar issues.

 

Thank you for being part of the Microsoft Fabric Community.

 

Kagiyama_yutaka
Responsive Resident
Responsive Resident

Fabric Lakehouse and Notebooks do not provide any built‑in HTML→PDF, so the safe way is to read the HTML out of the Lakehouse and convert it to PDF in another environment (for example a normal browser’s “Print → Save as PDF” or an external HTML‑to‑PDF service).

Murtaza_Ghafoor
Super User
Super User

@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



Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Fabric Update Carousel

Fabric Monthly Update - July 2026

Check out the July 2026 Fabric update to learn about new features.