Free Support Forum - aspose.com

How to turn off update automatically option for Date time in ppt while converting to PDF

Ok thank you. Please update me once it is done.

@pradeepdone,

I suggest you to please try using following sample code on your end and share if there is any issue incurring.

public static void TestDateIssueinPDF()
{
	String path = @"C:\Aspose Data\Source_convertedFiles\";

	using (Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation(path + "Test.pptx"))
	{
		DateTime lastSavedDateTime = presentation.DocumentProperties.LastSavedTime;

		// Set "lastSavedDateTime" to all DateTime placeholders in presentation
		IPresentationHeaderFooterManager presentationHeaderFooter = presentation.HeaderFooterManager;
		presentationHeaderFooter.SetAllDateTimesVisibility(true);
		presentationHeaderFooter.SetAllDateTimesText(lastSavedDateTime.ToString());

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

			// Set "lastSavedDateTime" to slides internal DateTime portions
			SetDateTimeText(slide, lastSavedDateTime.ToString());

			if (slide.NotesSlideManager.NotesSlide != null)
			{
				// Set "lastSavedDateTime" to notes internal DateTime portions
				SetDateTimeText(slide.NotesSlideManager.NotesSlide, lastSavedDateTime.ToString());
			}
		}

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

		presentation.Save(path + "Date_ppt_Exported.pdf", Aspose.Slides.Export.SaveFormat.Pdf, pdfOptions);
	}
}

private static void SetDateTimeText(IBaseSlide baseSlide, string text)
{
	foreach (IShape shape in baseSlide.Shapes)
	{
		if (shape is Aspose.Slides.AutoShape && ((AutoShape)shape).TextFrame != null)
		{
			foreach (IParagraph para in ((AutoShape)shape).TextFrame.Paragraphs)
			{
				foreach (IPortion port in para.Portions)
				{
					if (port.Field != null && port.Field.Type.InternalString.StartsWith("datetime"))
					{
						port.RemoveField();
						port.Text = text;
					}
				}
			}
		}
	}
}

Thank you it’s working now as expected.

The issues you have found earlier (filed as SLIDESNET-40366) have been fixed in this update.