Free Support Forum -

Convert HTML to PDF not respecting CSS

Hello, I am evaluating Aspose.PDF to convert in memory streams of HTML to PDF documents.

THe HTML documents are comprised of large HTML tables that I would like to fit to one page wide. However, when I try to do a simple test, it appears that Aspose is not respecting the CSS and the HTML just goes straight across the page.

I have tried experimenting with the IsFitToPage and IsLandscape properties of PDF and Text without success.

below is a sample of my C# code and attached is the HTML I am trying to convert. Also, attached is the resulting PDF document.

Pdf pdf2 = new Pdf();
Aspose.Pdf.Section section = pdf2.Sections.Add();
section.IsLandscape = true;
StreamReader r = File.OpenText(@"D:\mark\ctl3.htm");
Aspose.Pdf.Text text = new Text( r.ReadToEnd());
text.IsFitToPage = true;
text.IsHtmlTagSupported = true;
pdf2.IsLandscape = true;

Is it possible to force to Fit-To-Page one page wide or Shrink-To-Fit one page wide with Aspose.Pdf? I am trying to replicate what is possible to do with IE Print Options->Fit-To-Page or with Word or Excel Print Options Fit-To-Page. thank you ,mark

Hello Mark,

Thanks for your interest in our products.

I have tested the scenario and as per my observations, the IsFitToPage property is not working properly and also the CSS information is not being honored during HTML to PDF conversion. For the sake of correction, I have logged this problem as PDFNET-28410 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Thank you for response.

We are anxious to find a solution for this problem and would like to use Aspose.Pdf if at all possible. Please let me know if there is any assistance we can be. thank you, mark

Hello Mark,

Thanks for your interest in our products.

We will try our level best to get resolved all the issues that are occurring. However if we require any further information regarding its resolution, we will let you know. Please be patient and spare us little time. We apologize for your inconvenience.