Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kerning issues with IronPDF HTML Conversion #6

Open
DanieleDaccurso opened this issue Nov 26, 2018 · 30 comments
Open

Kerning issues with IronPDF HTML Conversion #6

DanieleDaccurso opened this issue Nov 26, 2018 · 30 comments

Comments

@DanieleDaccurso
Copy link

DanieleDaccurso commented Nov 26, 2018

Hi

I noticed that there are some issues with the kerning when converting HTML to PDF using IronPDF. Depending on the font-size, the kerning is faulty. Is there a workaround in order to have it working right?

Here you can see an example:

testtext

And the code used to create exactly this example.

namespace IronPdfTest2
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var Renderer = new IronPdf.HtmlToPdf();
            var PDF = Renderer.RenderHtmlAsPdf("<h1 style='font-family: calibri;'>Pack my box with five dozen liquor jugs.</h1>" +
                                               "<span style='font-size: 8px; font-family: Calibri'>Pack my box with five dozen liquor jugs.</span> <br>" +
                                               "<span style='font-size: 6px; font-family: Calibri'>Pack my box with five dozen liquor jugs.</span> <br>" +
                                               "<span style='font-size: 4px; font-family: Calibri'>Pack my box with five dozen liquor jugs.</span> <br>");
            var OutputPath = "HtmlToPDF.pdf";
            PDF.SaveAs(OutputPath);
            System.Diagnostics.Process.Start(OutputPath);
        }
    }
}

Furthermore:

  • Using a different PDF reader does not solve the issue
  • Using pt or em for font-sizes instead of px still had various kerning issues
  • The issues seem to be depending on the font-size. Larger fonts tend to have different issues
  • The tests have been made on Windows 10

I found a similar issue in wkhtml2pdf. I don't know if IronPDF uses wkhtml2pdf in the background (or, the webkit engine in general), but if it does, it might be related: wkhtmltopdf/wkhtmltopdf#45

@IronPdf
Copy link
Owner

IronPdf commented Nov 26, 2018 via email

@nbaranidharan
Copy link

Team,
Is there any solution for this issue? Thank you.

@IronPdf
Copy link
Owner

IronPdf commented May 31, 2019 via email

@ghost
Copy link

ghost commented Aug 21, 2019

We're currently trialling IronPDF for a few projects and seeing this issue too, anyone have any workarounds for it as the files really don't look very professional?

@dradovic
Copy link

We are facing the same problem after an upgrade from 5.2.0.1 to 2020.3.2. The kerning of the characters are so bad that we cannot go live with this upgrade.

BTW: we are using "Arial" as a font family and it only appears on Windows 10 and on Azure. However the documents seems to be fine when generated in our CI in a Linux container.

@adbdehghan
Copy link

Hey guys we are facing this issue any update on this?

@unruledboy
Copy link

unruledboy commented Oct 7, 2020

Same problem here, with latest version, no matter how big the letter-spacing we set, the letters are just overlapping each other.

Had no choice, but downgraded to 2019.8.9. All versions after that have the problem.

@joes0ft
Copy link

joes0ft commented Oct 9, 2020

Same kerning issues on Win10 2004 using the latest IronPDF 2020.10.2.
Anybody from IronPDF can help us find a resolution to this problem?

IronPDF_kerning_issues

@adbdehghan
Copy link

adbdehghan commented Oct 10, 2020

Same kerning issues on Win10 2004 using the latest IronPDF 2020.10.2.
Anybody from IronPDF can help us find a resolution to this problem?

IronPDF_kerning_issues

I figured it out, You should import the font in your css don't import it like this ->

Screen Shot 2020-10-10 at 4 48 54 PM

just import your font with @import url('https://fonts.googleapis.com/css?family='); and it'll works perfect.

@AIZ-THerring
Copy link

2-1/2 years later, and this is still a problem with IronPdf.

In my particular case, the suggestion to use @import isn't helpful because it's a Windows TrueType font on the server (a standard Windows font) where we're seeing the issue.

@dradovic
Copy link

dradovic commented Apr 22, 2021

@AIZ-THerring Is it related to the Known Issue listed under https://ironpdf.com/docs/questions/azure/?

For us, all kerning issues disappeared when we switched from Windows to Linux Docker images.

@AIZ-THerring
Copy link

AIZ-THerring commented Apr 22, 2021

We are currently looking into Docker as a solution for the web font problem, but it would have to be a Windows image. Our app is in DotNet 4.7.2 and can't be upgraded to DotNet Core because of another dependency it has.

Edit: Let me clarify. We currently can't use Web Fonts because the app is running as an Azure Web App. We're looking into changing the hosting model to a Docker container hosted in an Azure ASP so that Web Fonts will work.

FYI, that link doesn't go directly to an issue. It goes to an empty search result.

@DanieleDaccurso
Copy link
Author

