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

Free Support Forum - aspose.com

Aspose Word Save Page Range to Stream

Is there a way to save a page range to a memory stream? For example, I want to load a document, and save pages 5-10 as a PDF to a memory stream. The code below works to load all pages of the document but I’m not sure how to select the page range.


sDocPath = Server.MapPath("…") & “\scripts_questionbank\assessments\FileName.docx”)
Dim dstStream As New MemoryStream()
doc.Save(dstStream, Aspose.Words.SaveFormat.Pdf)

Thanks

Hi Maxime,


Thanks for your inquiry. Please use PdfSaveOptions.PageIndex property to get or set the 0-based index of the first page to save and use PdfSaveOptions.PageCount property to get or set the number of pages to save.

Please use following code example to achieve your requirements. Hope this helps you.

<span style=“font-size:10.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>Dim<span style=“font-size:10.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman””> doc As
New Document(MyDir & “Rendering.doc”)<o:p></o:p>

Using stream As Stream = File.Create(MyDir & "Out.pdf")

Dim options As New PdfSaveOptions()

options.PageIndex = 4

options.PageCount = 10

doc.Save(stream, options)

End Using