So I am using https://github.com/chrisnharvey/CodeIgniter-PDF-Generator-Library/wiki to easily make PDF's on my system.
I am also using bootstrap. Now when I run the code, my styles dont' get extracted. And I get the following error:
Illegal string offset 'hex'
If I remove my stylesheets, I don't get the error but nothing is styled.
I am loading my styles like so:
<link href="http://the-green-panda.org/themes/admin/Adminica/css/bootstrap.min.css" rel="stylesheet" />
<link href="http://the-green-panda.org/themes/admin/Adminica/css/theme.css" rel="stylesheet" />
I did enable remote in the dompdf_config.inc.php file
def("DOMPDF_ENABLE_REMOTE", true);
Has anyone else used this codeigniter library and successfully linked style sheets to make the pdf's look nicer?
Related
I am working with node.js, express and .ejs files. My style did work and i did not change anything about it before it stopped.
Here is the code:
https://github.com/RTweety/todoapp-v1/tree/main/todoapp-v1
I've checked the path and changed both it in the script.js and list.ejs but no response.
I also tried to restore the code to the point when it did work but it did not work.
I've cloned Your Project and You have bug in header.ejs file.
Instead of this line
<link type="text/css" href="css/styles.css" />
You should use <link/> tag like that and that's it ! :-)
<link rel="stylesheet" href="css/styles.css" />
Here You have reference about How To link an external stylesheet
Folder and file structure script.js, header.ejs, terminal:
Output in browser:
I'm using less for a web-app. In development environment, I have something like
<head>
<link rel="stylesheet/less" type="text/css" href="test.less"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/3.0.2/less.min.js" ></script>
</head>
this is working correctly: my test.less file is downloaded and converted into valid css by less, automatically.
Now, If the user navigate in a particular section of the site, I need to download another .less file. To do so, I create a element on the fly like this:
<link rel="stylesheet/less" type="text/css" href="test2.less"/>
and append it to the head.
This is NOT working - at least in Chrome 66.0.3359.117 - because the browser is not triggering the file download at all.
I resolved the problem by modifying the link 'rel' attribute:
<link rel="stylesheet" type="text/css" href="test2.less"/>
This way, the browser correctly download the file test2.less; however, it's content is not automatically parsed by less, so it is not converted to valid .css
I think that when less.js is downloaded, it executes by searchings all element with attribute rel = "stylesheet/less" and parsing them - stop.
But after then, it "stops" listening to other .less files downloaded asynchronously.
There is a way to "trigger" less parsing?
Thank you
Ok, so far I've found a solution.
I bet there are more efficient solutions, but for now I'll proceed this way.
I append the element
<link rel="stylesheet/less" type="text/css" href="test2.less"/>
in the head of the document, and this is not triggering the file download.
After that, I call the function
less.registerStylesheets().then(less.refresh);
This is causing less to read again the document, ask for all documents and parsing again them all... not efficient, but it works.
I wonder if exist a method to tell to less to import just a single file...
Edit: a small improvement:
instead of doing
less.registerStylesheets().then(less.refresh);
I can do
less.sheets.push(link);
less.refresh();
link is the reference to the link created. This way less won't read again all the document, searching for links; instead, it will just prepare the XHR for the new link created and parse that.
I have not worked on JSPs for a long time and I'm not sure how to approach this issue.
I have this following code which tries to load a stylesheet in a page in the following way-
In JSP-
<link type="text/css" rel="stylesheet" href='<bean:message key="properties.file.key" bundle="propertiesFile" />' />
In propertiesFile.properties file-
properties.file.key=//dummy.website.com/absolute/path/of/cssFile.css
The same css file is downloaded and available locally as well.
Now, I want to fetch the cssFile.css from the dummy.website.com first, if I'm unable to do it (due to various reasons like the css may not be available anymore or the website may be blocked by the browser, etc...), I want to fetch it from the local location. Is there anyway I could do that?
So, I have the classical problem described in the post title. In my jsp, I am trying to look for the css using this:
#import url(WebContent/css/adminstyle.css);
In order to help me diagnose the problem, I am trying to print on the jsp itself the value of what the above statement is resolving the url to. How can I get it
to print the value of:
#import url(WebContent/css/adminstyle.css)
I want to know what url the above statement in resulting in after it is evaluated.
Why you are using above statement to include css? You can use javascript statement to do your task.
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
Here i have style.css in css folder.
and even if you can find your images, you can find path to it or any file in project using,
String absolutePath = getServletContext().getRealPath("image.jpeg");
absolutePath can be used in img tag. Just put it in scriptlet.
I usually after css modification, change the version of css file in master.
then i must upload css file and master file.
is there any solution to change css version without need to upload master.
<link rel="stylesheet" href="<%=ResolveUrl("~/themes/default/style.css?v2") %>" type="text/css"/>
i am using asp.net.
Seeing how you do not want to change anything but the CSS file itself you could write a custom method which wraps ResolveURL and appends the last modified date of the css file in a set format (i.e. MMddyyhhmmss). This would automatically update whenever the file gets changed.
Something along the lines of:
<link href="<%= VersionCssUrl("~/Styles/Site.css") %>" rel="stylesheet" type="text/css" />
C#:
public string VersionCssUrl(string url)
{
// Get physical path.
var path = HttpContext.Current.Server.MapPath(url);
return String.Format("{0}?{1}",
ResolveUrl(url),
File.GetLastWriteTime(path).ToString("MMddyyhhmmss"));
}
Alternatively, it might be worth looking into any of these:
Shinkansen
ClientDependency
Cassette, as mentioned by TJB
.NET built-in bundling
There are lots of automated solutions for this now-a-days
Cassette # http://getcassette.net/ is open source
It will detect changes in the .css files and if you use their markup it will automatically append a hash (so you don't even have to manually update the version!)
They have installation via Nuget which simplifies the configuration / setup.