-->

Rotativa Pdf generation does not respect HTML char

2019-07-18 23:33发布

问题:

I am converting from MVC HTML to Pdf using Rotativa. In HTML everything looks good, but in Pdf format, the characters spacing is not well formatted, as it is too little. This reduces the readability of the documents considerably.

In the following image is a string in HTML:

and here is the same string generated with Rotativa:

I have tried to increase the character spacing from css, but when I changed it to 1px, on the HTML side everything looks even better, but in Pdf all the strings mess-up and gain a spacing more than 10px splitting along the divs and overlapping with each other.

I found that this could be one of the Rotativa issues, like in this one, which does not help me so much as it is solved only for Debian Sid operating system, and I am using Windows, and I have installed Rotativa 1.64 using Nuget.

Does anyone know a fix for letter spacing using Rotativa?

回答1:

I have solved this issue after i changed the font-family with one imported from google. The idea came to me after I have read this article in which is described how changing font-family with a given one by url solved a wkhtmltopdf similar problem.

The code I have used to fix this is the following:

@import url('https://fonts.googleapis.com/css?family=Open+Sans');
body {
    font-family: "Open Sans";
}