Free Support Forum - aspose.com

[.Net] Modifing Handouts header

To update the existing content I guess you can use the same code and ich just overrides the existing content. That´s what IU would assume but I neither have tried right now or am the Aspose support so they may can explain you further questions :roll_eyes: .

We use the following code to convert to PDF:

                    var options = new PdfOptions
                    {
                        DrawSlidesFrame = true,
                        ShowHiddenSlides = false,
                        JpegQuality = 100,
                    };
                    options.NotesCommentsLayouting.CommentsPosition = CommentsPositions.None;
                    options.NotesCommentsLayouting.NotesPosition = NotesPositions.BottomFull;
                    Presentation.Save(dstFile, SaveFormat.Pdf, options);

Now i am able to update the datetime in the Handouts headers but have couple of more queries in this.

  1. How do we do the same if the content in the slide has date time and need to update it.
  2. After converting to PDF i cant see the date that is inserted in the notes

Below is the code i use and attaching the source and converted pdfSource.zip (130.7 KB)

using (Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation(“D:\Convert\Test.pptx”))
{
// presentation.UpdateDateTimeFields = false;
DateTime lastSavedDateTime = presentation.DocumentProperties.LastSavedTime;
IPresentationHeaderFooterManager presentationHeaderFooter = presentation.HeaderFooterManager;
presentationHeaderFooter.SetAllDateTimesText(lastSavedDateTime.ToString());

            foreach (var notes in presentation.Slides.Select(slide => slide.NotesSlideManager.NotesSlide))
            {
                if(notes != null)
                notes.HeaderFooterManager.SetDateTimeText(lastSavedDateTime.ToString());                    
            }        

            foreach (ISlide slide in presentation.Slides)
            {
                if ((slide.Hidden))
                {
                    slide.Hidden = false;
                }




                IShapeCollection sc = slide.Shapes;
            int count = sc.Count;
            bool fieldremoveflag = false;

                for (int i = 0; i<count; i++)
                {
                    
                    IShape shape;
                    if (fieldremoveflag)
                    {
                        count = count - 1;
                        i = i - 1;
                        shape = sc[i];
                        fieldremoveflag = false;
                    }
                    else
                    {
                        shape = sc[i];
                    }

                    if (shape.Placeholder != null
                        && !(shape is Aspose.Slides.PictureFrame)
                        && !(shape is Aspose.Slides.SmartArt.SmartArt))
                    {
                        IPlaceholder pc = ((AutoShape)shape).Placeholder;

                           if (((AutoShape) shape).TextFrame != null)
                            {
                                foreach (IParagraph para in ((AutoShape) shape).TextFrame.Paragraphs)
                                {
                                    foreach (IPortion port in para.Portions)
                                    {
                                        if (port.Field != null)
                                        {

                                        if (port.Field.Type.InternalString.StartsWith("datetime"))
                                          //  if (port.Field.Type.InternalString.Contains("datetime"))
                                            {
                                            //((AutoShape)shape).ShapeLock.SelectLocked = false;
                                            //  sc.Remove(shape);

                                           // port.Text = lastSavedDateTime.ToString();
                                            fieldremoveflag = true;

                                            }
                                        }

                                    }
                                }
                            }
                       // }
                    }
                }
            }



          

            PdfOptions pdfOptions = new PdfOptions();
            pdfOptions.DrawSlidesFrame = false;
            pdfOptions.NotesCommentsLayouting.NotesPosition = NotesPositions.BottomTruncated;
            pdfOptions.NotesCommentsLayouting.CommentsPosition = CommentsPositions.Right;

            presentation.Save("D:\\Convert\\Date_ppt.pdf", Aspose.Slides.Export.SaveFormat.Pdf, pdfOptions);                


        }

@pradeepdone,

I suggest you to please visit following thread link for your convenience.