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

Free Support Forum - aspose.com

Pptx vs ppt

I am evaluting Slides with the hope of automatically creating ppt's (or pptx's). It would appear that your pptx support is immature. Creating an entire new set of objects (all the pptx Ex objects) to replace the ones you used for ppt is not a good solution. That means we all have to create two different code sets to handle ppt and pptx.

In particular, a PlaceHolderEx can not be typed as a TextHolder although (based on your documentation) a PlaceHolder can. There does not appear to be a TextHolderEx.

Let me know if I am seeing this wrong.

Thanks

Hi Brad,

Thanks for your interest in Aspose.Slides.

Your judgment is correct as we provide different set of classes to handle PPT and PPTX files. That is, classes in Aspose.Slides namespace handle PPT format and classes in Aspose.Slides.Pptx namespace handle PPTX format.

What I can understand, your comments about PlaceHolder and TextHolder are with respect to Replacing Text on PlaceHolder topic from Aspose.Slides documentation. In fact, there is a different way to modify text in a PlaceHolder for PPTX files. You can identify a PlaceHolder in PPTX using ShapeEx.IsTextHolder property. Following code example shows how to find place holders on a slide and change text in those place holders.

PresentationEx pres = new PresentationEx("myPlaceholder.pptx");

SlideEx sld = pres.Slides[0];

foreach (ShapeEx shp in sld.Shapes)

if (shp.IsTextHolder)

((AutoShapeEx)shp).TextFrame.Text = "New Text by Aspose";

pres.Write("myPlaceholder_New.pptx");

Hope this will help you.

Best Regards

Hi Muhammad,

Long time since this last post. We have ordered aspose Total, but it takes a long time to get through our purchasing dept.

I have ultimately used some PlaceHolderExs. I am able to do the text as shown in your post.

One minor problem, we put alternate text on the PlaceHolderEx in the layout page, but it does not get to the page where I want to substitute the text; I thus can't find the PlaceHolderEx by its AlternateText.

I will have multiple PlaceHolderExs on some LayoutPages and would like to be able to find them. How can one do that?

Thanks for all your help.

Hi Brad,

I have tried to reproduce the issue specified by you and I have been successfully able to access the Alternative Text property. Actually, the alternative text property is applied on the shape level. I have modified the part of code section shared in above post to make thing work for you. I have also shared the sample presentation for your kind reference.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

if (shp.IsTextHolder && shp.AlternativeText=="title")

((AutoShapeEx)shp).TextFrame.Text = "New Text by Aspose";

else if(shp.IsTextHolder && shp.AlternativeText=="body")

((AutoShapeEx)shp).TextFrame.Text = "Body Text";

Thanks and Regards,

Hi Mudassir,

I have investigated farther into the problem. I added two PlaceHolderExs to a LayoutSlideEx. I then created a SlideEx using that layout. I then looked at the shapes both on the layout and on the slide:

Protected Sub FindPlaceHolder(ByVal oSlide As SlideEx)

Dim oShape As ShapeEx

For Each oShape In oSlide.Shapes

If oShape.IsTextHolder Then

Trace.Warn("Slide AltText = " + oShape.AlternativeText + " Name = " + oShape.Name)

Else

Trace.Warn("Not a placeholder = " + oShape.AlternativeText + " Name = " + oShape.Name)

End If

Next

For Each oShape In oSlide.LayoutSlide.Shapes

If oShape.IsTextHolder Then

Trace.Warn("Layout AltText = " + oShape.AlternativeText + " Name = " + oShape.Name)

Else

Trace.Warn("Layout Not a placeholder = " + oShape.AlternativeText + " Name = " + oShape.Name)

End If

Next

End Sub

The results were:

Slide AltText = Name = Text Placeholder 3

Slide AltText = Name = Text Placeholder 4

Layout AltText = ArtTitle Name = Text Placeholder 4

Layout AltText = LessonDescription Name = Text Placeholder 6

In other words, the AlternateText exists on the layout slide, but is not transferred to the slide. Unfortunately, the shape Name does not remain the same either. How do I determine which PlaceHolder is which on the Slide side? It would be very nice if the AlternateText was copied to the slide with the placeholder!

