Free Support Forum - aspose.com

HTML to PDF : CSS is lost

HTMl to PDF CSS is missing:

Hi,

The requirement of our project is to convert the HTMl page to PDF with no loss of CSS.
The output PDF should look exactly same as the HTMl page.

I am using the below code which was mentioned in the url:

http://www.aspose.com/docs/display/pdfnet/How+to+convert+HTML+to+PDF+using+InLineHTML+approach


// The address of the web URL which you need to convert into PDF format
string WebUrl = "http://en.wikipedia.org/wiki/Main_Page";
// 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 text2 = new Aspose.Pdf.Generator.Text(section, localResponseStream.ReadToEnd());

// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;

// Add the text object containing HTML contents to PD Sections
section.Paragraphs.Add(text2);

// Specify the URL which serves as images database
//pdf.HtmlInfo.ImgUrl = "http://en.wikipedia.org/";
//Save the pdf document
pdf.Save(@"D:/OutputPDF Files/DirectHTML2pdf.pdf");

localWebResponse.Close();
localResponseStream.Close();

PLease see the attached output pdf file:

There is no CSS ....It looks ugly..

And Please note that below are the other forum topic links I have posted on the same CSS issue:

1)

=================================================================================

1)
Can you please look into this issue with high priority as it is almost a year since this issue got logged into your defect tracking system.


2)Please give me the exact dates..when you are planning to resolve this issue..As our clients are requesting us to resolve this issue..They cant wait any further..

3)Please suggest with any other approaches We can get this working ..no loss of css..
with any other Aspose products..

Please let me know if you need any information from my end.

Thanks,
Siddi.


====================================================================================

Hi Siddi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please accept our apologies for inconvenience you are facing.

I am able to generate your mentioned issue after an initial test using the code sample shared. The issue has been registered in our issue tracking system with issue id: PDFNEWNET-34475. You will be notified via this forum thread regarding any update.

spothuganti:
Can you please look into this issue with high priority as it is almost a year since this issue got logged into your defect tracking system.

Well, we cannot commit to a high priority resolution of any issue under normal support forum. Also, it depends on the complexity of the issue as well. However, as replied here, I will update you regarding the progress and ETA regarding your issue.

spothuganti:
Please give me the exact dates..when you are planning to resolve this issue..As our clients are requesting us to resolve this issue..They cant wait any further.

As mentioned above, as soon as I get a response from the development team, I will update you regarding the ETA.

spothuganti:
Please suggest with any other approaches We can get this working ..no loss of css.. with any other Aspose products..

Well, I am afraid there is no other approach which you can use in this regard as you have already used Aspose.Words for .NET and Aspose.Pdf for .NET separately and you are facing the issues in both the product. Both the team are looking into your issue, so please wait until your issue is rectified.

We are really sorry for the delay and inconvenience,