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 4.0.5.0.

Hi,
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.