Free Support Forum - aspose.com

Split document's pages into separate document using .NET

Hi,

I have a need to split a document out by page number, similar to when you print a range. For example I would like to create a new document out of page 10-20 of a input document. Is there a way to do this?


Thanks,
Ronnie

Hi Ronnie,

Thanks for your query.Word
document is flow document and does not contain any information about
its layout into lines and pages. Therefore, technically there is no
“Page” concept in Word document.

Aspose.Words uses our own Rendering Engine to layout documents into pages. And we have plans to expose layout information. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is supported.


The workaround for your scenario is, first convert doc file to pdf and then convert pdf to doc. Please see the code below.


Document doc = new Document(MyDir + "SplitTest.docx");

PdfSaveOptions options = new PdfSaveOptions();

options.SaveFormat = SaveFormat.Pdf;

// Set how many pages to render

options.PageCount = 3;

// The first page to render (index is 0-based).

options.PageIndex = 1;

MemoryStream stream = new MemoryStream();

doc.Save(stream, options);

Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(stream);

pdf.Save(MyDir + "out.doc", Aspose.Pdf.SaveFormat.Doc);

The issues you have found earlier (filed as WORDSNET-2978) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(95)