Sign In  Sign Up Live-Chat

Copy Slide Notes with Slides

Last post 05-08-2008, 1:49 PM by msfaiz. 6 replies.
Sort Posts: Previous Next
  •  06-22-2007, 8:27 AM 81503

    Copy Slide Notes with Slides

    Hi,

    I am using cloneslides to import slides from one presentation to another. Is it possible to import the slide notes as well as the slide content?

    Regards

    Alan

     
  •  06-22-2007, 10:23 AM 81516 in reply to 81503

    Re: Copy Slide Notes with Slides

    Dear Alan,

     

    CloneSlide method clones the full slide along with its all contents. For slide’s notes, you will have to write the code to import notes of cloned slide.

     

    For it, you can use Slide.Notes property and Slide.Notes.Paragraphs


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  06-22-2007, 10:58 AM 81524 in reply to 81516

    Re: Copy Slide Notes with Slides

    Hi,

    Do you have an example of some code to do this? Any help would be very appreciated.

    Regards

    Alan

     
  •  06-22-2007, 1:02 PM 81537 in reply to 81524

    Re: Copy Slide Notes with Slides

    Attachment: Present (inaccessible)

    Dear Alan,

     

    The code below clone slides as well as its notes. The method takes three parameters as input, one is source presentation, the slide number to be cloned and destination presentation.

     

    It then not only clones the source slide from source presentation into the destination presentation but also copies its notes.

     

    I have attached the source presentation, code and resulting output presentation.

    Imports System

    Imports System.IO

    Imports System.Collections.Generic

    Imports System.Collections

    Imports System.Text

    Imports System.Drawing

    Imports System.Drawing.Imaging

    Imports Aspose.Slides

     

    Module PPTPractice

    Sub Main()

    Dim srcPres As Presentation

    srcPres = New Presentation("c:\srcPres.ppt")

    Dim dstPres As Presentation

    dstPres = New Presentation()

    CloneSlideWithNotes(srcPres, 1, dstPres)

    dstPres.Write("c:\dstPres.ppt")

    End Sub

     

    Sub CloneSlideWithNotes(ByVal srcPres As Presentation, ByVal srcSlidePosition As Integer, _

    ByVal dstPres As Presentation)

    Dim srcSld As Slide

    srcSld = srcPres.GetSlideByPosition(srcSlidePosition)

    If srcSld Is Nothing Then

    Exit Sub

    End If

    Dim dstSldPosition As Integer

    dstSldPosition = dstPres.Slides.LastSlidePosition + 1

    'Clone slide now, we have all the necessary parameters

    Dim dstSld As Slide

    dstSld = srcPres.CloneSlide(srcSld, dstSldPosition, dstPres, New SortedList)

    'Now below is the code to copy srcSld notes to dstSld notes

    'Add notes to dstSld and clear all paragraphs

    dstSld.AddNotes()

    dstSld.Notes.Paragraphs.Clear()

     

    'Finally add all the pargraphs in notes of sldSrc into the notes of dstSld

    For Each srcPara As Paragraph In srcSld.Notes.Paragraphs

    'Create the replica of srcPara

    Dim dstPara As Paragraph

    dstPara = New Paragraph(srcPara)

    'Add this Replica to dstSld.Notes.Paragraphs

    dstSld.Notes.Paragraphs.Add(dstPara)

    Next

    End Sub

    End Module


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  06-25-2007, 4:09 AM 81628 in reply to 81537

    Re: Copy Slide Notes with Slides

    Hi Shakeel

    That works perfectly. Thank you for you help once again

    Regards

    Alan

     
  •  04-20-2008, 10:22 AM 123132 in reply to 81537

    Re: Copy Slide Notes with Slides

    Below is the same code in C#

     

    C# Code

    ----------------------------------------------------------------------------------------------------------------------

            static void Main(string[] args)

            {

     

                Presentation srcPres = new Presentation(@"C\srcPres.ppt");

                Presentation dstPres = new Presentation();

     

                CloneSlideWithNotes(srcPres, 1, dstPres);

     

                dstPres.Write(@"c:\dstPres.ppt");

                Console.WriteLine("\nPress any key to continue...");

                Console.ReadKey();

            }

     

            static void CloneSlideWithNotes(Presentation srcPres, int srcSlidePosition, Presentation dstPres)

            {

                Slide srcSld;

                srcSld = srcPres.GetSlideByPosition(srcSlidePosition);

     

                if (srcSld == null)

                    return;

     

                int dstSldPosition;

                dstSldPosition = dstPres.Slides.LastSlidePosition + 1;

     

                //Clone slide now, we have all the necessary parameters

                Slide dstSld;

                dstSld = srcPres.CloneSlide(srcSld, dstSldPosition, dstPres, new SortedList());

     

                //Now below is the code to copy srcSld notes to dstSld notes

                //Add notes to dstSld and clear all paragraphs

     

                dstSld.AddNotes();

                dstSld.Notes.Paragraphs.Clear();

     

                //Finally add all the pargraphs in notes of sldSrc into the notes of dstSld

                foreach (Paragraph srcPara in srcSld.Notes.Paragraphs)

                {

                    //Create the replica of srcPara

                    Paragraph dstPara = new Paragraph(srcPara);

     

                    //Add this Replica to dstSld.Notes.Paragraphs

                    dstSld.Notes.Paragraphs.Add(dstPara);

                }

            }

     

     


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  05-08-2008, 1:49 PM 126081 in reply to 123132

    Re: Copy Slide Notes with Slides

    Attachment: Present (inaccessible)

    Below is the same code in JAVA. It has the same output, you can see the output presentation and source presentation from the post above, they are attached there.

     

    JAVA CODE

    ----------------------------------------------------------------------------------------------------------------------

     

    public static void main(String[] args) {

         

          try

          {

                Presentation srcPres = new Presentation(new FileInputStream("c:\\srcPres.ppt"));

                Presentation dstPres = new Presentation();

                CloneSlideWithNotes(srcPres, 1, dstPres);

                dstPres.write(new FileOutputStream("c:\\dstPres.ppt"));

          }

          catch(Exception ex)

          {

                System.out.println(ex.toString());

          }

         

    }

     

    public static void CloneSlideWithNotes(Presentation srcPres, int srcSlidePosition,

                Presentation dstPres) throws Exception

    {

        Slide srcSld;

        srcSld = srcPres.getSlideByPosition(srcSlidePosition);

     

        if (srcSld == null)

            return;

     

        int dstSldPosition;

        dstSldPosition = dstPres.getSlides().getLastSlidePosition() + 1;

     

        //Clone slide now, we have all the necessary parameters

        Slide dstSld;

        dstSld = srcPres.cloneSlide(srcSld, dstSldPosition, dstPres, new TreeMap());

     

        //Now below is the code to copy srcSld notes to dstSld notes

       

        //Check if the source slide has notes

        if(srcSld.getNotes()==null)

          return;

       

        //Add notes to dstSld and clear all paragraphs

        dstSld.addNotes();

        Paragraphs dstNotesParas=dstSld.getNotes().getParagraphs();

        dstNotesParas.clear();

     

        //Finally add all the pargraphs in notes of sldSrc into the notes of dstSld

        Paragraphs srcNotesParas=srcSld.getNotes().getParagraphs();

       

        int parasCount=srcNotesParas.size();

       

        for(int i=0; i<parasCount; i++)

        {

          Paragraph srcPara=srcNotesParas.get(i);

         

             //Create the replica of srcPara

          Paragraph dstPara=new Paragraph(srcPara);

     

            //Add this Replica to dstSld.Notes.Paragraphs

          dstNotesParas.add(dstPara);

       

        }//for

    }

     

     


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
View as RSS news feed in XML