Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //Opens an existing PowerPoint presentation.
            Stream        file1   = new FileStream(ResolveApplicationDataPath("HeaderFooter.pptx"), FileMode.Open, FileAccess.Read, FileShare.Read);
            IPresentation pptxDoc = Presentation.Open(file1);

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in pptxDoc.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = pptxDoc.Slides[0].AddNotesSlide();

            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            //Saves Presentation with specified file name with extension.
            pptxDoc.Save("HeaderFooterSample.pptx", FormatType.Pptx, Response);
            //Closes the Presentation
            pptxDoc.Close();
        }
Exemplo n.º 2
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Assembly assembly     = typeof(GettingStartedPresentation).GetTypeInfo().Assembly;
            string   resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.HeaderFooter.pptx";
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            //Opens an existing PowerPoint presentation.
            IPresentation presentation = await Presentation.OpenAsync(fileStream);

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in presentation.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide();

            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            SavePPTX(presentation);
        }
Exemplo n.º 3
0
        public ActionResult HeaderAndFooter(string Browser)
        {
            //Opens an existing PowerPoint presentation.
            string        filename     = "HeaderFooter.pptx";
            IPresentation presentation = Presentation.Open(ResolveApplicationDataPath(filename));

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in presentation.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide();

            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            //Saves the presentation
            return(new PresentationResult(presentation, "HeaderAndFooter.pptx", HttpContext.ApplicationInstance.Response));
        }
        /// <summary>
        /// Creates a PowerPoint Presentation file with headers and footers.
        /// </summary>
        private void BtnCreatePresn_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
        {
            //Gets the input PowerPoint Presentation file.
            Assembly assembly     = typeof(HeaderAndFooter).GetTypeInfo().Assembly;
            string   resourcePath = "syncfusion.presentationdemos.winui.Assets.Presentation.HeaderFooter.pptx";

            using Stream fileStream = assembly.GetManifestResourceStream(resourcePath);
            //Opens an existing PowerPoint Presentation file.
            using IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);
            //Adds footers into all the PowerPoint slides.
            foreach (ISlide slide in presentation.Slides)
            {
                //Enables a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enables a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enables a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Adds header into first slide notes page.
            //Adds a notes slide to the slide.
            INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide();

            //Enables a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Syncfusion PowerPoint Library";

            //Saves the presentation to the memory stream.
            using MemoryStream stream = new();
            if (presentationdoc.IsChecked == true)
            {
                presentation.Save(stream);
                stream.Position = 0;
                //Saves the memory stream as file.
                SaveAndLaunch.Save("HeaderFooter.pptx", stream);
            }
            else
            {
                //Converts the PowerPoint Presentation to PDF document.
                using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation))
                {
                    //Saves the converted PDF document to MemoryStream.
                    pdfDocument.Save(stream);
                    stream.Position = 0;
                }
                //Saves the memory stream as file.
                SaveAndLaunch.Save("HeaderFooter.pdf", stream);
            }
        }
