Free Support Forum -

Use AddGlyphs with XpsFont in Aspose.Page for .NET

How to add text to XPS using this method?
I don’t need to use same method with System.Drawing.FontStyle.
In documentation I can’t find any example of using AddGlyphs with XpsFont.


We are preparing a code sample for you and will get back to you shortly.


Please check following code snippet:

        public void Test()
            XpsDocument doc = new XpsDocument();
            // Example 1
            XpsFont font1 = doc.CreateFont("Arial", System.Drawing.FontStyle.Italic);
            XpsGlyphs glyphs1 = doc.AddGlyphs(font1, 25, 100f, 100f, "Arial italic");
            glyphs1.Fill = doc.CreateSolidColorBrush(System.Drawing.Color.Red);

            // Example 2
            XpsFont font2 = glyphs1.Font;
            XpsGlyphs glyphs2 = doc.AddGlyphs(font2, 45, 100f, 200f, "Arial italic too");
            glyphs2.Fill = doc.CreateSolidColorBrush(System.Drawing.Color.Blue);