-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdompdf-failing-to-render-certain-accented-characters-9be35f0c13a6.html
228 lines (174 loc) · 8.25 KB
/
dompdf-failing-to-render-certain-accented-characters-9be35f0c13a6.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="" />
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,700;1,400&family=Source+Sans+Pro:ital,wght@0,300;0,400;0,700;1,400&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./theme/stylesheet/style.min.css">
<link id="pygments-light-theme" rel="stylesheet" type="text/css"
href="./theme/pygments/github.min.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/fontawesome.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/brands.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/solid.css">
<link href="https://shanedowling.com/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Shane Dowling Atom">
<link href="https://shanedowling.com/feeds/all.rss.xml" type="application/rss+xml" rel="alternate" title="Shane Dowling RSS">
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'G-Z9P3V6D0SV', 'auto');
ga('send', 'pageview');
</script>
<meta name="author" content="Shane Dowling" />
<meta name="description" content="I've noticed some issues with DOMpdf when trying to generate PDFs using their internal Helvetica font. After banging my head against a wall for a few hours trying to "fix" UTF-8 support, it turned out UTF-8 support was working fine. Essentially DOMpdf's internal Helvetica font didn't support a few polish …" />
<meta name="keywords" content="">
<meta property="og:site_name" content="Shane Dowling"/>
<meta property="og:title" content="DOMpdf failing to render certain accented characters"/>
<meta property="og:description" content="I've noticed some issues with DOMpdf when trying to generate PDFs using their internal Helvetica font. After banging my head against a wall for a few hours trying to "fix" UTF-8 support, it turned out UTF-8 support was working fine. Essentially DOMpdf's internal Helvetica font didn't support a few polish …"/>
<meta property="og:locale" content="en_US"/>
<meta property="og:url" content="./dompdf-failing-to-render-certain-accented-characters-9be35f0c13a6.html"/>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="2014-08-21 00:00:00+00:00"/>
<meta property="article:modified_time" content=""/>
<meta property="article:author" content="./author/shane-dowling.html">
<meta property="article:section" content="Tech"/>
<meta property="og:image" content="/images/logo.png">
<title>Shane Dowling – DOMpdf failing to render certain accented characters</title>
</head>
<body class="light-theme">
<aside>
<div>
<a href="./">
<img src="/images/logo.png" alt="Shane Dowling" title="Shane Dowling">
</a>
<h1>
<a href="./">Shane Dowling</a>
</h1>
<p>Platform Engineering Manager</p>
<nav>
<ul class="list">
<li>
<a target="_self"
href="./pages/contact.html#contact">
Contact
</a>
</li>
<li>
<a target="_self"
href="./pages/now-page.html#now-page">
Now Page
</a>
</li>
<li>
<a target="_self"
href="./pages/statuslog.html#statuslog">
Statuslog
</a>
</li>
<li>
<a target="_self" href="https://hybridcloudshow.com/" >podcast</a>
</li>
<li>
<a target="_self" href="https://pemonthly.com/" >newsletter</a>
</li>
</ul>
</nav>
<ul class="social">
<li>
<a class="sc-github"
href="http://github.com/shano"
target="_blank">
<i class="fa-brands fa-github"></i>
</a>
</li>
<li>
<a class="sc-mastodon"
rel="me" href="http://social.lol/@sed"
target="_blank">
<i class="fa-brands fa-mastodon"></i>
</a>
</li>
<li>
<a class="sc-linkedin"
href="https://www.linkedin.com/in/shanedow/"
target="_blank">
<i class="fa-brands fa-linkedin"></i>
</a>
</li>
</ul>
</div>
</aside>
<main>
<article class="single">
<header>
<h1 id="dompdf-failing-to-render-certain-accented-characters-9be35f0c13a6">DOMpdf failing to render certain accented characters</h1>
<p>
Posted on Thu 21 August 2014 in <a href="./category/tech.html">Tech</a>
</p>
</header>
<div>
<p>I've noticed some issues with DOMpdf when trying to generate PDFs using
their internal Helvetica font. After banging my head against a wall for
a few hours trying to "fix" UTF-8 support, it turned out UTF-8 support
was working fine. Essentially DOMpdf's internal Helvetica font didn't
support a few polish characters. Specifically the Sacute, sacute and a
few others like this. This was a bit of a killer problem for my
requirements so I needed a work-around. My workaround was to use Arial
fonts(they were close enough), but if you really need Helvetica you
could source a copy of the .ttfs and replicate these steps.</p>
<h3>Download Arial fonts</h3>
<p>wget <a href="http://www.drivehq.com/file/df.aspx/shareID2129391/fileID59377155/arial.ttf">http://www.drivehq.com/file/df.aspx/shareID2129391/fileID59377155/arial.ttf</a>
wget <a href="http://www.911fonts.com/fonts/6/0/5/605.ttf">http://www.911fonts.com/fonts/6/0/5/605.ttf</a> -O arialit.ttf
wget <a href="http://4nts.com/fonts/arialbd.ttf">http://4nts.com/fonts/arialbd.ttf</a>
wget <a href="http://www.911fonts.com/fonts/6/0/4/604.ttf">http://www.911fonts.com/fonts/6/0/4/604.ttf</a> -O arialbit.ttf</p>
<p>This downloads arial, arial-bold, arial-oblique and arial-boldoblique.</p>
<h3>Generate compatible dompdf files</h3>
<p>Pull up a terminal and cd into your dompdf folder. If you're using
composer, it'll be /vendor/dompdf/dompdf</p>
<p><code>php load_font.php arial ~/arial.ttf ~/arialbd.ttf ~/arialit.ttf ~/arialbit.ttf</code></p>
<p>You should now see an entry in lib/fonts/dompdf_font_family_cache.php</p>
<div class="highlight"><pre><span></span><code><span class="x">arial' =></span>
<span class="x"> array (</span>
<span class="x"> 'normal' => DOMPDF_FONT_DIR . 'arial',</span>
<span class="x"> 'bold' => DOMPDF_FONT_DIR . 'arialbd',</span>
<span class="x"> 'italic' => DOMPDF_FONT_DIR . 'arialit',</span>
<span class="x"> 'bold_italic' => DOMPDF_FONT_DIR . 'arialbit',</span>
<span class="x"> ),</span>
</code></pre></div>
<p>You can now reference the Arial font-family in your DOMpdf stylesheets
and have it render some nice Helvetica like fonts.</p>
<p>If you are using composer with DOMpdf, I would highly recommend not
leaving your custom fonts in DOMpdfs vendor folder. Copy the fonts
directory somewhere in your projects directory, and over-ride this
variable with your own def, referencing the new folder location.</p>
<div class="highlight"><pre><span></span><code><span class="x">def("DOMPDF_FONT_DIR", DOMPDF_DIR . "/lib/fonts/");</span>
</code></pre></div>
<p>This means you shouldn't need to rely on dodgy customisations to the
vendor folder.</p>
</div>
<div class="tag-cloud">
<p>
</p>
</div>
</article>
<footer>
<p>© </p>
<p>
Built with <a href="http://getpelican.com" target="_blank">Pelican</a> using <a href="http://bit.ly/flex-pelican" target="_blank">Flex</a> theme
</p></footer> </main>
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Blog",
"name": " Shane Dowling ",
"url" : ".",
"image": "/images/logo.png",
"description": ""
}
</script>
</body>
</html>