We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text information when converting pptx to PDF/PNG

Hello Aspose,

I am trying to convert ms PowerPoint files to PDF/PNG on the environment Docker + Linux (Ubuntu 18.04.5 LTS).
Regarding PDF files, characters in texts often overlap.
Regarding PNG files, text corruption happens.

Could you teach me how to resolve these phenomena?
I wrote down the script below.
As for the input file, it takes much time to prepare for you because of a certain reason.

String filepath = args[0];

String filename = Path.GetFileName(args[0]);

// Make directories

Directory.CreateDirectory(args[1] + "/" + filename);

String txt_outpath = args[1] + "/" + filename + "/" + "txt";

String png_outpath = args[1] + "/" + filename + "/" + "png";

Directory.CreateDirectory(txt_outpath);

Directory.CreateDirectory(png_outpath);       

// load the presentation file

Presentation presentation = new Presentation(filepath);

String[] loadFonts = new String[] { "../data/Fonts_windows/" };

// Load the custom font directory fonts

FontsLoader.LoadExternalFonts(loadFonts);

// Save the entire file as PDF

presentation.Save(args[1] + "/" + filename +"/"+ "result_pptx.pdf", Aspose.Slides.Export.SaveFormat.Pdf);

              
for (int j = 0; j < presentation.Slides.Count; j++)

{

    var sld = presentation.Slides[j];

    // create a full scale image of the slide

    var bmp = sld.GetThumbnail(1f, 1f);

    bmp.Save(png_outpath +"/"+ $"output_{j + 1}.png", System.Drawing.Imaging.ImageFormat.Png);

    //Get an Array of TextFrameEx objects from the first slide

    ITextFrame[] textFramesSlideOne = SlideUtil.GetAllTextBoxes(sld);

    //Loop through the Array of TextFrames

    for (int i = 0; i < textFramesSlideOne.Length; i++)

        //Loop through paragraphs in current TextFrame

        foreach (Aspose.Slides.Paragraph para in textFramesSlideOne[i].Paragraphs)

            //Loop through portions in the current Paragraph

            foreach (Portion port in para.Portions)

            {
                //Save text in the current portion
                File.AppendAllText(txt_outpath +"/"+ $"output{j + 1}.txt", port.Text + Environment.NewLine);              
            }
}

@shun1985

These issues are incurring owing to missing or inaccessible fonts that have been used in your presentation. You need to make sure if the fonts used in your presentations are available on your machine or not.