Reputation: 43
I'm using BNHtmlPdfKit to generate pdf file from html template. This lib has a UIWebView, it will load html string.
Then it use UIPrintPageRenderer to generate pdf file.
In HTML file, I have imported 2 css files like below :
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="bootstrap.css" rel="stylesheet" type="text/css" />
Currently, the rendered pdf file has only css style of the bootstrap.css file.
However, I tried to add important! property for each item in style.css, the pdf could display css style of style.css file.
#myContent {
background-color: lightblue !important;
font-family: Helvetica Neue, sans-serif;
color: red !important;
padding: 20px;
}
Anyone has been able to generate pdf using multiple css file and without using !important property?
Upvotes: 1
Views: 513
Reputation: 1521
The crux is that bootstrap.css
overwrites your style via @media print { }
rules and UIPrintPageRenderer
prints the content to PDF file.
Upvotes: 1