Я пытаюсь открыть PDF-файл в Mac-OS на определенной странице и программно масштабировать его.
Но я не могу этого сделать.
Вот мой код для Windows, может кто-нибудь, пожалуйста, дайте мне знать что мне нужно изменить в mac-os?
import subprocess
import os
def open_pdf_with_adobe(pdf_path, page_num, zoom):
try:
# Ensure the PDF path is absolute
pdf_path = os.path.abspath(pdf_path)
# Path to Adobe Acrobat Reader on macOS
path_to_acrobat = "/Applications/Adobe Acrobat Reader.app/Contents/MacOS/AdobeReader"
# Construct the command
command = [
path_to_acrobat,
pdf_path,
"/A",
f"page={page_num}&zoom={zoom}"
]
# Execute the command
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
# Print stdout and stderr (optional for debugging)
if stdout:
print("Standard output:", stdout.decode())
if stderr:
print("Standard error:", stderr.decode())
except FileNotFoundError:
print("Adobe Acrobat Reader application not found. Trying default PDF viewer.")
# If Adobe Acrobat Reader is not found, open with the default PDF viewer
subprocess.Popen(["open", pdf_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Example usage
pdf_path = "/Users/granth.jain/Desktop/Work/Wi-Fi CERTIFIED n Test Plan v2.21_0.pdf"
page_num = 12 # Adjust the page number as needed
zoom = "100" # Adjust the zoom level as needed
open_pdf_with_adobe(pdf_path, page_num, zoom)
Подробнее здесь: https://stackoverflow.com/questions/787 ... -in-mac-os
Как открыть PDF-файл на определенной странице и увеличить масштаб Python в Mac-OS ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Echart, как увеличить масштаб в определенной точке? Пример предоставлен
Anonymous » » в форуме Javascript - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Рисунок холста Flutter исчезает при попытке увеличить/уменьшить масштаб
Anonymous » » в форуме Android - 0 Ответы
- 21 Просмотры
-
Последнее сообщение Anonymous
-