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

Free Support Forum - aspose.com

Getting Extra line break on converting HTML to PDF


When we are converting HTML to PDF we notice extra line breaks in converted PDF. When we open HTML is MS word we don’t get extra line breaks.

Below is the code which we are using

using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(File.ReadAllText(@“C:\Users\msingh02\Desktop\IssueFile.html”))))
Aspose.Words.Document docw = new Aspose.Words.Document(memoryStream, new LoadOptions(LoadFormat.Html, null, null));
foreach (Aspose.Words.Section sec in docw.Sections)
Aspose.Words.PageSetup ps = sec.PageSetup;
// 1 inch equals 72 points
ps.TopMargin = 0;
ps.RightMargin = 0;
ps.BottomMargin = 0;
ps.LeftMargin = 0;
ps.PageWidth = Aspose.Pdf.Generator.PageSize.A4Width;
ps.PageHeight = Aspose.Pdf.Generator.PageSize.A4Height;


Please find html file as attachment.Aspose Line break issue.zip (287.4 KB)

Mukesh Singh


Thanks for your inquiry. We have tested your HTML document using the latest version of Aspose.Words 18.11 and found no issue. Please upgrade to the latest version of Aspose.Words.

Please check document for your reference.mskccIssue_18.11.zip (130.1 KB)