PaperSize enumeration

PaperSize enumeration

Specifies paper size.

Members

NameDescription
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.

Examples

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!')
doc.save(file_name=ARTIFACTS_DIR + '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.
builder.insert_break(aw.BreakType.SECTION_BREAK_EVEN_PAGE)
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)
builder.insert_break(aw.BreakType.SECTION_BREAK_EVEN_PAGE)
# 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}.')
doc.save(ARTIFACTS_DIR + '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.
doc.remove_all_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)
doc.append_child(section)
# 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)
section.append_child(body)
# 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
body.append_child(para)
# 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 = aspose.pydrawing.Color.red
para.append_child(run)
self.assertEqual('Hello World!', doc.get_text().strip())
doc.save(file_name=ARTIFACTS_DIR + 'Section.CreateManually.docx')

See Also