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

Free Support Forum - aspose.com

ArgumentOutOfRangeException is thrown while saving DOCX to PDF using .NET

Hi all, i got this err when saving the docx document to pdf format. Any one can help me?
Also, i see the page count of the document is different per debug time.
My file
10MB.zip (8.3 MB)

My code:
var document = new Aspose.Words.Document(assetPath);
var PageCount = document.PageCount;

var memoryStream = new MemoryStream();
var pdfSaveOptions = new Aspose.Words.Saving.PdfSaveOptions(){PageCount = 100 /*save first 100 pages*/};
document.Save(memoryStream,  pdfSaveOptions);


System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter ‘pageCount’)

Specified argument was out of the range of valid values. (Parameter ‘pageCount’)
at Aspose.Words.Document. (Int32 , Int32 )
at ​ ( , ​ )
at ​ . ​( )
at . ​( )
at Aspose.Words.Document. ( )
at Aspose.Words.Document.​(Stream , String , SaveOptions )
at Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions)


We have tested the scenario using the latest version of Aspose.Words for .NET 20.9 and have not found the shared issue. So, please use Aspose.Words for .NET 20.9.