Hi Mudassir,

Another issue has arisen. I attempted to create a new slide using AddEmptySlide with a LayoutSlideEx as an argument. I assumed that the placeholders from the LayoutSlideEx (and its MasterSlideEx) would be represented on the new empty slide; they were not. When I run the code in the previous post, I see no Slide output, only the placeholder on the LayoutSlideEx.

Brad

Hi Brad,

You are very right in pointing the issue that if you add placeholders in some layout slide and add alternative text to those placeholders. After this generating a slide and applying that generated layout will not have alternative text property with placeholders that were set in respective layout placeholders. This all has been done on PowerPoint end so far and it is not a bug in Aspose.Slides. So, when you execute your code, you get null string from alternative text property. I have used your code snippet and have modified that to work in a way that you will be able to read the alternative text property of placeholder in Layout slide the text will be added in the respective placeholder of normal slide. You have also mentioned that adding an empty slide by selecting any layout slide always generates and empty slide. Actually, this feature has not yet been added for PPTX in Aspose.Slides. If you want to add text frames in empty slide then please use auto shapes or clone the slide that has placeholders inside it.

Public Sub FindPlaceHolder(Byref pred as PresentationEx)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Dim oSlide As SlideEx = pred.Slides(0)

Dim oShapeLayout As ShapeEx

Dim oShape As ShapeEx

Dim aShp As AutoShapeEx

For Each oShape In oSlide.Shapes

If oShape.IsTextHolder Then

For Each oShapeLayout In oSlide.LayoutSlide.Shapes

If oShapeLayout.IsTextHolder And oShapeLayout.AlternativeText = "TitleLayout" And oShapeLayout.X = oShape.X And oShapeLayout.Y = oShape.Y Then

aShp = oShape

aShp.TextFrame.Text = "Title Text"

ElseIf oShapeLayout.IsTextHolder And oShapeLayout.AlternativeText = "BodyLayout" And oShapeLayout.X = oShape.X And oShapeLayout.Y = oShape.Y Then

aShp = oShape

aShp.TextFrame.Text = "Body Text"

End If

Next

Else

Trace.Write("Not a placeholder = " + oShape.AlternativeText + " Name = " + oShape.Name + "\n")

End If

Next

pred.Write("D:\\Test.pptx")

End Sub

Thanks and Regards,

Hi Mudassir,

Good workaround for the missing AltText on the slide. I will implement a utility for that.

You mentioned:

You have also mentioned that adding an empty slide by selecting any layout slide always generates an empty slide. Actually, this feature has not yet been added for PPTX in Aspose.Slides. If you want to add text frames in empty slide then please use auto shapes or clone the slide that has placeholders inside it.

I think I am missing something fundamental here. The one page that had the placeholders copied onto the slide was created in PP. PP itself did not keep the AltText. (Your workaround would fix that).

I am attaching a PPTx file. We are trying to use this as a master for many PPTxs. We would like, for example, to use aspose to create a slide within this PPTx which would use the TemplateJPGArt Layout. We would then, from a database, fill in the Title in the Placeholder from the MasterArtSlides master page, fill in an art number in the placeholder from the master, have the page number from the master, and add a jpg into the placeholder from the TemplateJPGArt layout.

Are we going about this the wrong way? Seems like it should be the most straightforward way. I can't even get a slide created which has those four items on it!

Any help is appreciated.

Hi Brad,

As I have mentioned earlier, that creating slides from layout slides is not yet available.There are two approaches here. First, you create a slide in using Aspose.Slides by creating Autoshapes to server as placeholder. You can then clone the slide inside presentation to generate other slides but with differen data. Second approach would be to generate different template slides of desired layout in PowerPoint. Then access the presentation using Aspose.Slides and clone the slides with desired layout in your presentation using the workaround code shared in my previous post.

Thanks and Regards,

Hi Mudassir,

I have previously used your second option. That worked well. It presented a problem (and, I thought, an opportunity) when we wanted to clone a complete external pptx page into the destination pptx. This required that the cloning worked with a layout slide in the target presentation (which you have pointed out does not work yet). Anyway...

