Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Font issue when generating PDF from URL #161

Closed
Blakey opened this Issue · 4 comments

4 participants

@Blakey

Hi,

I am running the following code :

require 'pdfkit'

PDFKit.configure do |config|
config.wkhtmltopdf = 'C:/wkhtmltopdf/wkhtmltopdf.exe'
config.default_options = {
:page_size => 'Legal',
:print_media_type => true}
end

preview_article_url = "http://www.epithimies.gr/%CE%AC%CF%81%CE%B8%CF%81%CE%BF/moirasteite-mazi-toy-tis-doyleies-toy-spitioy"

kit=PDFKit.new("#{preview_article_url}")
kit.to_pdf("temp_page1.pdf")

but it doesnt render all of the article correctly as shown in the image below:
examplegreekfont

Is this to do with the fonts PDFkit is using? I have downloaded the GNU Unicode font but cannot get it to work. Does anybody have any suggestions of better code to do this or know whether the issue is something different?

Thanks!

@Blakey

No ideas anybody ?? :(

@dongyuwei

I have solved a similar issue: pdfkit can't render a Chinese web page on ubuntu server correctly. I suggest you to check the following condition:
1. make sure your css rule declared in @media all or @media print
2. if you use custom web font face, make sure load it use correct URI(I find that a relative path will not work),such as

@media all{
   @font-face{
      font-family: WenQuanYiMicroHeiMono;
      src:url('http://<%=@host%>:<%=@port%>/pdf-fonts/WenQuanYiMicroHeiMono.ttf') format('truetype');
   }
}
@sigmavirus24

This is likely a limitation of wkhtmltopdf, how it is compiled for your server, or the fonts that wkhtmltopdf can find (as @dongyuwei suggests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.