The doc to docx conversion somehow gets the table cutoff.
Here is the library information I have in my pom:
com.aspose aspose-words 18.10 jdk16 com.aspose aspose-words 19.10 javadoc AsposeJavaAPI Aspose Java API https://repository.aspose.com/repo/
Could you please ZIP and attach your input DOC file here for testing? We will investigate the issue and provide you information on it.
Hi Tahir, thank you so much for responding me!
The table issue seem to be resolved by updating my original file format. Now I got a new issue, the
Header and footer of my original documentation is gone after the convertion.
I attached my original documentation here, whcich is an htm file. If I use ms word to open it, it contains header and footer, but when I use Aspose java library to convert it,
The result docx file lost the header and footer. I am attaching both htm and docx files here.
Here is how am I doing the converting:
Document doc = new Document(docFile);
//Save the document to docx format
doc.save(docxFile,SaveFormat.DOCX);
Thanks a lot!
Zhishuai
(Attachment dbg.htm is missing)
6017E-Final_MAIN-SECTION–2021-07-23T13-03-14-203.docx (5.97 KB)
@zhishuaizhou_249810
You have attached the DOCX file and there is no header in the document. Please check the attached image. image.png (28.3 KB)
Please share the correct input HTML, problematic and expected output document. We will then test your scenario and provide you more information on it.
Here is the files compressed.
Thanks again!
Zhishuai
(Attachment tmp.rar is missing)
Here is the attachment. My problem is the conversion from .htm to .docx does not keep the header and footer. If I open the .htm file in word, the page header and footer are there.
Thanks!
Zhishuai
tmp.zip (6.47 KB)
We have tested the scenario and managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22530. You will be notified via this forum thread once this issue is resolved.
We apologize for your inconvenience.
As I described in previous posting, I am using html to docx conversion. The converted docx miss all the original headers and footers.
We need to decide if we really will go with Aspose java so I need to try to solve this issue by calling
Aspose java apis.
I am able to use the java api to add the header and footer. But the added footer is not what we want.
We have different footer for different section (each section can have many pages.) We have the page count start from 1 for every beginning of the section. For example, SECTION 1-1, SECTION 1-2 …
when it detects section 2, we will have Section 2-1, Section 2-2 etc.
I assume the following function call should make that happen:
builder.getCurrentSection().getHeadersFooters().linkToPrevious(false);
But as long as I call this function, I would lose all header and footers.
I loop through each Section, I will add a section break and set linkToPrevious to false for each section and move to footer to write the new footer. It does not work. Based on the examples you provided, you can set different footer for even or odd pages. Can we set footer for different section?
Thanks!
@zhishuaizhou_249810
The header of the HTML document is lost after HTML to DOCX conversion. We will will inform you via this forum thread once this issue is resolved.
If you are facing different issue, please share your document and code example to reproduce the issue at our end.
Yes, you can set footer for different sections. The HeaderFooter is a section-level node and can only be a child of Section. There can only be one HeaderFooter or each HeaderFooterType in a Section.
Thanks Tahir!
Can you give me an example on how to setup Footer for each section? That would solve my problem and I will not need to wait for the fix for html to docx header footer lose issue.
I can add the footer though the following loop:
Int SectionId=0;
for (Section sec : doc.getSections()) {
String secFooter = “Section “+SectionId;
SectionId++;
sec.getHeadersFooters().linkToPrevious(false);
PageSetup ps = sec.getPageSetup();
builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
builder.write(secFooter);
builder.write(" - ");
builder.insertField("PAGE", "");
}
But this made all footer and header disappear.
Can you give me some suggestion to make it work? I need some footer like Section 1- 1, Section 1-2, Section 1-3
For Section 2, we will have Section 2-1, Section2-2,…
Thanks!
To ensure a timely and accurate response, please attach the following resources here for testing:
- Your input Word document.
- Please attach the output Word file that shows the undesired behavior.
- Please attach the expected output Word file that shows the desired behavior.
- Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip and upload them.