Fonts Are Not Loading Properly in PPTX to HTML Conversion in C#

I have used below code to convert ppt to html but still fonts are not loading properly

using (Presentation pres = new Presentation("input.pptx"))
{
    // Excludes default presentation fonts
    string[] fontNameExcludeList = { "Calibri", "Arial" };

    EmbedAllFontsHtmlController embedFontsController = new EmbedAllFontsHtmlController(fontNameExcludeList);

    HtmlOptions htmlOptionsEmbed = new HtmlOptions
    {
        HtmlFormatter = HtmlFormatter.CreateCustomFormatter(embedFontsController)
    };

    pres.Save("input-PFDinDisplayPro-Regular-installed.html", SaveFormat.Html, htmlOptionsEmbed);
}

@mrunal.a.deshmukh,
Thank you for contacting support.

We are sorry that you had to encounter this problem. We need more details to investigate the case and help you. Please share the following files and information:

  • input presentation file
  • output HTML file
  • screenshot with the problem you described
  • OS version on which the conversion was performed
  • .NET target platform in your application project
  • Aspose.Slides version you used

I have embedded fonts in input ppt, so 80% issue got resolved. But in conversion i am getting SVG images. I need structure in div span tag format and png images

@mrunal.a.deshmukh,
Could you kindly share a sample presentation to reproduce the problem on our end?

Please find the attached file input and output file.
Below are the issues:
1.Fonts are not loading properly
2.Also images are in svg format.
Test_Font_Output.zip (367.9 KB)

@mrunal.a.deshmukh,
Thank you for the sample files.

I’ve reproduced the problem you described. The problem means that the fonts used in the presentation are not present on the operating system on which the conversion was performed. You should install the Aptos fonts on the OS or load them as external fonts as follows:

FontsLoader.LoadExternalFonts(new string[] { "path_to_your_fonts" });

Custom PowerPoint Font in C#|Aspose.Slides Documentation

We have opened the following new ticket(s) in our internal issue tracking system and will consider implementing the feature according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-44628

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

where i need to put this line?It would be good if you could provide me entire logic.

FontsLoader.LoadExternalFonts(new string[] { “path_to_your_fonts” });

@Mrunal07,
Thank you for the question. This code line should be placed before loading a presentation.

@mrunal.a.deshmukh,
Our developers have investigated the case and your requirements.

  1. The provided presentation does not contain any SVG or other images. The image of the earth and the human figure are PowerPoint Shape objects and are therefore treated as Shapes. When exporting to HTML, they are saved as geometric paths, like any other figure, using the tag as shown here: rightImage.png (66.2 KB).
  2. The following code can be used to address your problem, specifically the need to save custom shapes in PNG format. This code replaces custom shapes with PNG images right before converting the presentation to HTML:
    // Open the presentation file
    using (Presentation presentation = new Presentation("Test_Font.pptx"))
    {
        // Iterate through each slide in the presentation
        foreach (ISlide slide in presentation.Slides)
        {
            // Iterate through each shape on the slide
            for (int i = 0; i < slide.Shapes.Count; i++)
            {
                IShape shape = slide.Shapes[i];

                // Check if the shape is an AutoShape and has a custom shape type (a user-defined vector object)
                if (shape is IAutoShape && ((AutoShape)shape).ShapeType == ShapeType.Custom)
                {
                    // Save the current position and size of the shape
                    float x = shape.X;           // X coordinate of the shape
                    float y = shape.Y;           // Y coordinate of the shape
                    float width = shape.Width;   // Width of the shape
                    float height = shape.Height; // Height of the shape

                    // Generate an image (bitmap) from the shape with its appearance and 1:1 scaling
                    using (IImage shapeImage = shape.GetImage(ShapeThumbnailBounds.Appearance, 1f, 1f))
                    {
                        // Remove the original vector shape from the slide
                        slide.Shapes.Remove(shape);

                        // Add the image (PNG) to the presentation's image collection
                        IPPImage image = presentation.Images.AddImage(shapeImage);

                        // Replace the removed shape with a picture frame that contains the image
                        // The picture frame is positioned at the original coordinates of the shape
                        slide.Shapes.AddPictureFrame(ShapeType.Rectangle, x, y, width, height, image);

                        // Decrement the loop counter since the shape was removed to prevent skipping the next shape
                        i--;
                    }
                }
            }
        }

        // Save the modified presentation to an HTML file
        presentation.Save("output.html", SaveFormat.Html);
    }