Is it possible for me to create objects in the target slide from placeholders in the target layout or master slides? Seems like that is what you would do to create this functionality.

Brad

Hi Mudassir,

I have mostly done what I mentioned in the previous post. Have copied the PlaceHolders from the Master and Layout slides onto the Slide. Then filled in the text:

Protected Sub FillArtTitle(ByVal oSlide As SlideEx, ByVal sTitle As String)

Dim oText As TextFrameEx

oText = CType(oSlide.FindShapeByAltText("ArtTitle"), AutoShapeEx).TextFrame

oText.Paragraphs(0).Portions(0).Text = sTitle

oText.Paragraphs(0).Portions(0).FillFormat.SolidFillColor.Color = Drawing.Color.Black

oText.AnchoringType = TextAnchorTypeEx.Bottom

End Sub

Only problem is, the text is white instead of black! Any idea why that next to last line of code is not making the text black? The text does get the correct Title on each page.

Brad

Dear Brad,

I regret to inform you that I am unable to completely understand the issue specified by you in your previous post. Can you please share some more details about the issue.

Thanks and Regards,

Hi Mudassir,

Is there a way to set information for specific placeholders like Title, Footer, etc. without having to copy a shape to the current slide?

Previous post - I found placeholders on the layout or master pages and created shapes like them on the current slide. The new shapes with text fields worked on the slide except that the text color remains white.

Hi Brad,

Can you please share the complete code snippet and the presentation file where by you are experiencing. In my perception you are copying a placeholder or text frame from the layout slide into the source slide. If it is so, then I am afraid that the formatting property is getting reset. The better way is to clone the slide. As i suggested you earlier that please create your custom layout slides in PowerPoint and then generate normal slides based on generated custom layout slides. Then use those normal slides by cloning them in your source presentation. I hope this way you will not encounter any issue. But please also share your working presentation and code snippet as well, once the mentioned technique does not prove fruitful for you. Can you please share that what type of information you need to set for a specific placeholder. There is no other way to add that in the text holder of the placeholder.

Thanks and Regards,

Hi Mudassir,

I have taken your advice and returned to the original technique which uses a separate lesson template. I currently am getting errors when copying the title and document number; will try to fix that myself.

I also notice that there are many extraneous master and layout slides. I tried to remove them using Masters.Remove; they did not get removed. I then looked in the documentation and noticed that there are some other functions (RemoveUnused in particular) that do not show up in Visual Studio.

I am still using Slides 4.1.0. How does one upgrade? I downloaded Slides 4.2.0 but couldn't get it loaded into VS. Should I download the Total package (I also have Pdf and Words in my project)?

Dear Brad,

You are right in making your point that RemoveUnused masters property is unavailable in Aspose.Slides for .NET 4.1.0. However, it is available in latest release of Aspose.Slides for .NET. The online documentation always refers to the latest available version. You can download the latest version of Aspose.Slides individually. But, you may please need to remove the old reference to Aspose.Slides.dll in your project and then add the reference to the Aspose.Slides.dll corresponding to version 4.2.0. Please share your problem in detail, if it still persists.

Thanks and Regards,

Hi Mudassir,

We have received our license and I have downloaded the latest .Net Total package. I have Slides 4.2.0 along with all the other latest packages.

I am attaching two files to this note. One is the template (LessonTemplate.pptx), the other the output of the aspose process (CreatePPTx.pptx). The output pages are made by cloning template pages 4, 5, or 6, inserting info, then copying the fields from template page 3 and filling in their text. The last two pages of the output are made by cloning external individual pptx pages and then copying the fields from template page 3 and filling in their text.

I would not be copying the fields from template page 3 and filling in their text except for the fact that we clone those individual pptx pages.

Anyway, when I do copy and fill in those fields you will notice that they end up blue with white text and I cannot find a way to make them go transparent with black text. I have tried various fill properties in the middle of this routine...

Protected Sub CopyArtTitleEtc(ByVal oSlide As SlideEx, ByVal oTemplateSlide As SlideEx)

