将绝对路径添加到 css 会导致 Gecko Engine 无法呈现页面

Adding absolute paths to css causes Gecko Engine to fail on rendering the page

我能够让 abcPDF Gecko 引擎为我的其中一个页面呈现我的 PDF,但是一旦我向我的 css <link> 元素添加绝对路径,它渲染失败。
但是,我还有其他页面能够很好地呈现 PDF,并且它们使用相同的 javascript 将绝对路径添加到 css <link> 元素。

我正在使用 javascript 动态更改每个 css 元素的 href。

//Give css files full paths
var domain = window.location.protocol + "//" + window.location.host;

html.find("link").each(function(index, item){
   var linkPath = domain + $(item).attr("href");
   $(item).attr("href", linkPath);
});

我一添加这行代码,就得到以下异常:

WebSupergoo.ABCpdf8.Doc.AddImageHtml(String html, Boolean paged, Int32 width, Boolean disableCache) +209
   WebSupergoo.ABCpdf8.Doc.AddImageHtml(String html) +64
   DocuMatix_Complete_Suite.Classes.Helpers.ConvertToPDF.ExportToPDF(String companyId, String name, String pHtmlorUrl, Boolean pIsUrl, Boolean useCohesion, EngineType engine, Orientation orientation) +530
   DocuMatixPageBase.PdfContent(String filename, String html, Boolean useCohesion, EngineType engine, Orientation orientation) +244
   DocuMatix_Complete_Suite.ReportCenter.Controllers.ReportCenterController.CreateSubscriberActivityReportPDF(SubscriberActivityReportPDFModel model, String orientation) +109
   lambda_method(Closure , ControllerBase , Object[] ) +147
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +156
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9651532
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155er code here

我还有其他页面实现了这一行 javascript/jQuery 并且该页面上的 PDF 生成完美无缺。当我研究这个时,我发现将 EngineType 设置为 MSHtml,页面会呈现但样式不正确。这似乎是 Gecko 引擎的问题。 我检查了生成的每个 css link 并确保它们都是合法的 link,它们确实是。我将 css links 与成功呈现 PDF 的页面进行了比较,这两个页面使用的是完全相同的 css links.

我不确定你需要我提供什么代码或信息来帮助我解决这个问题,但如果有人能指出正确的方向,我将不胜感激。我现在不知道去哪里了。

我找到问题所在了。

我的 table 上有一个 <tfoot>,出于某种原因,当 <tfoot><tbody> 下方时,abcPDF 不喜欢它,所以我移动了<thead> 上面的 <tfoot> 部分和我的 html 能够转换为 PDF。