SpraedPDFGeneratorBundle : Generate PDF with CSS - symfony

I'm trying to generate a PDF document from a Twig HTML Page using SpraedPDFGeneratorBundle, but the problem is that my stylesheet is not supported.
Somewhere I followed this question : Generate PDF with CSS and Images and I I tried to do like that:
<link rel="stylesheet" href="{{ app.request.scheme ~'://'~ app.request.httpHost ~ asset('css/bootstrap.min.css') }}" />
But I'm getting an error:
The exit status code '1' says something went wrong: stderr: "Exception in thread "main" java.lang.ClassCastException: org.xhtmlrenderer.render.BlockBox cannot be cast to org.xhtmlrenderer.newtable.TableBox at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:127) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:139) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:139) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:139) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.jav:..
Can someone help me ?

It is mentioned somewhere in the SpraedPDFGeneratorBundle github page this:
To define proper print css you might want to read into the w3.org's
hints on that: w3.org
One of my problem was the fact that the SpraedPDFGeneratorBundle could not correctly parse the CSS file I passed him. This is the CSS file Twitter bootstrap (the version I used):
<link rel="stylesheet" href="{{ app.request.scheme ~'://'~ app.request.httpHost ~ asset('css/bootstrap.min.css') }}" />
After changing the CSS file, I replaced my own stylesheet, everything worked properly because SpraedPDFGeneratorBundle was properly validate my stylesheet:
<link rel="stylesheet" href="{{ app.request.scheme ~'://'~ app.request.httpHost ~ asset('css/my_custom_stylesheet.css') }}" />

Related

Symfony 4 - Can't load my css on some pages

I'm creating a website with Symfony 4.
But I've a page where my css and js don't load.
In the console, I've :
GET http://localhost/symbnb/public/ads/css/bootstrap.min.css
net::ERR_BLOCKED_BY_CLIENT
maiores-nemo-excepturi-consectetur-saepe:40 GET
http://localhost/symbnb/public/ads/js/bootstrap.min.js
net::ERR_BLOCKED_BY_CLIENT
maiores-nemo-excepturi-consectetur-saepe:38 GET
http://localhost/symbnb/public/ads/js/jquery.min.js
net::ERR_BLOCKED_BY_CLIENT
maiores-nemo-excepturi-consectetur-saepe:39 GET
http://localhost/symbnb/public/ads/js/popper.min.js
net::ERR_BLOCKED_BY_CLIENT
This error is at :
http://localhost/symbnb/public/ads/maiores-nemo-excepturi-consectetur-saepe
The files don't load.
But at
http://localhost/symbnb/public/
and
http://localhost/symbnb/public/ads/
All is good.
This is my files :
And if i put a / like :
/css/bootstrap.min.js
/js/....
I've the error on all pages
Change your source by using Symfony twig asset function.
<script src="{{ asset('js/jquery.min.js') }}"></script>
<script src="{{ asset('js/popper.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
Use it the same way for CSS asset.
<link rel="stylesheet" src="{{ asset('css/boostrap.min.css') }}">
Currently your website is looking for files in a folder that doesn't exist. Try to add a leading / to all of your assets. This should fix your issue.

Github pages not rendering css correctly for Jekyll theme

This is the link to github for the theme which I'm working on: https://github.com/PrashantYadav/xosjapps
On the localhost, its working properly.
I have set the baseurl but still its rendering css correctly as you can see it here - https://prashantyadav.github.io/xosjapps/
This is the url for original theme: https://github.com/jeromelachaud/freelancer-theme
Please help.
The console said that it's failed to load ressources. Are you sure you put the correct path to the files ?
CSS files aren't being loaded properly.
Move your css files that are located in /_includes/css to /css and load them from your layout file (or include) as:
<link rel="stylesheet" href="{{ '/css/main.css' | absolute_url }}" type="text/css" />
<link rel="stylesheet" href="{{ '/css/bootstrap.min.css' | absolute_url }}" type="text/css" />

django-tables2 stylesheet not loading

