com.aspose.words
Class PaperSize

java.lang.Object
    extended by com.aspose.words.PaperSize

public class PaperSize 
extends java.lang.Object

Utility class containing constants. Specifies paper size.

Example:

Specifies paper size, orientation, margins and other settings for a section.
DocumentBuilder builder = new DocumentBuilder();

PageSetup ps = builder.getPageSetup();
ps.setPaperSize(PaperSize.LEGAL);
ps.setOrientation(Orientation.LANDSCAPE);
ps.setTopMargin(ConvertUtil.inchToPoint(1.0));
ps.setBottomMargin(ConvertUtil.inchToPoint(1.0));
ps.setLeftMargin(ConvertUtil.inchToPoint(1.5));
ps.setRightMargin(ConvertUtil.inchToPoint(1.5));
ps.setHeaderDistance(ConvertUtil.inchToPoint(0.2));
ps.setFooterDistance(ConvertUtil.inchToPoint(0.2));

builder.writeln("Hello world.");

builder.getDocument().save(getMyDir() + "PageSetup.PageMargins Out.doc");

Example:

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).
doc.removeAllChildren();

// 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.
doc.appendChild(section);

// Lets set some properties for the section.
section.getPageSetup().setSectionStart(SectionStart.NEW_PAGE);
section.getPageSetup().setPaperSize(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);
section.appendChild(body);


// 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);
body.appendChild(para);

// We can set some formatting for the paragraph
para.getParagraphFormat().setStyleName("Heading 1");
para.getParagraphFormat().setAlignment(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.setText("Hello World!");
run.getFont().setColor(Color.RED);
para.appendChild(run);


// 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.
System.out.println(doc.getText());

// Save the document.
doc.save(getMyDir() + "Section.CreateFromScratch Out.doc");

Field Summary
static final intA3 = 0
           297 x 420 mm.
static final intA4 = 1
           210 x 297 mm.
static final intA5 = 2
           148 x 210 mm.
static final intB4 = 3
           250 x 353 mm.
static final intB5 = 4
           176 x 250 mm.
static final intEXECUTIVE = 5
           7.25 x 10.5 inches.
static final intFOLIO = 6
           8 x 13 inches.
static final intLEDGER = 7
           11 x 17 inches.
static final intLEGAL = 8
           8.5 x 14 inches.
static final intLETTER = 9
           8.5 x 11 inches.
static final intENVELOPE_DL = 10
           110 x 220 mm.
static final intQUARTO = 11
           8 x 10 inches.
static final intSTATEMENT = 12
           8.5 x 5.5 inches.
static final intTABLOID = 13
           11 x 17 inches.
static final intPAPER_10_X_14 = 14
           10 x 14 inches.
static final intPAPER_11_X_17 = 15
           11 x 17 inches.
static final intCUSTOM = 16
           Custom paper size.
 

Field Detail

A3 = 0

public static final int A3
297 x 420 mm.

A4 = 1

public static final int A4
210 x 297 mm.

A5 = 2

public static final int A5
148 x 210 mm.

B4 = 3

public static final int B4
250 x 353 mm.

B5 = 4

public static final int B5
176 x 250 mm.

EXECUTIVE = 5

public static final int EXECUTIVE
7.25 x 10.5 inches.

FOLIO = 6

public static final int FOLIO
8 x 13 inches.

LEDGER = 7

public static final int LEDGER
11 x 17 inches.

LEGAL = 8

public static final int LEGAL
8.5 x 14 inches.

LETTER = 9

public static final int LETTER
8.5 x 11 inches.

ENVELOPE_DL = 10

public static final int ENVELOPE_DL
110 x 220 mm.

QUARTO = 11

public static final int QUARTO
8 x 10 inches.

STATEMENT = 12

public static final int STATEMENT
8.5 x 5.5 inches.

TABLOID = 13

public static final int TABLOID
11 x 17 inches.

PAPER_10_X_14 = 14

public static final int PAPER_10_X_14
10 x 14 inches.

PAPER_11_X_17 = 15

public static final int PAPER_11_X_17
11 x 17 inches.

CUSTOM = 16

public static final int CUSTOM
Custom paper size.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.