How C # Extracts text from SmartArt text and annotations in PPT

Source: Internet
Author: User

The extraction of text is often encountered in work and study, in the previous article, has described how to extract the text in the ppt Chinese box, in this article, will explain how to use the C # code language to extract the text of SmartArt and annotations in the PPT document. Similarly, the program needs to use the free spire.ppt for. NET, before writing the code, you need to install, and add reference DLL files to the project program, but also to be added to the namespace.

1. Extracting text from a SmartArt

Original file:

650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/09/e5592c7e7e9792816ed7d2650a9e288f.png "style=" float: none; "title=" 21.png "alt=" E5592c7e7e9792816ed7d2650a9e288f.png "/>

(in slide 2 smartart

using spire.presentation.diagrams;using system.drawing;using system.text;using system.io; Using spire.presentation; namespaceextracttextfromsmartart_ppt{    classprogram     {        staticvoid main (string[]  args)         {             //Initializes an instance of the presentation class and loads the document              presentation ppt = newpresentation ();             ppt. LoadFromFile (@ "C:\Users\Administrator\Desktop\Sample.pptx");             //Create a new StringBuilder object              stringbuilder st = newstringbuilder ();            //walking through a SmartArt graphic in a document              for  (int i = 0; i <ppt. slides.count; i++)             {                 for  (int j  = 0; j <ppt. Slides[i]. shapes.count; j++)                  {                     if (ppt. Slides[i]. Shapes[j] isismartart)                      {                        ismartart smartart = ppt. Slides[i]. shapes[j] asismartart;                        for  (int k = 0; k  < smartart.nodes.count; k++)                         {                             st. Append (Smartart.nodes[k]. Textframe.text);                         }                     }                 }            }             //writing text to txt document              File.writealltext ("Result.txt",  st. ToString ());         }    }}


Examples of effects include:

650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/09/362631ddecdc0579887bd9b3db14f094.png "style=" float: none; "title=" 22.png "alt=" 362631ddecdc0579887bd9b3db14f094.png "/>


2. Extracting text from annotations


Original file:

650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/09/195746d7b43e7f699440fa1c62266cbd.png "style=" float: none; "title=" 23.png "alt=" 195746d7b43e7f699440fa1c62266cbd.png "/>

on slide 1 , a comment is inserted that contains the text content

using system;using system.text;using spire.presentation;using system.io;  namespaceextracttextfromcomment_ppt{    classprogram    {         staticvoid main (String[] args)          {            // Instantiates a Presentation class and loads the document             presentation  ppt = newpresentation ();            ppt. LoadFromFile (@ "C:\Users\Administrator\Desktop\comment.pptx");             //creating a StringBuilder object              stringbuilder str = newstringbuilder ();             //gets all the annotations in the first slide &NBSP;&NBsp;          comment[] comments =ppt. Slides[0]. comments;            //iterating through annotations              for  (int i = 0; i < Comments. length; i++)             {                str. Append (Comments[i]. text +  "\ r \ n");            }             //writing text to txt document              file.writealltext ("TextFromComment.txt",  str. ToString ());         }    }}

Examples of effects:

650) this.width=650; "src=" Https://s1.51cto.com/oss/201711/09/38321bc1893888785c2f77bcbcfece8e.png "style=" float: none; "title=" 24.png "alt=" 38321bc1893888785c2f77bcbcfece8e.png "/>


the above method is to extract PPT SmartArt and comments in the implementation of text, for reference, I hope to help you, thank you for reading!

(End of this article)


This article is from the "E-iceblue" blog, make sure to keep this source http://eiceblue.blog.51cto.com/13438008/1980186

How C # Extracts text from SmartArt text and annotations in PPT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.