Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Sat Jul 30, 2022 3:55 pm

Hi,Support:

How to do I reach my those requirements as below using Spire.Presentation.dll based on VB.net and Net 4.6.1 and Win10:
1. Open a PPT or PPTX file
2. Get the count of the Slides in the presentation
3. Get the Width and height of the slide
4. Add a textbox at (x,y) with given width and height
5. Set the boarders of then new added textbox to none, and set the background of new added textbox to none or transparent
6. extract all the text in each slide
7. Add text into the new added textbox, and set the fontname, fontsize,fontstyle,fontcolor for the texts in the new added textbox
8. Modify the character space to squeeze the characters in the new added textbox
9. Clone the textbox and move the cloned textbox to a new position

Thanks for your help.

ducaisoft
 
Posts: 3
Joined: Sat Jul 30, 2022 2:29 pm

Mon Aug 01, 2022 10:18 am

Hello Ducai Soft,

Thanks for your message.
Please refer to the below sample code to complete your requirements, I also attached my testing files for your reference. If there is any other issues, to facilitate our further investigation, please send us your input document as well as your desired output effect. Thanks for your understanding.

Code: Select all
  'Open a PPTX file
      Dim ppt As New Presentation()
      ppt.LoadFromFile("input.pptx", FileFormat.Pptx2013)
      'Get the count of the Slides
      Dim sCount As Integer = ppt.Slides.Count
      'Get the size
      Dim sType As SlideSizeType = ppt.SlideSize.Type
      'Extract all the text in each slide
      Dim sb As New StringBuilder()
      For i As Integer = 0 To sCount - 1
        For j As Integer = 0 To ppt.Slides(i).Shapes.Count - 1
          If TypeOf ppt.Slides(i).Shapes(j) Is IAutoShape Then
            Dim shape As IAutoShape = TryCast(ppt.Slides(i).Shapes(j), IAutoShape)
            If shape.TextFrame IsNot Nothing Then
              For Each tp As TextParagraph In shape.TextFrame.Paragraphs
                sb.Append(tp.Text)
              Next tp
            End If
          End If
        Next j
      Next i
      'Add a textbox at(50,70) with (width:620 & height:150)
      Dim shape1 As IAutoShape = ppt.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 70, 620, 150))
      'Settings for borders and background
      shape1.Fill.FillType = FillFormatType.None
      shape1.ShapeStyle.LineColor.Color = Color.White
      'Add text into the new added textbox
      shape1.TextFrame.Text = sb.ToString()
      'Set the fontname, fontsize,fontstyle,fontcolor, character space
      shape1.TextFrame.Paragraphs(0).TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold")
      shape1.TextFrame.Paragraphs(0).TextRanges(0).Fill.FillType = FillFormatType.Solid
      shape1.TextFrame.Paragraphs(0).TextRanges(0).Fill.SolidColor.Color = Color.Black
      shape1.TextFrame.Paragraphs(0).TextRanges(0).FontHeight = 14
      shape1.TextFrame.Paragraphs(0).TextRanges(0).IsItalic = TriState.True
      shape1.TextFrame.Paragraphs(0).TextRanges(0).LineSpacing = 8

      'Clone the textbox to the second slide
      ppt.Slides(1).Shapes.AddShape(CType(shape1, Shape))

      'Save
      Dim result As String = "output.pptx"
      ppt.SaveToFile(result, FileFormat.Pptx2013)
      Process.Start(result)


Sincerely
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Mon Aug 01, 2022 11:38 am

Thanks for your reply.
Another issue is that the Spire.Presentation.dll will take a long time to handle ppt files. Is there any possible to speed up the handling efficiency? i.e. Hope it could handle over hundreds of ppt files per minute for it only handle tens of ppt files per minute so that it is too low efficient.

ducaisoft
 
Posts: 3
Joined: Sat Jul 30, 2022 2:29 pm

Tue Aug 02, 2022 7:56 am

Hello Ducai Soft,

Thanks for your inquiry.
As for the time performance, it mainly depends on the complexity of your documents and the processing code. If you were using an old version, I first suggest you use our latest version Spire.Presentation Pack Hotfix Version:7.7.5 and manually add the memory disposal method such as presentation.Dispose() to test again. If this still does not help, please provide us with below more information to further investigate.
1.Your test code and documentation, if they exceed the size limitation for attachment. You could upload it to the DropBox or OneDrive and then share the download link with us.
2.Your test system environment(E.g. win10,x64,RAM:16GB).

Sincerely
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Return to Spire.Presentation