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
366 stars 66 forks source link

% in the href attribute are still encoded to %25 #109

Closed Welloprim closed 1 year ago

Welloprim commented 1 year ago

Hello,

When I generate a pdf from HTML and use an anchor tag that contains a %. The href keeps encoding the % as %25.

For example, when I put the cursor on the link :

Here my code :

using(FileStream fs = new FileStream(tempFile, FileMode.OpenOrCreate)) { byte[] info = new UTF8Encoding(true).GetBytes(model.Header); fs.Write(info, 0, info.Length); var doc = new HtmlToPdfDocument() { GlobalSettings = { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4Plus, DPI = 300, Margins = new MarginSettings() { Top = 40, Left = 10, Right = 10 }, }, Objects = { new ObjectSettings() { PagesCount = true, HtmlContent = model.Html, WebSettings = { DefaultEncoding = "utf-8" }, FooterSettings = { FontSize = 9, Left = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss"), Right = "Page [page] of [toPage]", Spacing = 2.812 }, HeaderSettings = { HtmlUrl = tempFile, Spacing = 10 }, }, }, }; pdf = _converter.Convert(doc); return pdf;

When debugging the link remains unchanged (not encoded) then after the step pdf = _converter.Convert(doc); I have no visibility because it is a byte[]. Having no workaround at the moment, can I have some help from you, please?

HakanL commented 1 year ago

This project is just a wrapper around the native wkhtmltopdf library. Maybe if you test the library directly using command line to see if the issue is in there.

Welloprim commented 1 year ago

Indeed, the problem is present in the native library. Thank you for your reactivity