Hi, I am trying to save a word (docx) to pdf after the relevant formfields and bookmarks have been generated. When the output is set to docx the correct font is used.
However when the output is set to pdf the correct font is no longer used.
Document doc = new Document();
doc = new Document("wwwroot/Documents/Example.docx");
doc.Styles[StyleIdentifier.Normal].Font.Style.Name = "Montserrat";
DocumentBuilder builder = new DocumentBuilder(doc);
That is how the template is first loaded, you can see I have set the doc.styles to the font I wish to use.
Then when outputting it looks like this
var outputStream = new MemoryStream();
if (wordOutput)
{
doc.Save(outputStream, SaveFormat.Docx);
outputStream.Position = 0;
result = File(outputStream, System.Net.Mime.MediaTypeNames.Application.Rtf, Number + "_Report_" + Guid.NewGuid().ToString().Replace("-", "") + ".docx");
}
else
{
Aspose.Words.Saving.SaveOptions options = Aspose.Words.Saving.PdfSaveOptions.CreateSaveOptions(SaveFormat.Pdf);
options.UpdateFields = true;
doc.Save(outputStream, options);
outputStream.Position = 0;
result = File(outputStream, System.Net.Mime.MediaTypeNames.Application.Pdf, Number + "_Report_" + Guid.NewGuid().ToString().Replace("-", "") + ".pdf");
}
Can you see why the font might be getting ignored when outputting as PDF?
would it be caused by the font not being available on the server etc if so is there a way I can reference it in the template code to avoid having to install it on the server?
Thanks