iText7 pdfHTML c# doesn't respect baseuri on linux/unix systems

Viewed 759

Hi currently i am evaluating IText7 and i finding really amazing but i came up to a bug i believe. Using latest version pdfHTML 2.1.1 in .net core 2.2 setting the baseUri in order to access locally css and images works fine in windows but not on linux/mac.

private byte[] PdfGenerator(string html)
    {
        ConverterProperties converterProperties = new ConverterProperties();
        var basepath = Path.Combine(AppContext.BaseDirectory,"asset");
        _logger.LogDebug($"Base path is :" +basepath);
        converterProperties.SetBaseUri(basepath);
        using (var memStream = new MemoryStream())
        {
            HtmlConverter.ConvertToPdf(html, memStream, converterProperties);
            return memStream.ToArray();
        }
    }

Although in my running directory the asset folder exists with files underneath (css,images) I get 2 different results for windows and mac

I link css in my html like this

<link rel="stylesheet" type="text/css" href="css/style.css">

Windows

enter image description here

Mac

enter image description here

The value of basepath is

Mac /Users/gpapadak/Code/In.Backend/src/In.Report.Api/bin/Debug/netcoreapp2.2/asset Windows I:\_github\In.Backend\src\In.Report.Api\bin\Debug\netcoreapp2.2\asset

Linux /repositories/publish/asset

Any help or workaround?

0 Answers
Related