-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathOpenDocument.py
More file actions
27 lines (23 loc) · 768 Bytes
/
OpenDocument.py
File metadata and controls
27 lines (23 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
OpenDocument.py
Opens an existing document. You'll have to fill in your own file path
"""
import win32com.client
import os
app = win32com.client.Dispatch('InDesign.Application.CC.2017')
myFile = r'C:\ServerTestFiles\TestDocument.indd'
directory = os.path.dirname(myFile)
if not os.path.exists(directory):
os.makedirs(directory)
myDocument = app.Documents.Add()
myDocument = myDocument.Save(myFile)
myDocument.Close()
if os.path.exists(directory):
myDocument = app.Open(myFile)
myPage = myDocument.Pages.Item(1)
myRectangle = myPage.Rectangles.Add()
myRectangle.GeometricBounds = ["6p", "6p", "18p", "18p"]
myRectangle.StrokeWeight = 12
#leave the document open...
print(myDocument.FullName)
# myDocument.Close()