Skip to content

How to run a macro before converting a file to PDF? #3

@shantanuo

Description

@shantanuo

Thank you for this excellent code that is working as expected. And this line is the most important.

result = subprocess.run(['/opt/libreoffice7.5/program/soffice', '--headless', '--nologo', '--nodefault', '--nofirststartwizard', '--convert-to', 'pdf', file, '--outdir', '/tmp'], capture_output=True)

I need to run a macro before converting the file to PDF. So I added this line just before the one mentioned above.

macro_result = subprocess.run(
["/opt/libreoffice7.5/program/soffice", "--headless", "--invisible", "--norestore", f"macro:///StyleLibrary.Module1.myStyleMacro2({file})"],
check=False, capture_output=True

This line gets executed and changes the file as indicated by timestamp of the file. But the contents of the macro are not actually applied to the text inside the file. I have made sure that the macro is installed through extension. And the macro is working as expected and there is no problem with the macro code. I must be missing something in subprocess.run method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions