pruiz / WkHtmlToXSharp

C# wrapper wrapper (using P/Invoke) for the excelent Html to PDF conversion library wkhtmltopdf library.
239 stars 84 forks source link

Suport Custom Font #39

Closed liguobao closed 7 years ago

liguobao commented 7 years ago

Hi,Pruiz.thanks your project very mach! WkHtmlToXSharp is very good! I've got some problems on with WkHtmlToXSharp, My HTML like the document: <h1 style='font-family:Microsoft YaHei;'>I am Microsoft YaHei;...</h1> The HTML font is “Microsoft YaHei”,but the PDF font is “SimSun”,eg:

htmlsimsun

pdf

I find some people discuss the problem on stackoverflow:use-custom-fonts-with-wkhtmltopdf.

Many people suggest use “@font-face”,eg:

<html>
<style type="text/css">
@font-face {
   font-family: 'MSYH';
   font-style: normal;
   font-weight: normal;
   src: url(http://7xrayk.com1.z0.glb.clouddn.com/MSYH.TTC) format('truetype');
   }
</style>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<h1 style='font-family:MSYH;'>I am Microsoft YaHei;...</h1>
<h1 style='font-family:Microsoft YaHei;'>I am Microsoft YaHei;...</h1>
</html>

But Convert to pdf too slow because “Microsoft YaHei”(MSYH.TTC) more than 20M.

So,I want to add "Microsoft YaHei" to WkHtmlToXSharp project.

What should I do?

Thanks and Regards.

pruiz commented 7 years ago

Hi,

I may not understand you correctly. But including (embedding) the font as part of wkhtmltoxsharp is a bit out of scope of this proyect. As this font is not something every user of this component may want/need.

What exactly are you asking for?

liguobao commented 7 years ago

Yes,I want to embedding "Microsoft YaHei" font to the project and set as defualt. At present,"Simsun" of the font is default wkhtmltoxsharp,but my web font is "Microsoft YaHei". If my web contains the font ,the page site is too big.so... Thanks and Regards.

pruiz commented 7 years ago

I am afraid, the fonts you think are embedded by WkHtmlToXSharp, are in fact embedded by WebKit (or wkhtmltopdf), or simply installed by default at the operating system you are running this code on top of.

We (WkHtmlToXSharp) do not embed any font, or any additional rendering resource, aside from those already supplied upstream.

liguobao commented 7 years ago

My computer has installed YaHei of the font but the font is not enabled on convert to pdf.So I want to embed the font to WkHtmlToXSharp .