As the subject says, I’m having issues using HtmlInfo.ExternalResourcesBasePath for CSS links. The value I’m applying to that property is working when I apply it to HtmlInfo.ImgUrl.
So, imagine the following:
var basePath = “[http://domain](http://domain/)”;
var pdf = new Pdf {
HtmlInfo = {
ImgUrl = basePath,
ExternalResourcesBasePath = basePath,
}
};
var section = pdf.Sections.Add();
var text = new Text(section, htmlString) {
IsHtmlTagSupported = true,
IsHtml5Supported = true // tried with and without this
};
section.Paragraphs.Add(text);
The HTML I’m using to create the PDF has the following element in the tag:
…and the following element in the tag:
When I create a PDF, the image is properly found and loaded, but the CSS is NOT applied. If I view the page itself in a browser (without converting it to a PDF), the CSS IS applied.
I should also note that I’ve tried stripping “bootstrap.css” down to a couple simple styles to make sure something unsupported wasn’t breaking the use of the stylesheet, and it still didn’t work.
Am I missing something? Any direction or help would be greatly appreciated!
EDIT: I wrote this based on suggestions found on this page
Thanks for your inquiry. Please use new DOM approach for HTML to PDF conversion, pass basepath for image/css files to HtmlLoadOptions constructor as suggested in following documentation link. It will help you to accomplish the task.
Following the code example on that link: when I new up an HtmlLoadOptions() object, and attempt to set "UseNewConversionEngine" to "true", intellisense tells me that property is obsolete.
Is that code sample out of date, or is that still valid?
We are sorry for the inconvenience caused. Please ignore engine setting property. By default Aspose.Pdf.Document namespace uses new engine, It is depreciated now. We will update documentation very soon.
You may either consider following the steps give over following link to Update Page Dimensions. So you can use this approach before calling Document.Save(…) method.