Exemplo n.º 5
0
        private void btnCreatePresn_Click(object sender, EventArgs e)
        {
            string input = @"..\..\..\..\..\..\Common\Data\Presentation\HeaderFooter.pptx";

#if NETCore
            input = @"..\..\..\..\..\..\..\Common\Data\Presentation\HeaderFooter.pptx";
#endif

            //Opens an existing PowerPoint presentation.
            IPresentation pptxDoc = Presentation.Open(input);

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in pptxDoc.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = pptxDoc.Slides[0].AddNotesSlide();
            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            //Saves Presentation with specified file name with extension.
            pptxDoc.Save("HeaderFooterSample.pptx");

            if (System.Windows.MessageBox.Show("Do you want to view the generated Presentation?", "Presentation Created",
                                               MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
#if !NETCore
                System.Diagnostics.Process.Start("HeaderFooterSample.pptx");
#else
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo("HeaderFooterSample.pptx")
                {
                    UseShellExecute = true
                };
                process.Start();
#endif
                this.Close();
            }
        }
        public static void Run()
        {
            //ExStart:HeaderAndFooterInNotesSlide
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_Notes();

            using (Presentation presentation = new Presentation(dataDir + "presentation.pptx"))
            {
                // Change Header and Footer settings for notes master and all notes slides
                IMasterNotesSlide masterNotesSlide = presentation.MasterNotesSlideManager.MasterNotesSlide;
                if (masterNotesSlide != null)
                {
                    IMasterNotesSlideHeaderFooterManager headerFooterManager = masterNotesSlide.HeaderFooterManager;

                    headerFooterManager.SetHeaderAndChildHeadersVisibility(true);                     // make the master notes slide and all child Footer placeholders visible
                    headerFooterManager.SetFooterAndChildFootersVisibility(true);                     // make the master notes slide and all child Header placeholders visible
                    headerFooterManager.SetSlideNumberAndChildSlideNumbersVisibility(true);           // make the master notes slide and all child SlideNumber placeholders visible
                    headerFooterManager.SetDateTimeAndChildDateTimesVisibility(true);                 // make the master notes slide and all child Date and time placeholders visible

                    headerFooterManager.SetHeaderAndChildHeadersText("Header text");                  // set text to master notes slide and all child Header placeholders
                    headerFooterManager.SetFooterAndChildFootersText("Footer text");                  // set text to master notes slide and all child Footer placeholders
                    headerFooterManager.SetDateTimeAndChildDateTimesText("Date and time text");       // set text to master notes slide and all child Date and time placeholders
                }

                // Change Header and Footer settings for first notes slide only
                INotesSlide notesSlide = presentation.Slides[0].NotesSlideManager.NotesSlide;
                if (notesSlide != null)
                {
                    INotesSlideHeaderFooterManager headerFooterManager = notesSlide.HeaderFooterManager;
                    if (!headerFooterManager.IsHeaderVisible)
                    {
                        headerFooterManager.SetHeaderVisibility(true);                         // make this notes slide Header placeholder visible
                    }
                    if (!headerFooterManager.IsFooterVisible)
                    {
                        headerFooterManager.SetFooterVisibility(true);                         // make this notes slide Footer placeholder visible
                    }
                    if (!headerFooterManager.IsSlideNumberVisible)
                    {
                        headerFooterManager.SetSlideNumberVisibility(true);                         // make this notes slide SlideNumber placeholder visible
                    }
                    if (!headerFooterManager.IsDateTimeVisible)
                    {
                        headerFooterManager.SetDateTimeVisibility(true);                      // make this notes slide Date-time placeholder visible
                    }
                    headerFooterManager.SetHeaderText("New header text");                     // set text to notes slide Header placeholder
                    headerFooterManager.SetFooterText("New footer text");                     // set text to notes slide Footer placeholder
                    headerFooterManager.SetDateTimeText("New date and time text");            // set text to notes slide Date-time placeholder
                }
                presentation.Save(dataDir + "testresult.pptx", SaveFormat.Pptx);
            }
        }
Exemplo n.º 7
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string resourcePath = "";

#if COMMONSB
            resourcePath = "SampleBrowser.Samples.Presentation.Samples.Templates.HeaderFooter.pptx";
#else
            resourcePath = "SampleBrowser.Presentation.Samples.Templates.HeaderFooter.pptx";
#endif
            Assembly assembly   = typeof(WriteProtection).GetTypeInfo().Assembly;
            Stream   fileStream = assembly.GetManifestResourceStream(resourcePath);

            //Open a existing PowerPoint presentation
            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in presentation.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide();
            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (Device.RuntimePlatform == Device.UWP)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("HeaderFooterSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("HeaderFooterSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
        }
        public ActionResult HeaderAndFooter(string Browser)
        {
            //Opens the presentation document as stream
            string        basePath        = _hostingEnvironment.WebRootPath;
            FileStream    fileStreamInput = new FileStream(basePath + @"/Presentation/HeaderFooter.pptx", FileMode.Open, FileAccess.Read);
            IPresentation presentation    = Presentation.Open(fileStreamInput);

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in presentation.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide();

            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            MemoryStream ms = new MemoryStream();

            //Saves the presentation to the memory stream.
            presentation.Save(ms);
            //Set the position of the stream to beginning.
            ms.Position = 0;

            //Initialize the file stream to download the presentation.
            FileStreamResult fileStreamResult = new FileStreamResult(ms, "application/vnd.openxmlformats-officedocument.presentationml.presentation");

            //Set the file name.
            fileStreamResult.FileDownloadName = "HeaderFooter.pptx";

            return(fileStreamResult);
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.HeaderFooter.pptx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            //Create an instance for PowerPoint
            IPresentation presentation = Presentation.Open(fileStream);

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in presentation.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide();

            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            MemoryStream stream = new MemoryStream();

            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;

            if (stream != null)
            {
                SaveiOS iOSSave = new SaveiOS();
                iOSSave.Save("HeaderFooterPresentation.pptx", "application/mspowerpoint", stream);
            }
        }
Exemplo n.º 10
0
        private void SlideWithNotes1(IPresentation presentation)
        {
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = (IShape)slide1.Shapes[0];

            shape1.Left   = 1.27 * 72;
            shape1.Top    = 0.56 * 72;
            shape1.Width  = 9.55 * 72;
            shape1.Height = 5.4 * 72;

            ITextBody   textFrame  = shape1.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;

            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];

            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextParts textParts = paragraph.TextParts;

            textParts.Add();
            ITextPart textPart = textParts[0];

            textPart.Text          = "Essential Presentation ";
            textPart.Font.CapsType = TextCapsType.All;
            textPart.Font.FontName = "Calibri Light (Headings)";
            textPart.Font.FontSize = 80;
            textPart.Font.Color    = ColorObject.Black;

            //Adding Notes
            INotesSlide notesSlide    = slide1.AddNotesSlide();
            ITextPart   notesTextPart = notesSlide.NotesTextBody.Paragraphs[0].TextParts.Add();

            notesTextPart.Text = "The slide represents the title content of the presentation";

            IPresentationChart chart = notesSlide.Shapes.AddChart(1.24 * 72, 5.71 * 72, 5 * 72, 3.33 * 72);


            //Specifies the chart title

            chart.ChartTitle = "Sales Analysis";

            //Sets chart data - Row1

            chart.ChartData.SetValue(1, 2, "Jan");

            chart.ChartData.SetValue(1, 3, "Feb");

            chart.ChartData.SetValue(1, 4, "March");

            //Sets chart data - Row2

            chart.ChartData.SetValue(2, 1, 2010);

            chart.ChartData.SetValue(2, 2, 60);

            chart.ChartData.SetValue(2, 3, 70);

            chart.ChartData.SetValue(2, 4, 80);

            //Sets chart data - Row3

            chart.ChartData.SetValue(3, 1, 2011);

            chart.ChartData.SetValue(3, 2, 80);

            chart.ChartData.SetValue(3, 3, 70);

            chart.ChartData.SetValue(3, 4, 60);

            //Sets chart data - Row4

            chart.ChartData.SetValue(4, 1, 2012);

            chart.ChartData.SetValue(4, 2, 60);

            chart.ChartData.SetValue(4, 3, 70);

            chart.ChartData.SetValue(4, 4, 80);

            //Creates a new chart series with the name

            IOfficeChartSerie serieJan = chart.Series.Add("Jan");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieJan.Values = chart.ChartData[2, 2, 4, 2];

            //Creates a new chart series with the name

            IOfficeChartSerie serieFeb = chart.Series.Add("Feb");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieFeb.Values = chart.ChartData[2, 3, 4, 3];

            //Creates a new chart series with the name

            IOfficeChartSerie serieMarch = chart.Series.Add("March");

            //Sets the data range of chart series – start row, start column, end row, end column

            serieMarch.Values = chart.ChartData[2, 4, 4, 4];

            //Sets the data range of the category axis

            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];

            //Specifies the chart type

            chart.ChartType = OfficeChartType.Column_Clustered;

            chart.ChartTitle = "Chart inside Notes section";
        }