Set Page Size and Page Orientation for Word Document Using Java

import com.spire.doc.*;
import com.spire.doc.documents.*;

public class WordPageSetup {
public static void main(String[] args) throws Exception {
//Load the sample document
Document doc= new Document();
doc.loadFromFile("Oscar Wilde.docx");
//Get the first section
Section section = doc.getSections().get(0);
//Set the page size
section.getPageSetup().setPageSize(PageSize.A3 );
//Set the page orientation
//Save the document to file




Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Learn to Program: Writing Code

Learning Python 10 minutes a day #19

Why you should try Jira to manage your GitHub repos

How to integrate Google Authenticator in ASP.Net MVC Project?

Iterative vs Recursive vs Tail-Recursive in Golang

7 Must-Have Skills to Become an Outstanding Software Developer

Digging Deeper: our software developers’ favorite projects

Help us solve the developing world’s energy needs with software

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

HTML WebApp using Spring Boot

Exceptions Handling in Java..

Dynamic JSON Translator

Java Project Structure.

Refreshing expired tokens elegantly in Spotify API with Spring Boot and AOP