Click or drag to resize

PaperSize Enumeration

Specifies paper size.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.2
public enum PaperSize
  Member nameValueDescription
A30 297 x 420 mm.
A41 210 x 297 mm.
A52 148 x 210 mm.
B43 250 x 353 mm.
B54 176 x 250 mm.
Executive5 7.25 x 10.5 inches.
Folio6 8.5 x 13 inches.
Ledger7 17 x 11 inches.
Legal8 8.5 x 14 inches.
Letter9 8.5 x 11 inches.
EnvelopeDL10 110 x 220 mm.
Quarto11 8.47 x 10.83 inches.
Statement12 8.5 x 5.5 inches.
Tabloid13 11 x 17 inches.
Paper10x1414 10 x 14 inches.
Paper11x1715 11 x 17 inches.
Custom16 Custom paper size.
Specifies paper size, orientation, margins and other settings for a section.
DocumentBuilder builder = new DocumentBuilder();

PageSetup ps = builder.PageSetup;
ps.PaperSize = Aspose.Words.PaperSize.Legal;
ps.Orientation = Orientation.Landscape;
ps.TopMargin = ConvertUtil.InchToPoint(1.0);
ps.BottomMargin = ConvertUtil.InchToPoint(1.0);
ps.LeftMargin = ConvertUtil.InchToPoint(1.5);
ps.RightMargin = ConvertUtil.InchToPoint(1.5);
ps.HeaderDistance = ConvertUtil.InchToPoint(0.2);
ps.FooterDistance = ConvertUtil.InchToPoint(0.2);

builder.Writeln("Hello world.");

builder.Document.Save(ArtifactsDir + "PageSetup.PageMargins.doc");
Creates a simple document from scratch using the Aspose.Words object model.
// Create an "empty" document. Note that like in Microsoft Word, 
// the empty document has one section, body and one paragraph in it
Document doc = new Document();

// This truly makes the document empty. No sections (not possible in Microsoft Word)

// Create a new section node
// Note that the section has not yet been added to the document, 
// but we have to specify the parent document
Section section = new Section(doc);

// Append the section to the document

// Lets set some properties for the section
section.PageSetup.SectionStart = SectionStart.NewPage;
section.PageSetup.PaperSize = PaperSize.Letter;

// The section that we created is empty, lets populate it. The section needs at least the Body node
Body body = new Body(doc);

// The body needs to have at least one paragraph
// Note that the paragraph has not yet been added to the document, 
// but we have to specify the parent document
// The parent document is needed so the paragraph can correctly work
// with styles and other document-wide information
Paragraph para = new Paragraph(doc);

// We can set some formatting for the paragraph
para.ParagraphFormat.StyleName = "Heading 1";
para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

// So far we have one empty paragraph in the document
// The document is valid and can be saved, but lets add some text before saving
// Create a new run of text and add it to our paragraph
Run run = new Run(doc);
run.Text = "Hello World!";
run.Font.Color = Color.Red;

// As a matter of interest, you can retrieve text of the whole document and
// see that \x000c is automatically appended. \x000c is the end of section character
Console.WriteLine("Hello World!\x000c");

// Save the document
doc.Save(ArtifactsDir + "Section.CreateFromScratch.doc");
See Also