Save Html document to Pdf format with incorrect indentation

I’m using Aspose.Words to convert an html file (zipped and attached) into a Pdf file but the last pages display the text as one character per line, it seems the indentation is incorrectly converted.

I’m using the following code as a test:

var filename = @"C:\PathHere\htmlcopy.htm";
var htmlLoadFormat = new Aspose.Words.LoadOptions { LoadFormat = Aspose.Words.LoadFormat.Html };
var doc = new Aspose.Words.Document(filename, htmlLoadFormat);
var pdf = @"C:\PathHere\pdfcopy.pdf";
var options = new Aspose.Words.Saving.PdfSaveOptions();
doc.Save(pdf, options);

Please Help. Thank you.

Hi John,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you load your html in MS Word and convert it to Pdf, you will get the same output.

You can proportionally reduce left and right indents for all paragraphs in document before saving document to Pdf to get the required output. Please check following code example. Hope this helps you.

LoadOptions options = new LoadOptions();
options.LoadFormat = LoadFormat.Html;
Document doc = new Document(MyDir + "htmlcopy.htm", options);
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    para.ParagraphFormat.LeftIndent /= 4;
    para.ParagraphFormat.RightIndent /= 4;
}
doc.Save(MyDir + "Out.pdf");