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);
}
}