Exclude powerpoint animation from pdf

We have a WPF application that uses Syncfusion to create PowerPoint presentations. These presentations contain a lot of charts and graphs. The client has requested a feature as follows:
1. Ability to click on a graph and view additional textual information that pops up in a textbox

2. The popup should disappear when user clicks on it

3. When the presentation is saved to pdf, this additional textual information should be excluded

I have implemented features 1 and 2 by using animations to create a shape that pops up with the textual information. However, I am struggling to figure out how to exclude the textual information from showing up when we export the presentation to pdf. For context, the client exports these PowerPoints to pdf by using the "save as" feature in PowerPoint application and selecting "save as type" as PDF.

I've attached my sample application that includes the animation that I wrote.


Attachment: CreateStubs_4059cbf9.zip


3 Replies

AA Akash Arul Syncfusion Team August 31, 2023 01:22 PM UTC

Hi Rajib,

On further analyzation, we found that before you save it as PDF the popups should be hidden or removed. The shapes or elements that are visible in Microsoft PowerPoint application will be preserved in the converted PDF. There is no direct approach to exclude the particular shape or elements in PDF conversion.

To achieve your requirement, you can try the below suggestions.

1. You can set the particular name (“Popup message”) for your shapes and save it as PPTX.

Open the saved Presentation in the Microsoft PowerPoint application. After opening it in an application you can hide or delete the shape based on their name.

To hide or delete the name in Microsoft PowerPoint application follow the below steps

Home -> Arrange -> Selection Pane


Once clicking the selection pane, you can differentiate the shapes named Popup message in it. Either you can click and remove that or hide it. Now you can save it as PDF.

2. You can set the particular name (“Popup message”) for your shapes. You can also convert the PPTX document into PDF using Presentation library.
To know more about Presentation to PDF conversion, please refer below UG documentation
https://help.syncfusion.com/file-formats/presentation/presentation-to-pdf

Before converting the PPTX document to PDF, you can iterate the document and find the shapes in that particular name (“Popup message”) and either hide or remove it.

//Loads or open a PowerPoint Presentation

IPresentation pptxDoc = Presentation.Open(input);

//Iterates through shapes in a slide and sets title

foreach (IShape shape in pptxDoc.Slides[0].Shapes)

            {

                if (shape is IShape && shape.ShapeName == "Popup message")

                    shape.Hidden = true;

            }

After that you can convert the PPTX document to PDF.

We have modified the sample by implementing a method HidePopupAndSaveAsPDF for the above purpose.

Please refer the sample.

Note: Please find the input Presentation document and output PDF inside the zip file. 

Regards,
Akash.


Attachment: CreateStubs_modified_a317627c.zip


RM Rajib Miah August 31, 2023 05:37 PM UTC

Hi Akash,

Thank you for your valuable suggestions. Unfortunately suggestion #1 will not work for us since there are over 50 slides in the actual presentation, and we will have hundreds of such pop ups that will need to be hidden. We cannot expect the end user to manually hide that many elements.

Approach #2 might work for us, with a slight change in user workflow. Currently, the end users are manually creating the pdfs from the PowerPoint presentation. With this approach, we will be creating the pdfs for them at the same time that the PowerPoint is created using Syncfusion. We will investigate this further. 

We also found a third approach and I'll leave that here in case anyone has the same use case in the future. We can write macros in PowerPoint using VBA script that when executed will iterate through all the slides, delete the shapes that we do not want, and save the file as pdf. We will need to start with a base PowerPoint template that already has the macro embedded in it. 


Sub SaveAsPdf()

    RemoveStubs

    Dim pptName As String

    Dim PDFName As String


    ' Save PowerPoint as PDF

    pptName = ActivePresentation.FullName

    ' Replace PowerPoint file extension in the name to PDF

    PDFName = Left(pptName, InStr(pptName, ".")) & "pdf"

    ActivePresentation.ExportAsFixedFormat PDFName, 2 ' ppFixedFormatTypePDF = 2

End Sub


Sub RemoveStubs()

    Dim currentSlide As Slide

    Dim shp As Shape


    For Each currentSlide In ActivePresentation.Slides

      For Each shp In currentSlide.Shapes

        If Left(shp.Name, 4) = "stub" Then shp.Delete

      Next shp

    Next currentSlide

End Sub




JS Jayashree Suresh Anand Syncfusion Team September 1, 2023 09:02 AM UTC

Hi Rajib,

We are glad that the second approach will work for you, and we appreciate your suggested approach, please revert us back if you have any concerns or in need of further assistance. 

Regards,

Jayashree 


Loader.
Up arrow icon