How to convert embedded HTML code from string into plain string.
In XSL, we can use “<xsl:value-of select=“Value” disable-output-escaping=“yes”/>”
similar logic and properties to change into plain string with proper formatting and styling.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
// Specify the left margin info for the PDF file
doc.PageInfo.Margin.Left = 40;
// Specify the Right margin info for the PDF file
doc.PageInfo.Margin.Right = 40;
Aspose.Pdf.Page page = doc.Pages.Add();
string s = “Header”;
HtmlFragment heading_text = new HtmlFragment(s);
page.Paragraphs.Add(heading_text);
FloatingBox box = new FloatingBox();
// Add four columns in the section
box.ColumnInfo.ColumnCount = 2;
// Set the spacing between the columns
box.ColumnInfo.ColumnSpacing = "5";
box.ColumnInfo.ColumnWidths = "250 250";
TextFragment text1 = new TextFragment(@"embedded html like <p>,<strong><lt>");
text1.TextState.FontSize = 8;
text1.TextState.LineSpacing = 4;
box.Paragraphs.Add(text1);
text1.TextState.FontSize = 10;
text1.TextState.FontStyle = FontStyles.Italic;
// Create a graphs object to draw a line
Aspose.Pdf.Drawing.Graph graph2 = new Aspose.Pdf.Drawing.Graph(200, 10);
// Specify the coordinates for the line
float[] posArr2 = new float[] { 1, 10, 100, 10 };
Aspose.Pdf.Drawing.Line l2 = new Aspose.Pdf.Drawing.Line(posArr2);
graph2.Shapes.Add(l2);
// Add the line to paragraphs collection of section object
box.Paragraphs.Add(graph2);
HtmlFragment text2 = new HtmlFragment(html);
box.Paragraphs.Add(text2);
page.Paragraphs.Add(box);
TextFragment text12 = new TextFragment(lt.value);
page.Paragraphs.Add(text12);
string xmlpath1 = xmlpath + "CreateMultiColumnPdf_19.1.pdf";
var ms1 = new MemoryStream();
doc.Save(ms1, SaveFormat.Pdf);
foreach (Aspose.Pdf.Page p in doc.Pages)
{
p.Header = new HeaderFooter();
p.Header.Margin = marginInfo(5f, 5f, 0f, 0f);
p.Header.Paragraphs.Add("header");
p.Footer = new HeaderFooter();
p.Footer.Margin = marginInfo(5f, 5f, 0f, 0f);
p.Footer.Paragraphs.Add("footer");
}
// Save PDF file
doc.Save(xmlpath1);
Please suggest on this…Thanks in advance.