Wicked PDF changing font-size and font-family in Rails Production - wicked-pdf

Why wicked_pdf renders different in Rails environment (development & production) font-size and font-family changes.
I'm using Amazon EC2 Linux as production environment.
Even I already set the font-size & font-family in CSS.
How to make or set it to have consistent display of data.
Please help!

SOLVED
I fixed it by:
First: Importing my local system fonts to EC2 Serverm, using scp.
Note: Make sure to back up first.
Secondly:
I found a solution also here in stack, to use and import fonts.
In you applicantion directory:
mkdir fonts
> add the fonts you will use, in my case Arial
cd fonts
mkdir .ebextensions
vi copy_fonts.config
> put the code below:
container_commands:
copy_fonts:
command: "cp fonts/*.ttf /usr/share/fonts/"
I hope this will help others who encountered the same issue.

Related

lessc Option --source-map-rootpath seems not to work

I use lessc 2.7.3. I generate css files via a makefile and use following paths
the makefile is in themes/bodensee
the css is generated in themes/bodensee/css
the less files are in themes/bodensee/less
the maps are in the same folder as the css files.
My problem is that css files misses the themes/bodensee path, so it raises a file not found on css.map files.
lessc -s less/wlb.less --clean-css="--s0 --advanced" --source-map-rootpath=themes/bodensee/ --source-map="css/wlb.css.map" css/wlb.css
The CSS file now contains `sourceMappingURL=css/wlb.css.map``The rootpath does not have any effect.
I also tried a fantasy rootpath and searched for it in the file - it does not appear anywhere. But the option is correct. When I try to missspell the option, LESS drops an error.
What am I missing?
Description of the --source-map-rootpath option from here
Specifies a rootpath that should be prepended to each of the less file paths inside the sourcemap and also to the path to the map file specified in your output css.
Because the basepath defaults to the directory of the input less file, the rootpath defaults to the path from the sourcemap output file to the base directory of the input less file.
Use this option if for instance you have a css file generated in the root on your web server but have your source less/css/map files in a different folder. So for the option above you might have
The problem was indeed related to the Clean-CSS plugin.
I now call
lessc --source-map --clean-css="--s0 --advanced" -s less/wlb.less css/wlb.css which is working.
There is a standalone clean-css program, but that does not generate sources for the Less files. It's not clear if the lessc plugin and the standalone tool are the same or different implementations but both use node.
The standalone cleancss tool removes the source map URL generated by lessc be default (did not play around with the dozens of options).
These Node tools develop very fast and manual/tutorials often are outdated. That's why my make file stopped working. Developers of that tools should really consider not to touch working parameters or features and to keep their code compatible.

Sylius Stylesheet Not Reloading

So here's a question. I'm new to Sylius, and am working on some simple CSS updates. I have a local copy of Sylius running with the built-in webserver: server:run. I also have a development server on Digital Ocean, which runs an (almost) identical copy of Sylius, aside from the configs of course.
Something strange is happening with my CSS update, however. I made a change to .navbar-brand within web/assets/compiled/backend_backend_4.css.
This change showed up immediately on my local. On the development server, however, when pulling down the change (git), and verifying that it now exists in that file, the change doesn't seem to propegate. It's effects aren't shown, inspecting the stylesheet doesn't show them, and furthermore viewing the css file sourcecode directly in the browser does not show the change. But on the filesystem it's definitely there.
I've tried clearing the cache, to no avail.
I also checked the assetic value in both config_dev.yml files, and verified they are both set to use_controller: true
Even still, I tried dumping assetic, to no avail.
So I'm wondering what's going on. Additionally, I realize that I probably shouldn't edit CSS files within a folder called 'compiled'. I'm sure there's a way to do that using a compiler, but I'm not yet familiar with the process and am just making minor changes and learning about caching so far.
Yes you are right you shouldn't be editing the compiled files.
You should edit the source files, then run gulp
or on my system i have to explicitly run npm run gulp
I've documented the solution that worked for me here. It didn't involve Gulp at all, but instead uses Assetic:
Assets need to be installed as hard copies first (I'm not quite sure
what this does exactly, but it seems like an important step because
it copies a lot of assets to places. Documentation was unhelpful but
it was suggested on Stack Overflow somewhere.):
app/console assets:install web
Assets should be edited in web/bundles/[bundle-here]/css or js. This
is frequently within syliusweb if it has to do with page styles /
layouts.
Hint: These assets are referred to in files such as
src/Sylius/Bundle/Resources/views/Backend/layout.html.twig (see the
opening:
(% stylesheets
tag, or search universally for this tag).
Within this tag, you'll see that stylesheets have an output to the compiled folder, but also list the
bundles where they pull their original css from. You should edit one of the source css files, if you'd like your changes to end up in the destination css.
After editing assets, dump assetic:
php app/console assetic:dump
Note - it is also possible to set an assetic watcher on these assets
(google to find out how, think it's a -w flag somewhere), but this is
said to only work in development mode, as it should.
After dumping assetic, the assets from the source bundles compile into their assets/compiled versions, usually combining multiple stylesheets. You should now see your asset refresh!

Impresspages file uploads mask

Linux server, running suphp with Apache 2.2.22 and PHP5.5.17
When I upload an image using the image widget, it is stored in a date-based path under /file
the path directories are created with properties of -rwx------, and the file is stored with properties of -rw-------
This works fine when I am traversing the directory using shell, but Apache can't see the files, as it runs as not me.
What is a safe file into which I can add umask(002); that will be early enough in the application logic, but won't get overridden by updates? Can I create a Plugin and make it the only thing in the routes.php? Can I put this in my Theme file?
There is no such setting in ImpressPages yet. I guess you have to configure your Linux to use the right mask by default. Have you seen such a setting on other CMSs or Frameworks?

Phantomjs not render hebrew fonts

I am using PhantomJs 1.9.2 on Centos 6.3 to for automated ui tests. When a test fails,
screenshots are saved to the server.
My problem is that even though the screenshots are saved, they do not contain readable fonts.
So if the website reads like this:
חיים טכנולוגיים
the screenshot of the site will look like this:
םםםםםםםםםםםםם
So, instead of the actual letters, it renders and saves little boxes.
The system is centos 6.3. Freetype and Fontconfig are also installed.
How could I go about fixing this?
Thanks!
follow these steps:
in /usr/share/fonts/ I added a folder named arial with the arial.ttf for hebrew
I ran fc-cache -vf.
That's it! I did not edit or change fonts.conf or did anything else as suggested in the link.
You should use python code for taking screenshots of website. there are two module which will do whatever you want pyvirtualdisplay & selenium. Install them and write a class to create screenshot and call it with command line with your code.
Best of luck...
I recently had to fix the same problem myself. I ended up doing what's suggested in the this answer. Well, sort of. I skipped some of the steps:
in /usr/share/fonts/ I added a folder named arial with the arial.ttf for hebrew
I ran fc-cache -vf.
That's it! I did not edit or change fonts.conf or did anything else as suggested in the link.
Granted, I still had a little trouble with parts of the page (I'm guessing it was because they were using fonts other than arial), but I ended up not needing them. Hopefully that'll be good enough for you too!

Font is not available to the JVM with Jasper Reports

I'm trying to generate report with DynamicJasper, but I'm getting the following error:
net.sf.jasperreports.engine.util.JRFontNotFoundException:
Font 'Arial' is not available to the JVM.
msttcorefonts is installed, but I guess the JVM is not using any fonts from it.
I'm using Ubuntu 10.04.
How can I fix this?
I tried installing mscorefonts, but the package was installed and up-to-date.
sudo apt-get update
sudo apt-get install ttf-mscorefonts-installer
I tried searching for the font in the filesystem, with:
ls /usr/share/fonts/truetype/msttcorefonts/
This folder just had the README, with the correct instructions on how to install.
cat /usr/share/fonts/truetype/msttcorefonts/README
You need an internet connection for this:
sudo apt-get install --reinstall ttf-mscorefonts-installer
I re-installed ttf-mscorefonts-installer (as shown above, making sure to accept the EULA!) and the problem was solved.
JasperReports raises a JRFontNotFoundException in the case where the font used inside a report template is not available to the JVM as either as a system font or a font coming from a JR font extension. This ensure that all problems caused by font metrics mismatches are avoided and we have an early warning about the inconsistency.
Jasper reports is trying to help you in your report development, stating that it can not export your report correctly since it can not find the font defined in TextField or StaticText
<font fontName="Arial"/>
Yes you can disable this by setting net.sf.jasperreports.awt.ignore.missing.font to true but you will have export inconsistencies.
Yes you can install the font as JVM system font (but you need to do it on every PC used that may generate report and you can still have encoding problems).
The correct way!
Use Font Extensions!, if you like to create your own (see link below), jasper reports also distributes a default font-extension jar (jasperreports-fonts-x.x.x.jar), that supports fontName DejaVu Sans, DejaVu Serif and DejaVu Sans Mono
<font fontName="DejaVu Sans"/>
From the JasperReport Ultimate Guide:
We strongly encourage people to use only fonts derived from font
extensions, because this is the only way to make sure that the fonts
will be available to the application when the reports are executed at
runtime. Using system fonts always brings the risk for the reports not
to work properly when deployed on a new machine that might not have
those fonts installed
Links on StackOverflow on how to render fonts correctly in pdf
Checklist on how to render font correctly in pdf
Generate font-extensions with JasperSoft Studio
Generate font-extensions with iReport
I use IReport to install font:
tools -> options -> fonts -> click install font
Then select the font and click
-> export as extension and type name myfont.jar
add this jar and also spring.jar* to your build path.
*copy spring.jar from Jaspersoft\iReport-3.7.0\ireport\modules\ext
sudo apt-get install msttcorefonts works (on our Ubuntu development environment), but is not a very good solution.
Instead, we bundled the fonts with our application based on this tip. Their JAR file bundles the following fonts,
Arial
Times New Roman
Courier New
Comic Sans MS
Georgia
Verdana
Monospaced
Direct Link to download jar:
Maven ver 1.0. DynamicFonts
There are three method to avoid such a problem.
Method 1 : by setting ignore missing font property.
JRProperties.setProperty("net.sf.jasperreports.awt.ignore.missing.font", "true");
or you can set this property by entering following line into .jrxml file.
<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
Method 2 : by setting default font property.
JRProperties.setProperty("net.sf.jasperreports.default.font.name", "Sans Serif");
or you can set this property by entering following line into .jrxml file.
<property name="net.sf.jasperreports.default.font.name" value="Sans Serif"/>
Method 3 : by adding missing font property.
Firstly install missing fonts in IReport by selecting " Tools >> Options >> Fonts >> Install Font " then select the all font and Export this By clicking on "Export as Extension" with .jar Extension.
You can use this jar for Jasperreports-font.X.X.X.jar which will be present in your project library or classpath.
For CentOS:
wget msttcorefonts
Then:
tar -zxvf msttcorefonts.tar.gz
cp msttcorefonts/*.ttf /usr/share/fonts/TTF/
fc-cache -fv
After all, restart JVM.
I solved this by choosing 'SansSerif' or 'Serif' only and not 'Arial' or 'Times New Roman'.
If you are using maven in your project, you can just add the jasper-fonts dependency to pom.xml:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.8.1</version>
</dependency>
Installing the missing font on the system may be a working solution but not for me, I didn't want to have to install the missing fonts after each deployment in a new server, instead I opted for embedding the font with the application.
Regards.
Try adding the line
net.sf.jasperreports.awt.ignore.missing.font=true
to your jasperreports.properties file.
Jasper stops finding one font
For Debian
add
non-free contrib
to deb and deb-src in /etc/apt/sources.list ie:
deb http://ftp.debian.org/debian/ squeeze main non-free contrib
deb-src http://ftp.debian.org/debian/ squeeze main non-free contrib
Then
apt-get update
apt-get install msttcorefonts
Of course you'll need to restart jasperserver. ie:
/opt/jasperreports-server-cp-4.5.0/ctlscript.sh restart
Change for your version / path.
I faced the issue with my web application based on Spring 3 and deployed on Weblogic 10.3 on Oracle Linux 6. The solution mentioned at the link did not work for me.
I had to take the following steps -
1. Copy the Arial*.ttf font files to JROCKIT_JAVA_HOME/jre/lib/fonts directory
2. Make entries of the fonts in fontconfig.properties.src
3. Restart the cluster from Weblogic console
filename.Arial=Arial.ttf
filename.Arial_Bold=Arial_Bold.ttf
filename.Arial_Italic=Arial_Italic.ttf
filename.Arial_Bold_Italic=Arial_Bold_Italic.ttf
You can do it by installing fonts, that means everywhere you want to run that particular application. Simplest way is just add this bl line to your jrxml file:
<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
can make your custom fonts via iReport and converting like jars files
Create jasper report in multiple languages(Unicode)
1)Install font in ireport desginer
2)create extension of font(we will use it in applications classpath)
3)install font on os(optional)
4)paste all .ttf of font in jre->lib->fonts directory (otherwise web application will throw error font is not available to JVM)
You can use this library which packages the Liberation-fonts as JasperReport font extension, and registers them as Arial, Times New Roman and Courier:
https://mvnrepository.com/artifact/com.mpobjects.jasperreports.font/jasperreports-fonts-liberation
Actually I fixed this issue in a very simple way
go to your home path, like /root
create a folder named .fonts
copy your all your font files to .fonts, you can copy the font from C:\windows\fonts if you use windows.
sudo apt-get install fontconfig
fc-cache –fv to rebuid fonts caches.
Solution in 2 steps (if you are using centOS)
Download the Microsoft core fonts rpm package.
[root#WEBSVR~/]# wget http://www.itzgeek.com/msttcore-fonts-2.0-3.noarch.rpm
Install rpm package.
[root#WEBSVR~/]# rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm
Add the below in your .jrxml file:
<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
Copy your Fonts on the following directory
JDK_HOME\jre\lib\fonts
Hey Having trouble viewing documents produced on Windows?
You can try a fine solution easy:
yum install curl cabextract xorg-x11-font-utils fontconfig
rpm -i
https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm
After this I need reboot my system CentOS6.
Source: http://mscorefonts2.sourceforge.net/