(I’m on version 21.12)
I’m making a presentation with a table that has different image icons in them.
The table can have variable number of columns and rows.
The image icons are currently inserted as explained in
In the example code Manage Cells|Aspose.Slides Documentation
And using setStrechOffsetXXX to make the image centered.
I’m not able to get the images to show in a way that looks good.
Using the above method with strected images as background in the cell the images keeps getting poor resolution (when png) and stretched images when using svg. (svgs ignore setStrechOffsetXXX) methods
In libreoffice Impress there is an option to use custom position/size when using an image as table cell background.
image.png (139.6 KB)
But there is no matching “Custom position/size” with the relevant properties.
Having this available would help greatly I believe. (will this be implemented?)
I have tried adding image shapes over the cells, this works fine on pdf but in pptx the images gets placed slightly below the cell instead of hovering above as expected.
In summary :
- Could we have the custom position/size setting for cell background image
- Or investigate why pdf output have a different rendering of hover images than pptx output.
Regards
Odd Are Bjørkli
@Bjorkli
Can you please clarify what specific properties you are looking for in the ‘Custom position/size’ setting for cell background images?
In Libreoffice there is a width and height property as well as a “As percentage of the parent”
The parent in this case would be the cell.
There is also a position combo that allows the user to select center, top left, top right… and so on.
@Bjorkli,
I need some time to check the issue. I will get back to you as soon as possible.
@Bjorkli,
Thank you for your patience. Unfortunately, it’s hard to say at this point whether PowerPoint can do what you need. Could you please share sample images and a PowerPoint presentation containing a manually created table that shows the expected appearance? We will do our best to achieve the same result using Aspose.Slides for Java.
Using libreoffice Impress I made document
testDoc.zip (11.9 KB)
(zipped because odp files are not allowed here)
It has a table with a single svg in it.
image.png (1.1 KB)
Now saving it as pptx gives
testDoc1.zip (7.7 KB)
Reopening the pptx file does not show the icon in the same way as in the odp file.
image.png (1.2 KB)
So I guess that the pptx format does not support the custom placement like the odp files does.
So this means that pursuing this direction is not viable unless Microsoft changes pptx format to support this.
(I probably can’t convince customer to use odp instead, so I think a different direction is needed)
Regards
Odd
Now using the different method to “hover” images above the cell by calculating its position I get
pptx1.png (34.3 KB)
when exporting as pptx
pdf1.png (28.2 KB)
when exporting as pdf.
For some reason the icon is slightly shifted when saving as pptx.
Is this something that can be raised as an issue in Aspose slides?
Or is it a trick to it.
Regards
Odd Are Bjørkli
@Bjorkli ,
Thank you for the sample files. I need some time to check the issue. I will get back to you as soon as possible.
@Bjorkli,
Thank you for your patience. PowerPoint provides only the following properties for adjusting the placement of a background image inside a table cell: offset left, offset right, offset top, and offset bottom. I was able to achieve the same image placement in the PPTX file as in the ODP file using the following code example.
Presentation presentation = new Presentation("testDoc1.pptx");
ISlide slide = presentation.getSlides().get_Item(0);
ITable table = (ITable)slide.getShapes().get_Item(0);
ICell cell = table.getRows().get_Item(0).get_Item(2);
IPictureFillFormat fillFormat = cell.getCellFormat().getFillFormat().getPictureFillFormat();
fillFormat.setStretchOffsetLeft(39.5f);
fillFormat.setStretchOffsetRight(39.5f);
fillFormat.setStretchOffsetTop(21);
fillFormat.setStretchOffsetBottom(21);
presentation.save("output.pptx", SaveFormat.Pptx);
presentation.dispose();
files.zip (31.3 KB)
Unfortunately, PowerPoint does not provide another way.
Thanks for the answer.
I’ll continue investigating a solution with the strechoffsets
Regards
@Bjorkli
@Bjorkli,
You’re welcome! If you still notice a mismatch between what you see in PowerPoint and in the saved PPTX or PDF—please share the PPTX produced by your code along with the snippet itself. I’ll reproduce the behaviour on my side and, if necessary, log it in our tracker.