PaperSize enumeration

PaperSize enumeration

Specifies paper size.


A3297 x 420 mm.
A4210 x 297 mm.
A5148 x 210 mm.
B4250 x 353 mm.
B5176 x 250 mm.
EXECUTIVE7.25 x 10.5 inches.
FOLIO8.5 x 13 inches.
LEDGER17 x 11 inches.
LEGAL8.5 x 14 inches.
LETTER8.5 x 11 inches.
ENVELOPE_DL110 x 220 mm.
QUARTO8.47 x 10.83 inches.
STATEMENT8.5 x 5.5 inches.
TABLOID11 x 17 inches.
PAPER_10X1410 x 14 inches.
PAPER_11X1711 x 17 inches.
NUMBER_10_ENVELOPE4.125 x 9.5 inches.
CUSTOMCustom paper size.


Shows how to adjust paper size, orientation, margins, along with other settings for a section.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
builder.page_setup.paper_size = aw.PaperSize.LEGAL
builder.page_setup.orientation = aw.Orientation.LANDSCAPE
builder.page_setup.top_margin = aw.ConvertUtil.inch_to_point(1)
builder.page_setup.bottom_margin = aw.ConvertUtil.inch_to_point(1)
builder.page_setup.left_margin = aw.ConvertUtil.inch_to_point(1.5)
builder.page_setup.right_margin = aw.ConvertUtil.inch_to_point(1.5)
builder.page_setup.header_distance = aw.ConvertUtil.inch_to_point(0.2)
builder.page_setup.footer_distance = aw.ConvertUtil.inch_to_point(0.2)
builder.writeln('Hello world!') + 'PageSetup.PageMargins.docx')

Shows how to set page sizes.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
# We can change the current page's size to a pre-defined size
# by using the "paper_size" property of this section's PageSetup object.
builder.page_setup.paper_size = aw.PaperSize.TABLOID
self.assertEqual(792.0, builder.page_setup.page_width)
self.assertEqual(1224.0, builder.page_setup.page_height)
builder.writeln(f'This page is {builder.page_setup.page_width}x{builder.page_setup.page_height}.')
# Each section has its own PageSetup object. When we use a document builder to make a new section,
# that section's PageSetup object inherits all the previous section's PageSetup object's values.
self.assertEqual(aw.PaperSize.TABLOID, builder.page_setup.paper_size)
builder.page_setup.paper_size = aw.PaperSize.A5
builder.writeln(f'This page is {builder.page_setup.page_width}x{builder.page_setup.page_height}.')
self.assertEqual(419.55, builder.page_setup.page_width)
self.assertEqual(595.3, builder.page_setup.page_height)
# Set a custom size for this section's pages.
builder.page_setup.page_width = 620
builder.page_setup.page_height = 480
self.assertEqual(aw.PaperSize.CUSTOM, builder.page_setup.paper_size)
builder.writeln(f'This page is {builder.page_setup.page_width}x{builder.page_setup.page_height}.') + 'PageSetup.paper_sizes.docx')

Shows how to construct an Aspose.Words document by hand.

doc = aw.Document()
# A blank document contains one section, one body and one paragraph.
# Call the "RemoveAllChildren" method to remove all those nodes,
# and end up with a document node with no children.
# This document now has no composite child nodes that we can add content to.
# If we wish to edit it, we will need to repopulate its node collection.
# First, create a new section, and then append it as a child to the root document node.
section = aw.Section(doc)
# Set some page setup properties for the section.
section.page_setup.section_start = aw.SectionStart.NEW_PAGE
section.page_setup.paper_size = aw.PaperSize.LETTER
# A section needs a body, which will contain and display all its contents
# on the page between the section's header and footer.
body = aw.Body(doc)
# Create a paragraph, set some formatting properties, and then append it as a child to the body.
para = aw.Paragraph(doc)
para.paragraph_format.style_name = 'Heading 1'
para.paragraph_format.alignment = aw.ParagraphAlignment.CENTER
# Finally, add some content to do the document. Create a run,
# set its appearance and contents, and then append it as a child to the paragraph.
run = aw.Run(doc=doc)
run.text = 'Hello World!'
run.font.color =
self.assertEqual('Hello World!', doc.get_text().strip()) + 'Section.CreateManually.docx')

See Also