Techgeekster Techgeekster - 3 months ago 31
CSS Question

abcPDF and MVC - Adding absolute paths to css causes Gecko Engine to fail on rendering the page

I'm am able to get the abcPDF Gecko Engine to render my PDF for one of my pages, but as soon as as I add absolute paths to my css

<link>
elements, it fails to render.

However, I have other pages that are able to render PDFs just fine and they are using the same javascript to add absolute paths to the css
<link>
elements.

I'm using javascript to dynamically change the hrefs of each of my css elements.

//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);
});


As soon as I add this line of code, I get the following exception:

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


I have other pages that I implement this line of javascript/jQuery and the PDF on that page gets generated flawlessly. When I researched this, I discovered that setting the
EngineType
to
MSHtml
, the page would render but the styling was incorrect. This seems to be a problem with the Gecko engine.
I went through each css link that was generated and made sure they were all legitimate links, and they were. I compared the css links to my page that is successfully rendering the PDF, and the two pages are using the exact same css links.

I'm not sure what code or information you need me to give you to help me figure this out, but if someone could point me in the right direction, the help would be greatly appreciated. I'm at a loss as to where to go now.

Thanks!

Answer

I found what the problem was.

I had a <tfoot> on my table, and for some reason, abcPDF doesn't like it when the <tfoot> is underneath <tbody>, so I moved the <tfoot> section above <thead> and my html was able to be converted into a PDF.