PPTX how to get the marked list with adjacent icons.

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

PPTX how to get the marked list with adjacent icons.

savotii
This post was updated on .
Guys hi. I need your help, i don't understand how can I retrieve the
predefined custom marked list with some special icon instead numbers or
another symbols.
I've been implementing some conversion and faced with such problem.
It would be great if you could give me some links with examples.
Thx a lot.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

Reply | Threaded
Open this post in threaded view
|

Re: PPTX getting the custome marked list with special icons.

kiwiwings
Hi,

how can I retrieve the predefined custom marked list with some special icon

As you haven't provided any example file, I've made one up myself.
So I have a bullet list with custom images. Accessing the images can be done like this:

try (FileInputStream fis = new FileInputStream("CustomBulletList.pptx");
    XMLSlideShow ppt = new XMLSlideShow(fis)) {
    XSLFSlide slide = ppt.getSlides().get(0);
    XSLFAutoShape shape = (XSLFAutoShape) slide.getShapes().get(1);
    CTTextParagraph para = shape.getTextParagraphs().get(0).getXmlObject();
    String bulletId = para.getPPr().getBuBlip().getBlip().getEmbed();
    POIXMLDocumentPart rel = slide.getRelationById(bulletId);
    PackagePart pp = rel.getPackagePart();
    try (InputStream is = pp.getInputStream();
        FileOutputStream fos = new FileOutputStream(new File(pp.getPartName().getName()).getName())) {
        IOUtils.copy(is, fos);
    }
}


Not sure if this helps you, but if not, you need to put more effort into your question,
e.g. a sample file and what you expect from reading that file.

Andi


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

Re: PPTX getting the custome marked list with special icons.

savotii
This post was updated on .
Thx a lot, Yes It's my mistake about absent example, I'm here the new
desperate member)
I'll try your example and answer, if it's ok.
I've attached my example. I'm interested in extracted an icon near by text.
Quite complicated for me.
Anyway, thx for your example.


example.pptx
--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

Reply | Threaded
Open this post in threaded view
|

Re: PPTX getting the custome marked list with special icons.

savotii
In reply to this post by kiwiwings
Unfortunately, your example doesn't work for me.
para.getPPr().getBuBlip() returns a null.




--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

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

Reply | Threaded
Open this post in threaded view
|

Re: PPTX getting the custome marked list with special icons.

Alain Béarez
Hi,

It seems the bullet style is defined at the master level, not directly
at the paragraph level, in your particular case.

Unfortunately, I did not have time to finish the high level API which
was intended to perform the search for these paragraph properties.

When trying to use the following code on your paragraph, some null
reference will be returned too:

     String bulletId =
shape.getTextBody().getParagraph(0).getBulletProperties().getPicture().getXmlObject().getEmbed();

Cheers,
Alain FAGOT BÉAREZ

Je 2020-03-04 09:55, savotii skribis:
> Unfortunately, your example doesn't work for me.
> para.getPPr().getBuBlip() returns a null.

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

Reply | Threaded
Open this post in threaded view
|

Re: PPTX getting the custome marked list with special icons.

savotii
Maybe you could indicate on low level code, where can I find some solution
for my reason?
Thx a lot.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

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

Reply | Threaded
Open this post in threaded view
|

Re: PPTX getting the custome marked list with special icons.

kiwiwings

Hi Savotii,

I've made some changes to the codebase [1] - the placeholder code in XSLFShape.getPlaceholder() based on the placeholder type instead of the index is not valid for all cases ...

Please use a nightly [2] tomorrow, when the changes are compiled into.

You can then use the following code:

public class TestLayoutImages {
    static List<Function<XDDFTextBody,XDDFParagraphProperties>> PARA_PROPS = Arrays.asList(
        XDDFTextBody::getDefaultProperties,
        XDDFTextBody::getLevel1Properties,
        XDDFTextBody::getLevel2Properties,
        XDDFTextBody::getLevel3Properties,
        XDDFTextBody::getLevel4Properties,
        XDDFTextBody::getLevel5Properties,
        XDDFTextBody::getLevel6Properties,
        XDDFTextBody::getLevel7Properties,
        XDDFTextBody::getLevel8Properties,
        XDDFTextBody::getLevel9Properties
    );

    @Test
    public void exportImages() throws IOException {
        try (FileInputStream fis = new FileInputStream("example.pptx");
             XMLSlideShow ppt = new XMLSlideShow(fis)) {
            XSLFSlide slide = ppt.getSlides().get(0);
            XSLFTextShape list = (XSLFTextShape)slide.getShapes().get(0);

            XSLFAutoShape shape = (XSLFAutoShape)list.getPlaceholderDetails().getPlaceholderShape();

            XDDFTextBody phBody = shape.getTextBody();
            int indent = list.getTextParagraphs().get(0).getIndentLevel();
            XDDFParagraphProperties props = PARA_PROPS.get(indent == 0 || indent > 9 ? 1 : indent).apply(phBody);

            String bulletId = props.getBulletProperties().getXmlObject().getBuBlip().getBlip().getEmbed();
            POIXMLDocumentPart rel = slide.getMasterSheet().getRelationById(bulletId);
            PackagePart pp = rel.getPackagePart();
            try (InputStream is = pp.getInputStream();
                 FileOutputStream fos = new FileOutputStream(new File(pp.getPartName().getName()).getName())) {
                IOUtils.copy(is, fos);
            }
        }
    }
}

Best wishes,
Andi


[1] https://svn.apache.org/viewvc?view=revision&revision=1875328

[2] https://builds.apache.org/view/P/view/POI/job/POI-DSL-1.8/lastSuccessfulBuild/artifact/build/dist/


signature.asc (499 bytes) Download Attachment