I'm using Django-nonrel 1.5 and django-tables2
I'm outputting a table and it renders correctly, however there are no styling applied from the paleblue stylesheet (table has 'paleblue' class). I then added a table class with the attrs metadata but it didn't make a difference.
Whether I'm using:
<link href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" rel="stylesheet">
or
<link href="{% static 'django_tables2/themes/paleblue/css/screen.css' %}" rel="stylesheet">
it doesn't work. It does strangely enough return a 200 at this url
http://localhost:8000/static/django_tables2/themes/paleblue/css/screen.css
with the response body:
Reload the page to get source for: http://localhost:8000/static/django_tables2/themes/paleblue/css/screen.css
(which does not change after reloads)
Being appenginge, I'm using gaenv and the django-tables2 is thus in this location:
project_root/gaenv_lib/django_tables2/static/django_tables2/themes/paleblue/css/screen.css
I've added django_tables2 to the INSTALLED_APPS, and TEMPLATE_CONTEXT_PROCESSORS also has 'django.core.context_processors.request', (by default)
What am I missing to get the correct path to the css in dev env?

CSS is missing when rendering an html page with codeigniter

I'm aware this is similar to numerous existing posts but after looking at a number of others I wasn't able to solve my problem. I'm attempting to load a folder full of html files I've been supplied with. I didn't write them but I have been modifying them to integrate them into an existing system.
I've tried three ways of opening them, with varying success:
1) Simply right click on 'index.html' and go 'open with' and select a browser. This works perfectly!
2) Place the whole folder contents, unchanged, onto my server under 'public_html/cat/html' and navigating to the url 'localhost/cat/html/index.html'. This returns a '404 page not found error'.
3) The strange one. Place the html files in the 'application/view' folder, separate the included css and javascript files and place them in existing folders 'public_html/css' and 'public_html/js' and update the links to them in the html files appropriately. These now look something like:
<link type="text/css" href="css/cat/style.css" rel="stylesheet" />
If I load this page by running a function that uses CodeIgniter's $this->load->view(...) function it finds the index file but loads it with no css and with broken links to the other pages. I've explored the page source and seen that the link is exactly as above but clicking gives an error that reads "404 Not Found...The requested URL /css/cat/style.css was not found on this server".
I've attempted to use the base_url() function (and site_url()) like this:
<link type="text/css" href="<? base_url('css/cat/style.css') ?>" rel="stylesheet" />
and it yields the same result on the surface but examining the page source reveals the link line has become:
<link type="text/css" href="" rel="stylesheet" />
which seems to be even worse!
Any hints?
Thanks for reading
Try the following:
<link type="text/css" href="<?php echo base_url('css/cat/style.css') ?>" rel="stylesheet" />
base_url() functon simply return value, you should take a care for displaying returned value to output! :-)
Have you correctly configure you config file in codeIgniter ?
Or shorthand
<link type="text/css" href="<?=base_url('css/cat/style.css') ?>" rel="stylesheet" />
Then view your page source and copy the link from there to your browser, see if you can access it.
Can try this code <link type="text/css" href="<?=base_url('css/cat/style.css');?>" rel="stylesheet" />
if it doesn't work, you could try <link type="text/css" href="<?=base_url('css/cat');?>/style.css" rel="stylesheet" />

how to use the css and images in a bundle?

I'm new in symfony2, and I'm confused how to use css and image by asset.
For example, I have a boundle named userbundle, and i put my css and image in UserBundle/Resources/public/css and UserBundle/Resources/public/image. But by asset, they were located in web/acmeuser/css and web/acmeuser/image. They do not exist and of-course I can not show them.
answer:
The problem is because of the svn. If you have svn in both sides, which means in src/bundles and in web/bundles. If both of them is in svn control, then the command
assets:install web
will cause this exception:
unlink(web//bundles/framework\images.svn\text-base\open_quote.gif.svn-base): Permission denied in \vendor\symfony\src\Symfony\Component\HttpKernel\Util\Filesystem.php on line 101
If you just removed your /web/bundles and set svn ignore to it. rerun the command and all goes well.
You can try this.
{% block javascript %}
<link rel="stylesheet" type="text/css" href="{{ asset('bundles/UserBoundle/Resources/public/css/Filename.css') }}" ></link>
<script type="text/javascript" src="{{ asset('bundles/UserBoundle/Resources/public/js/Filename.js') }}">
</script>
{% endblock %}

Resources