Free Support Forum - aspose.cloud

Headers and Footers page number styles issue in DOCX to HTML and back to DOCX conversion using Aspose.Words REST API

Hello,
I have a problem.
When I upload document to aspose, I have page numbering that alignment by center.
After create new document via API aspose with all parameters first document, I get page numbering alignment by left. I have a question. Can I fix such behavior when create new document?
example.zip (81.9 KB)

@Anatoliy

We will appreciate it if you please share your sample code to create the new document. It will help us to understand the exact scenario and will guide you.

Thank you for your answer.
I use only your api for create documents.
Algorithm:

  1. I upload new document (in example above is first_document.docx)
  2. I get html from apose (I use nodejs) and create html file from this content
  3. I get page setup for all sections from document
  4. I upload this html file to aspose
  5. I create new document from this html file with format .docx (use getDocumentWithFormat function from api (asposewordscloud library))
  6. I do update this document with help page settings that I get when from uploading first document (use updateSectionPageSetup)

@Anatoliy

You may change the formatting of Page number paragraph as following. Hopefully, it will help you to accomplish the task. Please let us know if there is any difference between your requirement and my understanding.

curl -X PUT "https://api.aspose.cloud/v4.0/words/second-document.docx/sections/0/headersfooters/0/paragraphs/0/format?folder=Temp&destFileName=Temp/updated.docx" 
-H "accept: application/json" 
-H "Authorization: Bearer [Access_Token]" 
-H "Content-Type: application/json" 
-H "x-aspose-client: Containerize.Swagger" 
-d "{ "Alignment": "Center", }"

Thanks for your answer.
I will use such request for set paragraph format, but I should set such format that I had in first document.
But when I look format for this paragraph I see alignment value is equal left and it’s not right for me.

@Anatoliy

We have logged a ticket(WORDSCLOUD-1536) to preserve the page number alignment in the conversion. We will keep you updated about the issue resolution in this thread.

Thank you so much:)

1 Like

@Anatoliy

We have investigated the input Word document and noticed that it is using a non-recommended way to position page number fields. They are left-aligned fields with a tab stop. The HTML doesn’t has such a concept as a tab stop, so the piece of information is lost in the conversion. And the consequent conversion to DOCX creates a document with left-aligned page numbers.

To avoid this issue you don’t need to use tab stops to position elements. And instead of it use plain center-aligned page numbers.

Note: the step should be done for each section of the document.

@tilal.ahmad,

Thank you for your reply.
Unfortunately, the structure of the input document is out of my control. The user of my application is allowed to upload custom Word documents and templates so I can’t guarantee that they won’t contain non-recommended elements or unexpected combinations of nodes. I clearly understand that it’s nearly impossible to convert DOCX to HTML and back preserving the content in full. But maybe we can come up with a workaround that will satisfy my customers. Is there an API method that would allow me to obtain all warnings and errors thrown during document conversion? For example, if some element of the source document cannot be properly converted to a corresponding element of the output file, this method would report a human-readable warning describing the conversion issue. It also would be helpful to assign some unique identifiers to warnings and errors of different types so I could use them in my code. If the current version of the cloud API doesn’t provide such a method, could you please create an appropriate feature request?

Thank you.

1 Like

@Anatoliy

Thanks for your feedback. We are looking into your requirement and suggestion. We will update you soon.