HakanL / WkHtmlToPdf-DotNet

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
GNU Lesser General Public License v3.0
372 stars 67 forks source link

The HtmUrl in HeaderSettings and FooterSettings not work #73

Closed sean-tj closed 2 years ago

sean-tj commented 2 years ago

I set the HtmUrl in the HeaderSettings and FooterSettings as below, but it doesn't work.

var converter = new SynchronizedConverter(new PdfTools());

var globalSettings = new GlobalSettings
{
    ColorMode = ColorMode.Color,
    Orientation = Orientation.Portrait,
    PaperSize = PaperKind.A4,
    UseCompression = true,
    Margins = new MarginSettings()
    {
        Unit = Unit.Centimeters,
        Top = 6.5,
        Bottom = 2.5,
        Left = 2.3,
        Right = 2.3
    }
};

var headerSettings = new HeaderSettings()
{
    HtmUrl = headerUrl
};

var footerSettings = new FooterSettings()
{
    HtmUrl = footerUrl
};

var doc = new HtmlToPdfDocument()
{
    GlobalSettings = globalSettings,
    Objects = {
        new ObjectSettings() {
            PagesCount = true,
            HtmlContent =  input,
            HeaderSettings = headerSettings,
            FooterSettings= footerSettings
        }
    }
};
HakanL commented 2 years ago

I noticed they are misspelled; I have fixed that in the new build, but that's not the cause of the issue since it gets set correctly in the native library. Best is probably to test it in the native library, my guess is that the library has restrictions on what URLs it can access, I've never tested the URL feature.

ra-one commented 2 years ago

@sean-tj what does footerUrl point to, i have HtmlUrl = "/path/to/file.html" and it works perfectly fine. (even with misspelled one)