Questa breve guida descrive come estrarre testo da PowerPoint usando C#. Include details for configuring the IDE, a list of steps, and sample code to develop a PowerPoint text converter using C#. Imparerai ad accedere a vari contenuti nella presentazione/diapositive per estrarre il testo.
Steps to convert PowerPoint to text using C#
- Set up the environment to use Aspose.Slides for .NET to convert PPTX to TXT.
- Open the PPTX file in memory using the Presentation class, using the defined input file path.
- Call the SlideUtil.GetAllTextFrames() method to extract all text boxes from each slide.
- Imposta il flag per estrarre i riquadri di testo dalle diapositive master e layout, anche
- Declare the StringBuilder object to hold the extracted text content.
- Analyze each text frame and access its paragraphs.
- Iterate through each paragraph and add its text parts on new lines in the StringBuilder.
- Write the final accumulated text to a TXT file on the disk.
Questi passaggi spiegano lo sviluppo del convertitore PPTX in testo usando C#. Load the presentation, get the collection of all text boxes, create a StringBuilder object, and iterate through each box in the collection. For each box, access the collection of paragraphs, and for each paragraph get the collection of portions, retrieve the text from the portion, and add it to the StringBuilder object.
Codice per convertire PPTX in TXT usando C#
This code demonstrates how to extract text from PPTX using C#. There is another quick way to retrieve the text of the entire presentation using PresentationFactory.Instance. Il metodo GetPresentationText(inputPath, TextExtractionArrangingMode(Unarranged) writes the content of each slide to an output file encoded in UTF-8. Verranno scritti quattro componenti di testo per ogni diapositiva, includendo il testo principale del corpo, le note del relatore, il testo del master slide e il testo del layout.
This article taught us how to extract all the text from a presentation. Per convertire un PowerPoint in video MP4, consulta l’articolo Converti PowerPoint in video usando C#.