1

Following the Opening pdf file question

I am looking for a way to also command Adobe Acrobat Reader to save the file programmatically using Python.

I am not looking for the pikepdf way of saving the file.

Reason: This PDF file, created with fill-pdf, needs to go through special formatting done by Acrobat Reader upon opening. Upon exit Acrobat Reader asks whether to save the formatting it did, I need this "Yes, Save" to be via code.

Edit: How to proceed from here using pywinauto?

import time
from pywinauto.application import Application

pdf_file = r'C:\Path\To\Total.pdf'
acrobat_path = r"C:\Path\To\Acrobat.exe"

app = Application(backend=u'uia').start(cmd_line = acrobat_path + ' ' + pdf_file)
print("started")
time.sleep(1)
app = Application(backend=u'uia').connect(path=acrobat_path)
print("connected")

1 Answer 1

0

solution with pyautogui:

import os
os.startfile(path)
filename = os.path.basename(path)
focus = pg.getWindowsWithTitle(filename)
while len(focus) == 0:
    focus = pg.getWindowsWithTitle(filename)
focus [0].show() # show() for python3.9, activate() for python3.7
time.sleep(1)
pg.hotkey('ctrl', 's')
time.sleep(1)
pg.hotkey('ctrl', 'q')
print("Blessed Be God")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.