Info regarding extraction of resources from slides

Hi,

I’m using aspose.slides for Java.

Please tell me:

  1. There is a way to detect if same image is imported several times in a presentation?
  2. Hot to correctly detect shapes that are coming from master slide? I want to create a small program that extracts all the shapes that are visible on a particular slide (imported from master or imported directly in that slide).

Thank you,
Razvan

Hi Razwan,

Thanks for inquiring Aspose.Slides.

I have observed your requirements and will try to answer them separately.

There is a way to detect if same image is imported several times in a presentation?

Aspose.Slides automatically internally optimize the image addition in presentation process by avoiding addition of duplicate images in Presentation.Images collection. So, for any image if already added, its second instance will not be added in Image Collection and there will be only one import for any image in Image Collection but that image may be used many times inside presentation.

How to correctly detect shapes that are coming from master slide? I want to create a small program that extracts all the shapes that are visible on a particular slide (imported from master or imported directly in that slide).

I like to share that every slide has a method, Slide.getShowMasterShapes(), which if returns true means that slide inherit shapes from its respective LayoutSlide and Header/Footer from master slide (since they are defined on master slide level). In case of true returned from Slide.getShowMasterShapes(), you need to traverse the shapes inside respective LayouSlide for extraction.

I hope this will clarify the concept. For your kind reference, I have attached the working sample code, source and generated presentations exhibiting shapes access and same image addition multiple times in Presentation.Images collection.

Many Thanks,

Mudassir Fayyaz
Aspose - File Format APIs

Keep in touch! We’re on Twitter and Facebook

TestShapes.zip (266.8 KB)

Hi,
I cannot download the file.
“Sorry, this file is private. Only visible to post creator and staff members”

Razvsn

Hi Razwan,

We are having some issues with sharing of attachments and it will be fixed soon. Please download the shared files from this google drive public link for the time being:
https://drive.google.com/open?id=0BzvMFhwg29yELV9ZeUVSRDhLS1U

Many Thanks,

Mudassir Fayyaz
Aspose - File Format APIs

Keep in touch! We’re on Twitter and Facebook

And another question.
How can I retrieve the slide size.
I saw that the method presentation.getSlideSize().getSize() is deprecated and btw it returns wrong size.

Hi Razwan,

I have observed your requirements and like to share that you will still be getting the slide size by using presentation.getSlideSize().getSize() on your end. It has been marked deprecated only for setting size method only. We will also be improving our API documentation in coming product release to avoid this ambiguity as well. Secondly, Aspose.Slides uses 72 Pixels/Inch as a unit for slide size. So, for a slide with size 10 ‘’ X 7.5 ‘’, Aspose.Slides shall calculate the slide size as 1072 X 7.572= 720 X 540. I hope this will clear the concept to you.

Many Thanks,

Mudassir Fayyaz
Aspose - File Format APIs

Keep in touch! We’re on Twitter and Facebook

I managed to download the file.
For the second question I succeeded to detect pictures from master slide.
But for the first one: I don’t want to import one file twice.
I want to parse existing slides and detect duplicate pictures(scaled or not).
I saw that I can find the image in the collection associated with the presentation and test against the hashcode.
This is the way?

Hi Razwan,

I have observed your following question:

Yes, you need to access the slides for shapes or slide backgrounds having images. Then you get the image and verify that in ImageCollection and may set some counter for any occurrence of image. When more than one occurrence of images would be found in ImageCollection, you would get to know that image is repeated. I hope this will be understandable.

Many Thanks,

Mudassir Fayyaz
Aspose - File Format APIs

Keep in touch! We’re on Twitter and Facebook

Hi,

The method getSpaceWithin from IParagraphFormatEffectiveData returns a value.
Is it possible to translate this value in pixels?

Thank you,
Razvan

Hi Razwan,

I have observed your requirements and like to share getSpaceWithin return single value as its is set in Paragraph formatting inside PowerPoint. If you are able to map the value returned from getSpaceWithin inside PowerPoint to inches (which is unit for slide size), you can then derive Aspose.Slides mapping for that as well. Aspose.Slides has 72 Pixels/inch as unit for slide size. Otherwise, there is no direct way available to get the pixel values. This is not an issue as well because, Aspose.Slides maps the values to Space Within, After and Before for Paragraph Format in PowerPoint. I hope this will be understandable.

Many Thanks,

Mudassir Fayyaz

Hi,

I have a text box in a slide and the text inside this is vertically aligned in the middle.
Can you tell me how I can retrieve this information?
I tried with paragraph.getParagraphFormat().getFontAlignment(), but it returns -1.

Thank you,
Razvan

Hi Razvan,

Can you please provide the source presentation describing your requirement that what text formatting value you are interested in extracting. I will investigate that further on my end to help you out.

Many Thanks,

Mudassir Fayyaz

A simple slide with a textbox where the text is aligned in the middle both horizontally and vertically.
I want to extract that information related to vertical alignment.
I want to know if it’s bottom, top, centered…
I don’t know how to attach the presentation here…

Hi Razvan,

I have observed your requirements and like to share that you need to access TexVerticalType and TextAnchorType properties that are defined on TextFrameFormat to get desired results. Please try using following sample code on your end to serve the purpose.

public static void GetAlignmentValues()
{
    Presentation pres = new Presentation("C:\\Aspose Data\\TextAlign.pptx");
    ISlide slide = pres.getSlides().get_Item(0);
    IAutoShape ashp = (IAutoShape)slide.getShapes().get_Item(0);
    byte verticaleType= ashp.getTextFrame().getTextFrameFormat().getTextVerticalType();
    byte anchor= ashp.getTextFrame().getTextFrameFormat().getAnchoringType();

}

Many Thanks,

Mudassir Fayyaz
TextAlign.zip (24.0 KB)

Hi,

In case of a PictureFrame that is partially outside of the slide, can you tell me what this method should return?
getThumbnail(ShapeThumbnailBounds.Appearance, 1f, 1f)
I thought it will return the intersection between the picture and the slide, but it doesn’t.

Thank you,
Razvan

@razvanni,

I suggest you to please visit ShapeThumbnailBounds API reference guide page link for elaboration. ShapeThumbnailBounds.Appearance will have size equal to the shape appearance (in bounds of a slide).

Many Thanks,

Mudassir Fayyaz