In latest web development industry document conversion from one format to other format is very important. Sometimes we need to generate spread sheet files, some times we need to generate word files and some times PDF files. In this topic I will be talking about PDF file conversion.
For generating PDF files from the given data, there are a number of scripts and modules written in php and different languages. DomPDF is one of them written in php. DomPDF is fabulous in its features. It allows direct conversion of HTML files to PDF files. But there are some limitations like some times it never generates the exact copy of that HTML. Some times font-family doesn't apply correctly as we apply in HTML file. I had the same problem last days when I was using DomPDF for my PDF generation. I goggled the web and found some solutions. And on the basis of those many solutions and posts, I wrote a summarized article focusing on this problem.
It need some simple steps to follow,
Snippet 1:
If you want to use your own TTF font (say,
Snippet 2:
Please feel free to post you comments and suggestions.
Thanks
For generating PDF files from the given data, there are a number of scripts and modules written in php and different languages. DomPDF is one of them written in php. DomPDF is fabulous in its features. It allows direct conversion of HTML files to PDF files. But there are some limitations like some times it never generates the exact copy of that HTML. Some times font-family doesn't apply correctly as we apply in HTML file. I had the same problem last days when I was using DomPDF for my PDF generation. I goggled the web and found some solutions. And on the basis of those many solutions and posts, I wrote a summarized article focusing on this problem.
It need some simple steps to follow,
- Download archive from approved answer. Extract files
/dompdf/lib/fonts/times*.*
. - Copy them in your dompdf fonts folder.
- Edit
dompdf_font_family_cache.dist.php
with snippet 1. - In CSS use
font-family: times;
.
Snippet 1:
/* ... */
'times' => array (
'normal' => DOMPDF_FONT_DIR . 'times',
'bold' => DOMPDF_FONT_DIR . 'timesbd',
'italic' => DOMPDF_FONT_DIR . 'timesi',
'bold_italic' => DOMPDF_FONT_DIR . 'timesbi'
),
'times-roman' => array (
'normal' => DOMPDF_FONT_DIR . 'times',
'bold' => DOMPDF_FONT_DIR . 'timesbd',
'italic' => DOMPDF_FONT_DIR . 'timesi',
'bold_italic' => DOMPDF_FONT_DIR . 'timesbi'
),
/* ... */
If you want to use your own TTF font (say,
Arial.ttf
):- Run:
ttf2afm -o Arial.afm Arial.ttf
. (I did it in Ubuntu.) - Run:
ttf2ufm -a -F Arial.ttf
. (you can use/dompdf/lib/ttf2ufm/bin/ttf2ufm.exe
.) - Copy
Arial.*
files in/dompdf/lib/fonts/
. - Add to
dompdf_font_family_cache.dist.php
snippet 2. - In CSS use
font-family: arial;
.
Snippet 2:
/* ... */
'arial' => array (
'normal' => DOMPDF_FONT_DIR . 'Arial',
'bold' => DOMPDF_FONT_DIR . 'Arial',
'italic' => DOMPDF_FONT_DIR . 'Arial',
'bold_italic' => DOMPDF_FONT_DIR . 'Arial'
)
/* ... */
Please feel free to post you comments and suggestions.
Thanks
Really when someone doesn't understand afterward its up to other users that they will help, so here it occurs.
ReplyDeletemy website - reklama internetowa
I really love your site.. Great colors & theme. Did you
ReplyDeletecreate this amazing site yourself? Please reply back as I’m attempting to
create my own blog and would love to find out where you
got this from or just what the theme is called. Appreciate it!
instant payday loans
Feel free to visit my web blog :: payday loans reviews
This is a topic that's near to my heart... Take care! Exactly where are your contact details though? best raspberry ketone
ReplyDeleteMy website ... raspberry ketone
Hi there, yeah this post is actually pleasant
ReplyDeleteand I have learned lot of things from it concerning blogging.
thanks.
Here is my website - Vergleichen auf kfzversicherungsvergleich1.org
This website was... how do I say it? Relevant!! Finally I have found something that helped me.
ReplyDeleteKudos! espn
Also visit my blog post tv live
Good site you have got here.. It’s hard to find high quality writing like yours nowadays.
ReplyDeleteI truly appreciate people like you! Take care!! tv live
my page > watch movies online
Hello, thanks for this blog it recently helped me much.
ReplyDeleteThe issue is that i have tried adding font family "Agency FB" several times using this guide but i really dont know where do i have made mistakes. Please can you help me with this please b'se i have my project which needs reports in pdf in such fonts ("Agency FB")
Thanks a lot for the snippets :)
ReplyDelete