DanieleDaccurso commented Apr 22, 2021

Disclaimer: I haven't used IronPDF since creating this issue almost 3 years ago because it was a deal-breaker. Considering the price of IronPDF, this issue was not acceptable.

Changing font made the issue more, or less apparent.
If there is no alternative to IronPDF for your use-case, consider using another font.

@AIZ-THerring
Copy link

So far we've discovered that we can tweak the font-spacing in the CSS to make it acceptable. I'm mostly afraid this problem will get fixed and break all of our documents with too much space, so I want it fixed early before we create too many more.

Changing fonts is problematic because we're a large company and the fonts are specified by the Marketing department, and they have to approve all final documents during the implementation process. That's a political battle I'd rather not have to wage.

If you don't mind, could you send me a PM and let me know what you switched to for a solution? We just switched to IronPdf because it seemed to have the best support for Azure of all the PDF processors we were considering.

@DanieleDaccurso
Copy link
Author

DanieleDaccurso commented Apr 22, 2021

Same problem for us, big company, corporate identity.

I wasn't aware Github had a PM function. How would I PM you? Sorry I'm not here often

@AIZ-THerring
Copy link

My bad. There isn't a messaging system. I thought I'd done it with someone before a year or two ago, but I think I talked with him on an issues list.

@IronPdf
Copy link
Owner

IronPdf commented May 21, 2021 via email

@IronPdf
Copy link
Owner

IronPdf commented May 21, 2021 via email

@IronPdf
Copy link
Owner

IronPdf commented Jul 23, 2021 via email

@IronPdf
Copy link
Owner

IronPdf commented Jul 23, 2021 via email

@IronPdf
Copy link
Owner

IronPdf commented Aug 27, 2021 via email

@IronPdf
Copy link
Owner

IronPdf commented Aug 27, 2021 via email

@NguyenTung103
Copy link

image
I followed the request for the new version but the problem is that the error occurs
Error while deploying Chrome dependencies. To learn how to solve this issue please read https://iron.helpscoutdocs.com/article/166-error-while-deploying-chrome-dependencies [Issue Code IRONPDF-CHROME-DEPLOYMENT-ERROR]

@djrecipe
Copy link

image I followed the request for the new version but the problem is that the error occurs Error while deploying Chrome dependencies. To learn how to solve this issue please read https://iron.helpscoutdocs.com/article/166-error-while-deploying-chrome-dependencies [Issue Code IRONPDF-CHROME-DEPLOYMENT-ERROR]

IronPdf.Linux v2021.12.4495 works for me using example code like this:

` class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
try
{
IronPdf.Logging.Logger.EnableDebugging = true;
IronPdf.Logging.Logger.LogFilePath = "Default.log";
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;

            IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = false;
            IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;

            //IronPdf.Installation.Initialize();

            var doc = IronPdf.ChromePdfRenderer.StaticRenderHtmlAsPdf("qwewqewqe"); //something happens here
            doc.SaveAs($"{Environment.CurrentDirectory}/{DateTime.Now.Ticks}.pdf"); //this instruction won't be processed if i set breakpoint or use <F10>
                                                                                    //if there no breakpoints - usually it works under docker for a few moments, but falls immediately on test server (debial)
                                                                                    //if there breakpoint (or some other delay) - container still alive, but debug session ruins
                                                                                    //
                                                                                    //same with instance calls (e.g.  var Renderer = new ChromePdfRenderer(); Renderer.RenderHtmlAsPdf..)
                                                                                    //same on net 5.1 and 3.1, using all docker file examples from here - https://ironpdf.com/docs/questions/docker-linux/ (with replaced project name, of course)
                                                                                    //
                                                                                    //under wsl2 have the same result as this: https://github.com/IronPdf/Iron-Pdf-Documentation/issues/6#issuecomment-970092576
                                                                                    //so if this problem was solved - would be appropriate for any recommedations


            Console.ReadKey();
        }
        catch (Exception ex)
        { //unreachable under docker - debug session falls
            File.WriteAllLines($"{Environment.CurrentDirectory}/err_{DateTime.Now.Ticks}.txt", new[] { ex.Message, ex.Source, ex.StackTrace });
        }
    }
}`

Try setting IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = false;
Docker issues have been largely fixed within IronPdf as of the new releases.

@IronPdf
Copy link
Owner

IronPdf commented Aug 1, 2023 via email

@IronPdf
Copy link
Owner

IronPdf commented Aug 3, 2023 via email

@IronPdf
Copy link
Owner

IronPdf commented Aug 8, 2023 via email

@IronPdf
Copy link
Owner

IronPdf commented Sep 15, 2023 via email

@IronPdf
Copy link
Owner

IronPdf commented Mar 8, 2024 via email

@IronPdf
Copy link
Owner

IronPdf commented Jun 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants