Hi,
I have string builder with table output as follows
Main Table 3 days, 9 hours, 15 minutes
Child Table 3 days, 9 hours, 15 minutes
Now,I want to convert to PDF . So I tried using following code snippet
var resultHtml = sbOutput.ToString();
var scenarioExportPDF = new Document();
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(resultHtml);
//scenarioExportPDF.BindXML(xmlDoc, null);
Here bindxml is expecting string file but not xmlDoc.
Please help me.
Hi Avinash,
Thanks for your inquiry. You may convert StringBuilder to PDF as follows; hopefully, it will help you accomplish the task. If there is any difference in your requirements and my understanding, please share some more details.
Document pdf = new Document();
StringBuilder stringBuilder = new StringBuilder("<table border=\"1\"><tr><td>Main Table </td><td>3 days, 9 hours, 15 minutes</td></tr><tr><td><table border=\"1\"><tr><td>Child Table</td><td>3 days, 9 hours, 15 minutes</td></tr></td></tr></table></td></tr></table>");
Aspose.Pdf.Page page = pdf.Pages.Add();
HtmlFragment html = new HtmlFragment(stringBuilder.ToString());
page.Paragraphs.Add(html);
pdf.Save("StringBuildertoPdf.pdf");
Please feel free to contact us for any further assistance.
Best Regards,