We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting PageSetup.PaperSize to Custom causes an exception

The following code produces “Object reference not set to an instance of an object.” exception:

Dim builder As Aspose.Words.DocumentBuilder = New Aspose.Words.DocumentBuilder()
builder.PageSetup.PageWidth = 100
builder.PageSetup.PageHeight = 100
builder.PageSetup.PaperSize = Aspose.Words.PaperSize.Custom

Any advice on how to use custom paper sizes would be greatly appreciated.

Thank you in advance.

P.S. I am using Aspose.Words for NET 2.0. Version is

Thank you for reporting the problem to us. I have logged it as #1474. Meanwhile, just don’t set PaperSize to Custom because this value is automatically set when you explicitly specify page dimensions.

Thank you, Dima.

We have released a new version of Aspose.Words that contains a fix for your issue.
The new version of Aspose.Words is available for download from here.
Best regards.