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

Free Support Forum - aspose.com

Split document by page using pagesplitter.zip

Hi there


I am trying Split document by page and save each page into images jpg y already read in the forums some examples for resolve the same problem i download the library pagesplitter.zip posted in the forum and the next code i found it here Split Word's pages into separate documents using Java

Document doc = new Document(“C:\Temp\in.doc”);<o:p></o:p>

LayoutCollector layoutCollector = new LayoutCollector(doc);<o:p></o:p>

doc.updatePageLayout();<o:p></o:p>

DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);<o:p></o:p>

Document pageDoc = splitter.GetDocumentOfPage(5);<o:p></o:p>

pageDoc.save(“C:\Temp\out.doc”);


The code run perfectly but it didn´t run well if i specific a page of document splitter Document pageDoc = splitter.GetDocumentOfPage(5); only takes de first page of the document always even if i chage GetDocumentOfPage to 1 or 2… etc


My doubts are :

1) how can i know how many pages have the document?

2) how i can specify the number of page in the document that I want convert?



Thanks in advance for your help!

Hi,

1. You can use Document.PageCount property to get number of pages.

2. You can use SaveOptions to specify the page index you want to convert.

Can you please share your source document and to which format you want to export?

Best Regards,

Hi,


Thanks for your inquiry. I have attached a new version of “pagesplitter” here with this post. I hope, this helps.

Best regards,
Thanks for your answer, i alrady update the libray pagesplitter, but i have a problem it works perfectly with some documents , but with others there is an error, I left you my code and the error, also the document that i can´t convert




Thanks in advance for your help!

Hi,


Thanks for your inquiry. Please change line 80 of “SectionSplitter.java” as follows:

if (prevParagraph != null && prevSection != null) {

I hope, this helps.

Best regards,