question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When Converted Html to Pdf document, linked css not rendered.

See original GitHub issue

I want to create a report which has data from web services, charts, tables, pictures. While converting html to pdf, scripts works but css not rendered.

We have an application works .net framework and MVC pattern.

Css Path are located below.

<link href="~/Rapor/SablonCss/FONRAPOR" rel="stylesheet" /> This comes from databese because styles inserted on db. Rapor is a controller name, SablonCss is an action name.

But if we located as css file at physical directory, it works. Hovewer if we will change css code on database, it should be worked. Not take from physical path.

Physical Located File Path

<link href="~/Content/MasterSablon.css?ver=1.0.4" rel="stylesheet" />
<link href="~/Content/Sablon.css?ver=1.0.4" rel="stylesheet" />

By the way Chromium works as headless = false, because of an our web service’s process.

Expected Result Önizleme (6).pdf

Actual Result 22952_HKV_17042020_sirketbulteni.pdf

How to solve this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mertmtncommented, Apr 21, 2020

I tried to set PrintBackground to true as a pdf options and works it. Thanks for your help…

0reactions
rgeromegnacecommented, May 12, 2022

It seems to come from the presence of @media tag in my default css file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to apply CSS on View HTML to PDF Conversion ...
1 Answer. The reason why you cannot apply CSS is because you did not successfully obtain the path of the sub-files under the...
Read more >
CSS not working correctly when converting from html to pdf
Hi, I am trying to convert the HTML string to PDF using aspose pdf. But css is not applied in the generated PDF....
Read more >
Render as pdf with css not working properly
I have a controller which calls a couple of function. The variables are then send to the apex page, which is mostly a...
Read more >
HTML to PDF Conversion CSS styles and Table of ...
We have a requirement to convert a HTML document to PDF. When we try to import the HTML using HtmlFormatProvider the CSS styles...
Read more >
Knit to pdf with css/html or convert html file to pdf file.
I like to be able to Knit to PDF with the css codes embeded from the CSS file and apply any html codes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found