How to Add Notes To XSLFSlide?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to Add Notes To XSLFSlide?

Eliot Kimber
I'm coming back to my Slidinator project (https://github.com/drmacro/slidinator), which generates PPTX (and possibly other slide formats) from XML after having last worked on it in 2014, so I'm catching up on the XSLF part of POI.

I'm working on putting slide notes into slides and in my test case XSLFSlide.getNotes() returns null.

So I'd like to add notes to the slide but I'm not finding any obvious method for doing it. There's no public constructor on XSLFNotes and I didn't find any "createNotes()" sort of method.

Is this missing from the current API? If so, I can possibly try to add the necessary methods if appropriate, although I'm waiting on landing a client project to pursue Slidinator updates more actively...

I assume that I can always jump down in the markup and construct things that way but I always hate to do that if I can avoid it.

Thanks,

E.
--
Eliot Kimber
http://contrext.com



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to Add Notes To XSLFSlide?

pj.fanning
Have you tried XMLSlideShow#getNotesSlide(XSLFSlide slide)?



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to Add Notes To XSLFSlide?

kiwiwings
In reply to this post by Eliot Kimber
Hi Eliot,

> Is this missing from the current API? If so, I can possibly try to add the necessary methods if appropriate,
Yes it's missing. Although there's a XSLFSlide::setNotes method, it's a no-op.

Feel free to extend the API and please share your implementation in a bugzilla or github pull request.

Andi



signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to Add Notes To XSLFSlide?

Eliot Kimber
In reply to this post by pj.fanning
getNotesSlide() does get me an XSLFNotes instance and I can then add content to it, but as Andreas points out, addNotes() is a no-op (

I'll see if I can puzzle out what's involved in adding the notes object to a slide.

Cheers,

E.

--
Eliot Kimber
http://contrext.com
 

On 5/2/19, 3:23 PM, "pj.fanning" <[hidden email]> wrote:

    Have you tried XMLSlideShow#getNotesSlide(XSLFSlide slide)?
   
   
   
    --
    Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
   
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: [hidden email]
    For additional commands, e-mail: [hidden email]
   
   
   



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to Add Notes To XSLFSlide?

Eliot Kimber
I may have spoken too soon--looks like I'm actually getting the notes for the slide I'm constructing but the paragraphs I'm adding are not in the right place or don't have the right properties (they don't show up when I view the PPTX in PowerPoint but they are in the slide note XML).

So looks like it's just my user error, which is good.

Cheers,

E.
--
Eliot Kimber
http://contrext.com
 

On 5/4/19, 9:58 AM, "Eliot Kimber" <[hidden email]> wrote:

    getNotesSlide() does get me an XSLFNotes instance and I can then add content to it, but as Andreas points out, addNotes() is a no-op (
   
    I'll see if I can puzzle out what's involved in adding the notes object to a slide.
   
    Cheers,
   
    E.
   
    --
    Eliot Kimber
    http://contrext.com
     
   
    On 5/2/19, 3:23 PM, "pj.fanning" <[hidden email]> wrote:
   
        Have you tried XMLSlideShow#getNotesSlide(XSLFSlide slide)?
       
       
       
        --
        Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
       
        ---------------------------------------------------------------------
        To unsubscribe, e-mail: [hidden email]
        For additional commands, e-mail: [hidden email]
       
       
       
   
   
   
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: [hidden email]
    For additional commands, e-mail: [hidden email]
   
   
   



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to Add Notes To XSLFSlide?

Eliot Kimber
OK, here's my solution, using XMLSlideShow#getNotesSlide(XSLFSlide slide), which works but feels a bit kludgy, so maybe I'm missing a better way to get the appropriate placeholder from the XSLFNotes object?

      List<XSLFShape> shapes = pptxNotes.getShapes();
      XSLFTextShape shape = null;
      for (XSLFShape cand : shapes) {
        String shapeName = cand.getShapeName();
        if (shapeName.startsWith("Notes Placeholder")) {
          shape = (XSLFTextShape)cand;
          break;
        }
      }

I can then add paragraphs to the shape using my normal paragraph-adding code.

Cheers,

E.
--
Eliot Kimber
http://contrext.com
 

On 5/4/19, 10:11 AM, "Eliot Kimber" <[hidden email]> wrote:

    I may have spoken too soon--looks like I'm actually getting the notes for the slide I'm constructing but the paragraphs I'm adding are not in the right place or don't have the right properties (they don't show up when I view the PPTX in PowerPoint but they are in the slide note XML).
   
    So looks like it's just my user error, which is good.
   
    Cheers,
   
    E.
    --
    Eliot Kimber
    http://contrext.com
     
   
    On 5/4/19, 9:58 AM, "Eliot Kimber" <[hidden email]> wrote:
   
        getNotesSlide() does get me an XSLFNotes instance and I can then add content to it, but as Andreas points out, addNotes() is a no-op (
       
        I'll see if I can puzzle out what's involved in adding the notes object to a slide.
       
        Cheers,
       
        E.
       
        --
        Eliot Kimber
        http://contrext.com
         
       
        On 5/2/19, 3:23 PM, "pj.fanning" <[hidden email]> wrote:
       
            Have you tried XMLSlideShow#getNotesSlide(XSLFSlide slide)?
           
           
           
            --
            Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
           
            ---------------------------------------------------------------------
            To unsubscribe, e-mail: [hidden email]
            For additional commands, e-mail: [hidden email]
           
           
           
       
       
       
        ---------------------------------------------------------------------
        To unsubscribe, e-mail: [hidden email]
        For additional commands, e-mail: [hidden email]
       
       
       
   
   
   
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: [hidden email]
    For additional commands, e-mail: [hidden email]
   
   
   



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]