Greetings Aspose support and community,
Please see the following code… we are trying to simply get a page to save as a PDF document, however when we try to reference stylesheets it is as if they were never referenced. We get the same result when we do not have any css references. Thanks for your help. An example output is attached.
// The address of the web URL which you need to convert into PDF format
string WebUrl = @"https://sitefinity.dmainc.com/about-us/";
// create a Web Request object to connect to remote URL
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(WebUrl);
// set the Web Request timeout
request.Timeout = 10000; // 10 secs
// Retrieve request info headers
HttpWebResponse localWebResponse = (HttpWebResponse)request.GetResponse();
// Windows default Code Page (Include System.Text namespace in project)
Encoding encoding = Encoding.GetEncoding(1252);
// Read the contents of into StreamReader object
StreamReader localResponseStream = new StreamReader(localWebResponse.GetResponseStream(), encoding);
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(section, localResponseStream.ReadToEnd());
// enable the property to display HTML contents within their own formatting
text.IsHtmlTagSupported = true;
// Add the text object containing HTML contents to PD Sections
section.Paragraphs.Add(text);
pdf.HtmlInfo.ExternalResourcesBasePath = @"https://sitefinity.dmainc.com/css/";
//Save the pdf document
pdf.Save("C:/Test/DirectHTML2pdf.pdf