We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML To Pdf not rendering properly

Dear Aspose,

Please find attached my html file and pdf file. I am using below Aspose code to convert my html into pdf.
var htmlMemoryStream = new MemoryStream();
            using (var streamWriter = new StreamWriter(htmlMemoryStream))
htmlMemoryStream.Seek(0, SeekOrigin.Begin);
            <span style="color:green;">//create an instance of LoadOptions and set the LoadFormat to Mhtml</span>
            <span style="color:blue;">var</span> loadOptions = <span style="color:blue;">new</span> <span style="color:#2b91af;">LoadOptions</span> { LoadFormat = <span style="color:#2b91af;">LoadFormat</span>.Mhtml };

            <span style="color:green;">//create an instance of Document and load the MTHML from MemoryStream</span>
            <span style="color:blue;">var</span> document = <span style="color:blue;">new</span> <span style="color:#2b91af;">Document</span>(htmlMemoryStream, loadOptions);
            <span style="color:blue;">foreach</span> (Aspose.Words.<span style="color:#2b91af;">Section</span> section <span style="color:blue;">in</span> document.Sections)
                section.PageSetup.PaperSize = <span style="color:#2b91af;">PaperSize</span>.A4;

            <span style="color:green;">//create an instance of HtmlSaveOptions and set the SaveFormat to Html</span>
            <span style="color:blue;">var</span> saveOptions = <span style="color:blue;">new</span> <span style="color:#2b91af;">PdfSaveOptions</span>();

            <span style="color:blue;">var</span> targetLocationMemoryStream = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>();
            document.Save(targetLocationMemoryStream, saveOptions);

            <span style="color:green;">//save the document to Html file</span>
            _impersonatedFile.SaveFileToDestination(converterSettings.OutputFileLocation, targetLocationMemoryStream.ToArray());
        }</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">The problem is the Side bold heading are not rendering properly even though I set my custom font in the body tag. </pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Previously I was using Pechkin to convert this html to pdf. During that time it was rendering properly without any issues.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">I thought of evaluating this with Aspose. Aspose is not rendering the side heading properly. They were going into new lines. If you go to</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">page no 2 at the Meeting Status has came into two lines. Previously with Pechkin I have not faced this problem.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">So just for your testing sake I am sending my html file as well. First open that in browser then you will see how I am expecting my output,</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">and see the attached pdf file how it is rendered using Aspose.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><u><b>Note:</b></u></pre><pre style="font-family: Consolas; font-size: 13px; background: white;">I have tried to convert the ics file to pdf by following this link.</pre><pre style="background: white;"><font face="Consolas"><b>http://www.aspose.com/community/forums/615396/icalendar-to-pdf/showthread.aspx</b></font></pre><pre style="background: white;"><font face="Consolas">But the result became worst. I did not got a single event in my converted pdf.</font></pre><pre style="background: white;"><font face="Consolas">So I used Nustache and DDay.Ical to generate html and then using Aspose to convert the html to pdf.</font></pre><pre style="background: white;"><font face="Consolas">Thanks & Regards,</font></pre><pre style="background: white;"><font face="Consolas">N.Murali Krishna.</font></pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><br></pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><br></pre></div>

Hi N.Murali,

Thanks for your inquiry. Please note that Aspose.Words requires TrueType fonts when
rendering documents to fixed-page formats (JPEG, PDF or XPS). Make sure
you have all the Fonts installed on your machine you’re using to convert
Word document to Pdf format e.g Helvetica font. I would suggest you please read the
following articles:

I have tested the scenario and have noticed that the first column of table has font Helvetica (10.5). The font size is changed in output document. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-12004. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,

May I know Approximate time estimation to fix this issue.

Thanks & Regards,
N.Murali Krishna.

Hi N.Murali Krishna,

for your inquiry. I would like to
share with you that issues
are addressed and resolved based on first come first serve
basis. Currently, your issue is pending for analysis and is in the
queue. I am afraid, we can’t provide you any reliable estimate at the
moment. Once your issue is analyzed, we will then be able to provide you
an estimate.

Thanks for your patience and understanding.

Why you are mentioniong WORDSNET-12004 as Not a Bug. When there is a problem, try to fix it.

"The only way to escape from a problem is to solve it."

Thanks & Regards,
N.Murali Krishna.

Hi N.Murali,

Thanks for your inquiry. The WORDSNET-12004 (Font size of text is changed after conversion from Html to Docx/Pdf) is actually not a bug in
Aspose.Words. So, we have closed this issue as ‘Not a
Bug’. I am quoting product team comments here for your reference.

According to the HTML 5 Standard, the font size of the first column should be 12pt (the default font size), because the HTML document is opened in Quirks mode and there is a quirk related to font size of tables (please see a note about Quirks mode in http://www.w3.org/TR/html5/rendering.html#tables). All modern browsers also render the text of the first column in 12pt but MS Word apparently doesn’t conform to HTML 5 and ignores the quirk.

There is a way to instruct Aspose.Words and modern browsers to ignore that quirk and use inherited font size (10.5pt) for tables. The customer should add the following declaration to the beginning of the HTML document (before the tag):

<!doctype html>

Regarding the word wrap problem, it seems to be related not to the font size but to the lack of support for column width declared using elements. In the input html document, the following declarations are used to set widths of table columns:

We have logged this issue as WORDSNET-12020. We will inform you via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-12020) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.