[HttpPost]
public async Task<IActionResult> TstEmbed()
{
WordDocument doc = new WordDocument();
WParagraphStyle style = doc.AddParagraphStyle("Tradition") as WParagraphStyle;
style.CharacterFormat.FontName = "TraditionSansXLight";
style.CharacterFormat.FontSize = 11f;
WParagraphStyle styleBalt = doc.AddParagraphStyle("Balthazar") as WParagraphStyle;
styleBalt.CharacterFormat.FontName = "Balthazar";
styleBalt.CharacterFormat.FontSize = 11f;
WParagraphStyle styleArial = doc.AddParagraphStyle("Arial") as WParagraphStyle;
styleArial.CharacterFormat.FontName = "Arial";
styleArial.CharacterFormat.FontSize = 11f;
IWSection section = doc.AddSection();
IWParagraph par = section.AddParagraph();
par.ApplyStyle("Tradition");
par.AppendText("This is written in Tradition Sans XLight");
IWParagraph parAr = section.AddParagraph();
parAr.ApplyStyle("Arial");
parAr.AppendText("This is written in Arial");
IWParagraph parBal = section.AddParagraph();
parBal.ApplyStyle("Balthazar");
parBal.AppendText("This is written in Balthazar");
DocIORenderer render = new DocIORenderer();
render.Settings.EmbedFonts = true;
render.Settings.EmbedCompleteFonts = true;
PdfDocument pdf = render.ConvertToPDF(doc);
render.Dispose();
MemoryStream ms = new MemoryStream();
pdf.Save(ms);
ms.Position = 0;
pdf.Close();
string contentType = "application/pdf";
return File(ms, contentType, "123.pdf");
}