Amourspirit / python-ooouno-ex

MIT License
11 stars 1 forks source link

[question] accesing option when exporting Draw/Impress to saving format #287

Closed YouvenZ closed 8 months ago

YouvenZ commented 9 months ago

Hi @Amourspirit !

I would like to get acces to the option presented when saving a draw/Impress doc

Screenshot from 2024-01-13 19-11-59 First I tried to change the size slide directly by changing the property height and weight

    def main(self) -> None:
        # connect headless. will not need to see slides
        with Lo.Loader(Lo.ConnectPipe(headless=True)) as loader:
            doc = Lo.open_doc(fnm=self._fnm, loader=loader)

            if not Info.is_doc_type(obj=doc, doc_type=Lo.Service.IMPRESS):
                Lo.print("-- Not a slides presentation")
                return

            slide = Draw.get_slide(doc=doc, idx=self._idx)
            slide.setPropertyValue("Width", 300)
            slide.setPropertyValue("Height", 200)
            ...

but I was wrong it change actual size of the draw not the resolution. I want to change the resolution and the transparency of the image saved. could you provide some guidance on this please.

Amourspirit commented 9 months ago

I am not sure of the solution for this just yet. At this time OooDev does not have anything built in for this.

I am not even sure this is part of the LibreOffice API.

I did just today add an export Calc Range as Image. The demo is in this repo here.

The method to acomplish this uses filters. See my source for this here.

I am saying this because I suspect that the implemention you are looking for is similar for Draw.

In OooDev See docs on Info.get_filter_names() and Info.get_filter_props() to get more information on filters.

See also https://ask.libreoffice.org/t/export-as-png-with-macro/74337/11 and https://ask.libreoffice.org/t/how-to-export-cell-range-to-images/57828/2

YouvenZ commented 9 months ago

Thanks for the answer! In the the example with Calc, the dict event_data seems to have exactly what I need. I will take a look at the documentation to understand filters and try. I will also try to post the example if I find the correct workaround.

Amourspirit commented 9 months ago

I have been attempting to work out filters and add them to OooDev. So far it seems to be challenging and there may be bugs in Python around filters and Image export.

I starteded a post on Ask: Basic works, Python fails same task. Exporting image fails for other resolutions. Why?

Amourspirit commented 8 months ago

A new version of OooDev has been released to day, version 0.23.0.

Now it is possible to export Draw Page and Impress Pages with filters. This should give you what you need.

The Impress Slide to Image example has been updated to reflect the usage of filters.

Also there is an Impress Slide to Image 2 example that shows how export pages using filters in a different way.

Support has been added for exporting indivitual shapes a images too. The Export Shape as Image demonstrates this.