none
How to embed fonts in presentation using documenformat.openxml c# RRS feed

  • Question


  • I want to embed fonts using documentformat.openxml c# in my presentation(.pptx) but i dont know how to embed.

    need help.

    Your assistance in this matter would be greatly appreciated.

    Thansk & Regards

    kamaldeep

    • Moved by CoolDadTx Monday, December 2, 2019 6:38 PM Office related
    Monday, December 2, 2019 5:22 AM

All replies

  • I have not working code example of this or did not found one, but according to documentation you can append embedded fonts to Presentation.EmbeddedFontList. Then to use embedded font you need to reference it in.

    So maybe code could be something like this, I have not tested it so might need some changes and you need to figure yourself how to use the font.

    using (PresentationDocument presentationDocument = PresentationDocument.Open("Empty.pptx", true))
    {
        PresentationPart presentationPart = presentationDocument.PresentationPart;
        Presentation presentation = presentationPart.Presentation;
        EmbeddedFont font = new EmbeddedFont();
        font.Font = new Font() 
        {
            Typeface = "Arial"
        };
        presentation.EmbeddedFontList = new EmbeddedFontList();
        presentation.EmbeddedFontList.Append(font);
        presentationDocument.Save();
    }

    Monday, December 2, 2019 8:59 AM
  •  @MasaSam, Thanks for your assistance  but i want to embed external fonts (also create file in fonts folder and create refrence in .rels) in presentation.

    kamaldeep



    Wednesday, December 4, 2019 4:27 AM