Split Word's pages into separate documents using Java

Thank You Very Much

I modify my code, so it import the HTML file from disk, not retrieving from URL

Here is the code :

String paramFileName = "testing";
Document doc = new Document("/home/yanidp/workspace/Nota Dinas Intern.html");

System.out.println("Page Count Before splitting: " + doc.getPageCount());

LayoutCollector layoutCollector = new LayoutCollector(doc);
doc.updatePageLayout();

DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);

Document pageDoc = splitter.GetDocumentOfPage(1);
System.out.println("Page Count After splitting: " + pageDoc.getPageCount());
response.setContentType("application/vnd.ms-word");

response.setHeader("content-disposition", "inline; filename=" + paramFileName);
ServletOutputStream outputStream = response.getOutputStream();

pageDoc.save(outputStream, SaveFormat.DOCX);

The page Count after splitting is same as before splitting.
I attached the html file in the attachment

Best Regards

Hi,

Thanks for your inquiry. Please make sure that you’re using the latest version of Aspose.Words 14.8.0 on your end:
https://releases.aspose.com/words/java

Also, please try attached class files. Hope, this helps.

Best regards,

Thank you again.

It works. I really appreciate your fast response. It help me a lot. You guys are awesome

Best Regards

Hello, I want to ask again

When i upgrade to new version, the font change. Why this happen ?

This code seems not work

FontSettings.setDefaultFontName("Arial");

Regards

Hi there,

Thanks for your inquiry. Please use FontSettings.setDefaultFontName method when you want to convert your document to PDF, XPS or images. If you are converting your document to Pdf/XPS, please share your input document along with code which you are using. We will investigate the issue and provide you more information.

1 Like

I convert the html into word. I use the latest version of aspose. Before i used the previous version, The result document’s font is Arial, but when i upgrade the version of aspose, The font changed to Times New Rowman. This is the code when converting to docx:
response.setContentType(“application/vnd.ms-word”);

response.setHeader("content-disposition", "inline; filename=" + paramFileName);
outputStream = response.getOutputStream();
FontSettings.setDefaultFontName("Arial");
newdoc.save(outputStream, SaveFormat.DOCX);

Regards

Hi there,

Thanks for your inquiry. In your case, you do not need to use FontSettings.setDefaultFontName method. We need following detail to test this issue at our side. please share this detail for investigation purposes.

  • Please attach your input Word document.
  • Please create a standalone/runnable simple Java application that demonstrates the code (Aspose.Words code) you used to generate your output document
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach your target Word document showing the desired behavior. You can use Microsoft Word to create your target Word document. I will investigate as to how you are expecting your final document be generated like.

As soon as you get these pieces of information to us we’ll start our investigation into your issue.

Thank You for your reply

The issue is resolved. The cause is wrong external css url in href.

I want to ask another matter. How to upgrade the aspose word license ? My license was last updated almost 2 years ago. Can i upgrade the license or buy the new one ?

Best Regards

Hi Ano,

I have posted your request to our sales team in the purchase forum here: http://www.aspose.com/community/forums/583809/showthread.aspx#583809

Thanks,

Hi Tahir

I want ask again about page splitter

I am using aspose 14.10. I want to get the second page of the document. The outcome document did not result as it sholud be.

I attached the source document and the destination (result) document.

Regards

Hi,

Thanks for your inquiry. The content is not moved to second page in output document when running the code from this post using Aspose.Words for Java 14.11.0 on my side. Please see attached output document and other resources. I hope, this helps.

Best regards,