-
Notifications
You must be signed in to change notification settings - Fork 120
Open
Description
I created a PDF that contains links to other locations in the PDF, using this in the razor view
<a class="menuItem" href="#ruleskey">Rules</a>
which links to
<a name="ruleskey"> </a>
However in the ViewAsPdf.cs there is this code
string baseUrl = string.Format("{0}://{1}", context.HttpContext.Request.Scheme, context.HttpContext.Request.Host);
var htmlForWkhtml = Regex.Replace(html.ToString(), "<head>", string.Format("<head><base href=\"{0}\" />", baseUrl), RegexOptions.IgnoreCase);
byte[] fileContent = WkhtmltopdfDriver.ConvertHtml(this.WkhtmlPath, this.GetConvertOptions(), htmlForWkhtml);
Which sets a base href, this causes the links to not work, the only way I can get links to work is to
//string baseUrl = string.Format("{0}://{1}", context.HttpContext.Request.Scheme, context.HttpContext.Request.Host);
var htmlForWkhtml = html.ToString();
byte[] fileContent = WkhtmltopdfDriver.ConvertHtml(this.WkhtmlPath, this.GetConvertOptions(), htmlForWkhtml);
I guess the Base Url is there for image resources and the like, I have inlined my images as base64, which is why I probably dont have any other issues once I remove it.
Question is, is there a correct way to do clickable links to other locations in a PDF? OR can the addition of the BaseUrl be made configurable if its not needed?
Metadata
Metadata
Assignees
Labels
No labels