In case you still face any kind of issues, please share minimal sample code snippet with us so that we can try to replicate the issue in our environment and address it accordingly.
// Area where we create html data-----------------------
string html = string.Format(@"table style='width:100%;padding-left:5px;padding-right:5px;'> tr>td style='{2}'>{0}/td>/tr>
tr>td> /td>/tr>
tr>td >{1}/td>/tr>
</table"
, title
, subTableHtml
, this.Level1TitleCss
, this.CellBorderCss);
html = ASRExportHelper.PP_STYLE + html;
// Area where we create html data-----------------------
---------Area where the html is bing to builder-------------
builder.InsertHtml(section.HtmlContent);
pdf saving --------------------------
Document doc = new Document(tempPath);
DocumentBuilder builder = new DocumentBuilder(doc);
doc.Save(path, Aspose.Words.SaveFormat.Pdf);
@mayurih Could you please attach your problematic input HTML, temporary and problematic output documents here for testing? We will check the issue and provide you more information.
@mayurih Yes, with your template the problem is reproducible. As a workaround, you can load your HTML into a separate document and then insert this document instead of HTML string. Please see the following code:
Document doc = new Document(@"C:\Temp\in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
Document htmlDoc = new Document(@"C:\Temp\in.html");
builder.InsertDocument(htmlDoc, ImportFormatMode.KeepSourceFormatting);
doc.Save(@"C:\Temp\out.pdf");
@mayurih In the above code AutoFitBehavior.FixedColumnWidths was suggested not AutoFitBehavior.AutoFitToWindow. Please try using AutoFitBehavior.FixedColumnWidths.
it worked, but is there any way not to write content in html file as this may lead to creation of file on server and for each user we might need to create new.
string html = File.ReadAllText(@"C:\Temp\in.html");
Document htmlDoc;
using (MemoryStream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html)))
htmlDoc = new Document(htmlStream);