I built a console application that create MS Word letter and PDF from HTML code stored in a database using the Aspose.Words.net library.
I am setting the font to Myriad Pro (OpenType) . When the Aspose.word.net renders the MS Word Document the font is correct, But when it renders the PDF I get a differnt font called MicrosoftSansSerif. How do i get the PDF to render with the Myriad Pro font.
I use a variable called strLetterFont that contain a string with the font name . Example "Myriad Pro"
private static Document doc;
private static DocumentBuilder builder;
private static Paragraph paragraph;
private static Section currentSection;
private static PageSetup pageSetup;
doc = new Document();
doc.RemoveAllChildren();
builder = new DocumentBuilder(doc);
paragraph = builder.CurrentParagraph;
currentSection = builder.CurrentSection;
pageSetup = currentSection.PageSetup;
currentSection.PageSetup.PaperSize = PaperSize.Letter;
currentSection.PageSetup.TopMargin = 36;
currentSection.PageSetup.BottomMargin = 36;
currentSection.PageSetup.LeftMargin = 72;
currentSection.PageSetup.RightMargin = 72;
Aspose.Words.Font font = builder.Font;
font.Name = strLetterFont;
I will then loop trough the database use the DocumentBuilder
to insert the HTML into the Document, I also set the font
again in the builder.
builder.Font.Name = strLetterFont;
builder.Font.Size = 12;
builder.InsertHtml(strbuilder.ToString());
I am using SaveDoc menthod to save both documents after building up a document with the document builder.
SaveDoc(doc, outputFolder + strEXT_SRVY_ID + ".pdf", SaveFormat.Pdf);
SaveDoc(doc, outputFolder + strEXT_SRVY_ID + ".docx", SaveFormat.Docx);