Change Notes Page Size and Orientation in JavaScript
Overview
Use Presentation.getNotesSize to access the presentation’s notes page settings. It returns an NotesSize object whose setSize method sets the page dimensions. Although the settings object itself cannot be replaced, you can assign new dimensions through this method.
Width and height are specified in points, with 72 points per inch. For example, 900 × 600 points is 12.5 × 8⅓ inches. These settings apply to the presentation, rather than to an individual slide’s notes.
| Setting | Purpose |
|---|---|
| Presentation.getNotesSize | Controls notes page dimensions and the page dimensions used for handout export. |
| Presentation.getSlideSize | Controls regular presentation slide dimensions through SlideSize. |
Changing either setting does not automatically change the other. Changing the notes page orientation also does not rotate the regular slides. See Slide Size to resize regular slides.
The examples below use an existing sample.pptx. For the export examples, use a presentation with at least one slide containing speaker notes. Each example can be run independently.
Read the Notes Page Size and Orientation
Read the width and height and compare them to determine the orientation: a wider page is landscape, a taller page is portrait, and equal dimensions describe a square page. This example prints the actual dimensions in points, without assuming a standard paper size.
const slides = require("aspose.slides.via.java");
let presentation = new slides.Presentation("sample.pptx");
try {
let size = presentation.getNotesSize().getSize();
let orientation = "Square";
if (size.getWidth() > size.getHeight()) {
orientation = "Landscape";
} else if (size.getWidth() < size.getHeight()) {
orientation = "Portrait";
}
console.log("Notes page: " + size.getWidth() + " x " + size.getHeight() + " points");
console.log("Orientation: " + orientation);
} finally {
presentation.dispose();
}
Switch to Landscape Without Changing the Paper Size
To change only the orientation, swap the existing width and height. This preserves the lengths of both sides, including those of a custom paper size. The condition below prevents an already-landscape page from being switched back to portrait and leaves a square page unchanged.
const slides = require("aspose.slides.via.java");
let presentation = new slides.Presentation("sample.pptx");
try {
let size = presentation.getNotesSize().getSize();
if (size.getWidth() < size.getHeight()) {
let width = size.getWidth();
size.setSize(size.getHeight(), width);
presentation.getNotesSize().setSize(size);
}
presentation.save("landscape-notes.pptx", slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
For portrait orientation, use the same assignment when size.getWidth() > size.getHeight(). Do not substitute A4 or Letter dimensions unless you also want to change the paper size.
Set and Verify a Custom Notes Page Size
Assign both dimensions together, then use Presentation.save to write the presentation. This example sets a 900 × 600-point landscape page, saves it as PPTX, and opens the saved file again to check the persisted values. The comparison allows a 0.01-point tolerance for floating-point values; it is not a guarantee of precision for every file format.
const slides = require("aspose.slides.via.java");
const java = require("java");
let presentation = new slides.Presentation("sample.pptx");
try {
let expectedSize = java.newInstanceSync("java.awt.Dimension", 900, 600);
presentation.getNotesSize().setSize(expectedSize);
presentation.save("custom-notes.pptx", slides.SaveFormat.Pptx);
let reopened = new slides.Presentation("custom-notes.pptx");
try {
let actualSize = reopened.getNotesSize().getSize();
let widthMatches = Math.abs(actualSize.getWidth() - expectedSize.getWidth()) < 0.01;
let heightMatches = Math.abs(actualSize.getHeight() - expectedSize.getHeight()) < 0.01;
let preserved = widthMatches && heightMatches;
console.log("Stored notes page: " + actualSize.getWidth() + " x " + actualSize.getHeight() + " points");
console.log("Size preserved: " + preserved);
} finally {
reopened.dispose();
}
} finally {
presentation.dispose();
}
The expected result is 900 x 600 points and Size preserved: true. Checking a newly opened presentation verifies the saved file, rather than only the in-memory settings.
Export Notes and Handouts
The page dimensions define the available area for notes or handout layouts. They do not enable those layouts by themselves: configure the export options as well. Regular slide export continues to use the slide dimensions.
Export Notes to PDF and PNG
Assign NotesCommentsLayoutingOptions to PdfOptions.setSlidesLayoutOptions to include notes in the PDF. This example also renders the first slide with notes to PNG using Slide.getImage and RenderingOptions.
The BottomTruncated mode keeps the notes on one page; notes that do not fit can be truncated. The PDF uses 900 × 600-point pages. At the image scale of 1 × 1 used below, the PNG is 900 × 600 pixels. Points describe the page geometry; pixels describe the raster output, whose dimensions also depend on the rendering scale.
const slides = require("aspose.slides.via.java");
const java = require("java");
let presentation = new slides.Presentation("sample.pptx");
try {
let size = java.newInstanceSync("java.awt.Dimension", 900, 600);
presentation.getNotesSize().setSize(size);
let layout = new slides.NotesCommentsLayoutingOptions();
layout.setNotesPosition(slides.NotesPositions.BottomTruncated);
let pdfOptions = new slides.PdfOptions();
pdfOptions.setSlidesLayoutOptions(layout);
presentation.save("notes.pdf", slides.SaveFormat.Pdf, pdfOptions);
let renderingOptions = new slides.RenderingOptions();
renderingOptions.setSlidesLayoutOptions(layout);
let image = presentation.getSlides().get_Item(0).getImage(renderingOptions, 1, 1);
try {
image.save("first-slide-notes.png", slides.ImageFormat.Png);
} finally {
image.dispose();
}
} finally {
presentation.dispose();
}
For PDF export with long notes, BottomFull allows additional pages as needed. Do not use that mode with the single-slide image call above, which does not support it. After resizing, inspect the output for clipped notes and the placement of existing notes-master objects; changing page dimensions alone should not be treated as a guarantee that all content will fit. See Convert PowerPoint to PDF with Notes for more about notes export.
Export Handouts to PDF
Use HandoutLayoutingOptions for multiple slide thumbnails on one page. The following example sets a 900 × 600-point page and uses HandoutType.Handouts4Horizontal to arrange up to four slides per page. The horizontal preset controls slide ordering; the page orientation comes from its width and height.
const slides = require("aspose.slides.via.java");
const java = require("java");
let presentation = new slides.Presentation("sample.pptx");
try {
let size = java.newInstanceSync("java.awt.Dimension", 900, 600);
presentation.getNotesSize().setSize(size);
let layout = new slides.HandoutLayoutingOptions();
layout.setHandout(slides.HandoutType.Handouts4Horizontal);
let pdfOptions = new slides.PdfOptions();
pdfOptions.setSlidesLayoutOptions(layout);
presentation.save("handouts.pdf", slides.SaveFormat.Pdf, pdfOptions);
} finally {
presentation.dispose();
}
Changing the page size changes the area available for the handout grid without changing the source slides' dimensions. For handout images, use Presentation.getImages with the handout layout, rather than an individual slide’s image method. In Aspose.Slides, presentation-level handout rendering uses the notes page dimensions, while the individual slide image call does not produce the handout page. See Handout Mode for layout options.
Page Size in Viewers, Export, and Printing
Keep the stored presentation size, the exported page size, and the printed paper size distinct:
- Presentation viewers: A viewer can display or print notes using its own layout rules. If another application saves the file, reopen it and check the dimensions again; that application’s format conversion may normalize them.
- Export formats: The notes and handout PDF examples above use the configured page dimensions. Raster images use integer pixel dimensions and a rendering scale, so fractional point values can be rounded in the image output. Exporting regular slides does not apply the notes page size.
- Printer drivers: Paper selection, automatic rotation, and fit-to-page settings can change the physical output without changing the dimensions stored in the presentation or PDF. For a specific paper size, match the printer settings and inspect the print preview.
FAQ
Can I set the notes size for just one slide?
The notes page size is a presentation-level setting. Individual slides can have different notes content, but this property does not provide a separate page size for each slide.
Why did changing notes orientation not change my slides?
Notes pages and regular slides have independent dimensions. Use the regular slide size settings when you want to resize the slides themselves.
Why does my saved or printed result have a different size?
First reopen the saved presentation and compare its notes dimensions. If those changed, check whether saving or converting the file in another application changed the page settings. If they did not, check the export layout, image scale, viewer settings, and printer paper selection.