doc.AddPages(n)
Appends n pages at the end. The idiom while len(doc.Pages) < page_index: doc.AddPages(1) means "add pages until there are enough". len(doc.Pages) doesn't always work
Signature
doc.AddPages(n)
Notes
Appends n pages at the end. The idiom
while len(doc.Pages) < page_index: doc.AddPages(1) means "add pages until there are enough". len(doc.Pages) doesn't always work in Python — doc.Pages.Count is the safe form.Python example (runnable)
Requires
pywin32. The example assumes app / doc / page / layer are already connected.
See Connection & InitPython
need = 5 # we need 5 pages
while doc.Pages.Count < need: # keep adding until we have enough
doc.AddPages(1) # append one page per call
print("Page count: ", doc.Pages.Count)
About this section: Document
Document — documents and file handling.
- This section has 20 entries; this is one of them.
- See the full section index: Document
Other entries in this section
- doc.PagesThe page collection. doc.Pages.Count for the total, doc.Pages.Item(i)
- doc.ActivePageThe current page object.
- doc.ActiveLayerThe active layer of the current page.
- doc.UnitDocument unit (cdrUnit). Every geometric value follows it: shape coord
- doc.ResolutionDocument resolution in dpi. Affects bitmap export and effect rendering
- doc.ReferencePointReference point for transforms. It anchors SetPosition and SetSize and
- doc.ClearSelection()Deselects everything. Call it before a batch run so you don't accident
- doc.BeginCommandGroup(commandName)Opens an undo group; everything after it collapses into one entry in t