Dim oParagraph As ParagraphEx

Dim oPortion As PortionEx

Dim oAutoShape As AutoShapeEx

Dim oNewShape As AutoShapeEx

Dim iShape As Integer

Trace.Warn("Title temp shapes = " + oTemplateSlide.Shapes.Count.ToString())

For Each oAutoShape In oTemplateSlide.Shapes

If ControlUtilities.StringIsNotEmpty(oAutoShape.AlternativeText) Then

Trace.Warn(" Alt Text = " + oAutoShape.AlternativeText)

iShape = oSlide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, oAutoShape.X, oAutoShape.Y, oAutoShape.Width, oAutoShape.Height)

oNewShape = oSlide.Shapes(iShape)

PPTx.copyTextFrame(oNewShape, oAutoShape)

For Each oParagraph In oNewShape.TextFrame.Paragraphs

For Each oPortion In oParagraph.Portions

Next

Next

oNewShape.AlternativeText = oAutoShape.AlternativeText

End If

Next

End Sub

...but all tries have failed.

Any idea what I need to do there?

This was the last bug until I loaded 4.2.0, then another popped up which I have put in another post.

Thanks for any help.

Hi Mudassir,

I have solved the problem. Turns out the colors were coming from the rectangle, not the text field. I have changed the routine that copies the fields to the output presentation to:

Protected Sub CopyArtTitleEtc(ByVal oSlide As SlideEx, ByVal oTemplateSlide As SlideEx)

Dim oAutoShape As AutoShapeEx

Dim oNewShape As AutoShapeEx

Dim iShape As Integer

For Each oAutoShape In oTemplateSlide.Shapes

If ControlUtilities.StringIsNotEmpty(oAutoShape.AlternativeText) Then

iShape = oSlide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, oAutoShape.X, oAutoShape.Y, oAutoShape.Width, oAutoShape.Height)

oNewShape = oSlide.Shapes(iShape)

PPTx.copyTextFrame(oNewShape, oAutoShape)

oNewShape.FillFormat.FillType = FillTypeEx.NoFill

oNewShape.LineFormat.FillFormat.FillType = FillTypeEx.NoFill

oNewShape.TextFrame.Paragraphs(0).Portions(0).FillFormat.FillType = FillTypeEx.Solid

oNewShape.TextFrame.Paragraphs(0).Portions(0).FillFormat.SolidFillColor.Color = Drawing.Color.Black

oNewShape.AlternativeText = oAutoShape.AlternativeText

End If

Next

End Sub

The part that is indented changes the fill color and line color of the rectangle and then changes the text color in the text field.

For anyone interested in this solution, this is the copyTextFrame used in the above routine:

Public Shared Sub copyTextFrame(ByVal oDest As AutoShapeEx, ByVal oSour As AutoShapeEx)

Dim oTextDest As TextFrameEx

Dim oTextSour As TextFrameEx

Dim oParaDest As ParagraphEx

Dim oParaSour As ParagraphEx

Dim oPortDest As PortionEx

Dim oPortSour As PortionEx

oDest.FillFormat.FillType = oSour.FillFormat.FillType

oDest.LineFormat.FillFormat.FillType = oSour.LineFormat.FillFormat.FillType

oTextSour = oSour.TextFrame

oTextDest = oDest.TextFrame

oTextDest.Paragraphs.Clear()

For Each oParaSour In oTextSour.Paragraphs

oParaDest = New ParagraphEx(oParaSour)

oParaDest.Portions.Clear()

For Each oPortSour In oParaSour.Portions

oPortDest = New PortionEx(oPortSour)

oParaDest.Portions.Add(oPortDest)

Next

oParaDest.RawAlignment = oParaSour.RawAlignment

oTextDest.Paragraphs.Add(oParaDest)

Next

End Sub

Anyway, this problem is solved.

Thanks for all your help.

Brad

Dear Brad,

We are thankful to you for sharing the commonly used routine as it will be helpful for other customers visiting the thread. We appreciate your positive interest towards using our product.

Thanks and Regards,