DOCX to HTML Conversion has different CSS margin styles using Aspose.Words Cloud API

Hi, I have a question. I want to know how do you build html code from docx file? Sometimes I get html code with different margin styles constructions. For example: I can get margin-top: 10pt; margin-bottom: 5pt; I can get margin: 10pt 0 5pt; I want to know how do you build margins styles in html code?

BR,
Anatoliy

@Anatoliy,

Thanks for your inquiry. We will appreciate it if you please share your documents showing different margin styles. It will help us to address your query exactly.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Style-Type" content="text/css" /><meta name="generator" content="Aspose.Words for .NET 19.3" /><title></title></head><body><div><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">ACTION BY </span><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">WRITTEN CONSENT</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">OF THE STOCKHOLDERS OF</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">XYZ</span><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">, INC.</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold">DATE</span></p><p style="margin-top:0pt; margin-bottom:0pt; text-indent:36pt; text-align:justify; line-height:200%; font-size:12pt"><span style="font-family:'Times New Roman'">Pursuant to Section 228 of the Delaware General Corporation Law and Section 2.11 of the Bylaws of </span><span style="font-family:'Times New Roman'">XYZ</span><span style="font-family:'Times New Roman'">, </span><span style="font-family:'Times New Roman'">Inc</span><span style="font-family:'Times New Roman'">., </span><span style="font-family:'Times New Roman'">a Delaware corporation (the “</span><span style="font-family:'Times New Roman'; font-weight:bold; font-style:italic">Company</span><span style="font-family:'Times New Roman'">”), the undersigned stockholders of the Company hereby take the following actions and adopt the following r</span><span style="font-family:'Times New Roman'">esolutions by written consent</span><span style="font-family:'Times New Roman'">:</span></p><ol type="1" style="margin:0pt; padding-left:0pt"><li style="margin-bottom:12pt; text-align:justify; font-family:'Times New Roman'; font-size:12pt; font-weight:bold; list-style-position:inside; -aw-list-padding-sml:22pt"><span style="font:7pt 'Times New Roman'; -aw-import:ignore">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><span style="text-decoration:underline">Certificate of Incorporation</span><span>.</span></li></ol><p style="margin:0pt 36pt 12pt; text-align:justify; line-height:12pt"><span style="font-family:'Times New Roman'; font-size:12pt; font-weight:bold; text-decoration:underline">RESOLVED</span><span style="font-family:'Times New Roman'; font-size:12pt; font-weight:bold">:</span><span style="font-family:'Times New Roman'; font-size:12pt; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'; font-size:12pt">That a copy of the Certificate of Incorporation of the Company as filed with the Delaware Secretary of State and bearing the file stamp and certification of the Delaware Secretary of State, and attached hereto as </span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">Exhibit</span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">&#xa0;</span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">A</span><span style="font-family:'Times New Roman'; font-size:12pt">, is hereby accepted and ratified.</span></p><ol start="2" type="1" style="margin:0pt; padding-left:0pt"><li style="margin-bottom:12pt; text-align:justify; font-family:'Times New Roman'; font-size:12pt; font-weight:bold; list-style-position:inside; -aw-list-padding-sml:22pt"><span style="font:7pt 'Times New Roman'; -aw-import:ignore">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><span style="text-decoration:underline">Bylaws</span><span>.</span></li></ol><p style="margin:0pt 36pt 12pt; text-align:justify; line-height:12pt"><span style="font-family:'Times New Roman'; font-size:12pt; font-weight:bold; text-decoration:underline">RESOLVED</span><span style="font-family:'Times New Roman'; font-size:12pt; font-weight:bold">:</span><span style="font-family:'Times New Roman'; font-size:12pt; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'; font-size:12pt">That a copy of the Bylaws of the Company as adopted by the </span><span style="font-family:'Times New Roman'; font-size:12pt">Incorporator of the Company</span><span style="font-family:'Times New Roman'; font-size:12pt"> and approved by the Board of Directors of the Company, and attached hereto as </span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">Exhibit</span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">&#xa0;</span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">B</span><span style="font-family:'Times New Roman'; font-size:12pt">, is hereby accepted and ratified.</span></p><ol start="3" type="1" style="margin:0pt; padding-left:0pt"><li style="margin-bottom:12pt; text-align:justify; font-family:'Times New Roman'; font-size:12pt; font-weight:bold; list-style-position:inside; -aw-list-padding-sml:22pt"><span style="font:7pt 'Times New Roman'; -aw-import:ignore">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><span style="text-decoration:underline">Adoption of </span><span style="text-decoration:underline">YEAR</span><span style="text-decoration:underline"> Stock Plan</span><span>.</span></li></ol><p style="margin:0pt 36pt 12pt; text-align:justify; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">RESOLVED</span><span style="font-family:'Times New Roman'; font-weight:bold">:</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">That the </span><span style="font-family:'Times New Roman'">YEAR</span><span style="font-family:'Times New Roman'"> Stock Plan (the “</span><span style="font-family:'Times New Roman'; font-weight:bold; font-style:italic">Plan</span><span style="font-family:'Times New Roman'">”), in substantially the form attached hereto as </span><span style="font-family:'Times New Roman'; text-decoration:underline">Exhibit</span><span style="font-family:'Times New Roman'; text-decoration:underline">&#xa0;</span><span style="font-family:'Times New Roman'; text-decoration:underline">C</span><span style="font-family:'Times New Roman'">,</span><span style="font-family:'Times New Roman'; font-weight:bold"> </span><span style="font-family:'Times New Roman'">is h</span><span style="font-family:'Times New Roman'">ereby adopted and approved and </span><span style="font-family:'Times New Roman'">RESERVED SHARES</span><span style="font-family:'Times New Roman'"> shares of the Company’s Common Stock are hereby reserved for issuance thereunder.</span></p><ol start="4" type="1" style="margin:0pt; padding-left:0pt"><li style="margin-bottom:12pt; text-align:justify; font-family:'Times New Roman'; font-size:12pt; font-weight:bold; list-style-position:inside; -aw-list-padding-sml:22pt"><span style="font:7pt 'Times New Roman'; -aw-import:ignore">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><span style="text-decoration:underline">Indemnification Agreement</span><span>.</span></li></ol><p style="margin:0pt 36pt 12pt; text-align:justify; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">RESOLVED</span><span style="font-family:'Times New Roman'; font-weight:bold">:</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">That the Company may</span><span style="font-family:'Times New Roman'"> enter into Indemnification Agreements with its </span><span style="font-family:'Times New Roman'">present and future </span><span style="font-family:'Times New Roman'">officers and directors in substantially the form attached hereto as </span><span style="font-family:'Times New Roman'; text-decoration:underline">Exhibit</span><span style="font-family:'Times New Roman'; text-decoration:underline">&#xa0;</span><span style="font-family:'Times New Roman'; text-decoration:underline">D</span><span style="font-family:'Times New Roman'">, tog</span><span style="font-family:'Times New Roman'">ether with any changes to such a</span><span style="font-family:'Times New Roman'">greements determined by the </span><span style="font-family:'Times New Roman'">Chief Executive Officer</span><span style="font-family:'Times New Roman'"> of the Company to be desirable.</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">Such determination shall be conclusively evidenced by such officer’s execution and delivery of a definitive Indemnification Agreement.</span></p><p style="margin:0pt 36pt 12pt; text-align:justify; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">RESOLVED FURTHER</span><span style="font-family:'Times New Roman'; font-weight:bold">:</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">That the officers of the Company are authorized to execute such Indemnification Agreements on behalf of the Company and to take </span><span style="font-family:'Times New Roman'">whatever action they deem necessary to perform the Company’s obligations under such agreements.</span></p><ol start="5" type="1" style="margin:0pt; padding-left:0pt"><li style="margin-bottom:12pt; text-align:justify; font-family:'Times New Roman'; font-size:12pt; font-weight:bold; list-style-position:inside; -aw-list-padding-sml:22pt"><span style="font:7pt 'Times New Roman'; -aw-import:ignore">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><span style="text-decoration:underline">[</span><span style="text-decoration:underline">S Corporation Election</span><span style="font-weight:normal">.</span></li></ol><p style="margin-top:0pt; margin-left:36pt; margin-bottom:12pt; text-align:justify; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">RESOLVED</span><span style="font-family:'Times New Roman'; font-weight:bold">:</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">That the undersigned stockholders consent to the Company’s election to </span><span style="font-family:'Times New Roman'">be taxed as an </span><span style="font-family:'Times New Roman'">“</span><span style="font-family:'Times New Roman'">S corporation</span><span style="font-family:'Times New Roman'">”</span><span style="font-family:'Times New Roman'"> under Section 1362(a) of the Internal Revenue Code and Section 23801(a) of the California Tax Code.</span></p><p style="margin:0pt 36pt 12pt; text-align:justify; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">RESOLVED FURTHER</span><span style="font-family:'Times New Roman'; font-weight:bold">:</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">That the officers of this Company are hereby authorized and directed to solicit each stockholder’s consent to such election and to prepare, execute and file Internal Revenue Service Form 2553, together with a statement by each stockholder consenting to this election, and to do all other acts that may be required to make such elections effective</span><span style="font-family:'Times New Roman'">.</span><span style="font-family:'Times New Roman'">]</span></p><ol start="6" type="1" style="margin:0pt; padding-left:0pt"><li style="margin-bottom:12pt; text-align:justify; font-family:'Times New Roman'; font-size:12pt; font-weight:bold; list-style-position:inside; -aw-list-padding-sml:22pt"><span style="font:7pt 'Times New Roman'; -aw-import:ignore">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span><span style="text-decoration:underline">Omnibus Resolution</span><span>.</span></li></ol><p style="margin:0pt 36pt 24pt; text-align:justify; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">RESOLVED</span><span style="font-family:'Times New Roman'; font-weight:bold">:</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">That each of the officers of the Company is authorized and directed, on behalf of the Company, to execute and deliver any agreement, documents or instrument pursuant to or necessary to be delivered in connection with the</span><span style="font-family:'Times New Roman'"> foregoing resolutions</span><span style="font-family:'Times New Roman'">, with such modifications or amendments thereto as may be approved by the officer or officers executing and delivering the same, such approval to be conclusively evidenced by the execution and delivery thereof.</span></p><p style="margin-top:0pt; margin-bottom:0pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-style:italic">[Signature Page Follows]</span></p><br style="page-break-before:always; clear:both" /><p style="margin-top:0pt; margin-bottom:24pt; text-indent:36pt; text-align:justify; line-height:200%; font-size:12pt"><span style="font-family:'Times New Roman'">This a</span><span style="font-family:'Times New Roman'">ction by </span><span style="font-family:'Times New Roman'">w</span><span style="font-family:'Times New Roman'">ritten </span><span style="font-family:'Times New Roman'">c</span><span style="font-family:'Times New Roman'">onsent </span><span style="font-family:'Times New Roman'">of the stockholders of the Company shall be effective as of the date the Company receives the requisite consent of the Company’s stockholders.</span><span style="font-family:'Times New Roman'; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'">This action by written consent </span><span style="font-family:'Times New Roman'">may be executed in </span><span style="font-family:'Times New Roman'">any number of </span><span style="font-family:'Times New Roman'">counterparts, each of which shall be deemed an original and all of which together shall constitute one instrument.</span><span style="font-family:'Times New Roman'"> </span><span style="font-family:'Times New Roman'">This </span><span style="font-family:'Times New Roman'">action by </span><span style="font-family:'Times New Roman'">written consent </span><span style="font-family:'Times New Roman'">shall </span><span style="font-family:'Times New Roman'">be filed in the mi</span><span style="font-family:'Times New Roman'">nute book of the Company.</span></p><p style="margin-top:0pt; margin-bottom:24pt; text-indent:36pt; text-align:justify; line-height:200%; font-size:12pt"><span style="font-family:'Times New Roman'; -aw-import:ignore">&#xa0;</span></p><p style="margin-top:0pt; margin-left:216pt; margin-bottom:0pt; font-size:12pt"><span style="font-family:'Times New Roman'; text-transform:uppercase">[name]</span></p><p style="margin-top:0pt; margin-left:216pt; margin-bottom:0pt; font-size:12pt"><span style="font-family:'Times New Roman'; text-transform:uppercase; -aw-import:ignore">&#xa0;</span></p><p style="margin-top:0pt; margin-left:216pt; margin-bottom:0pt; font-size:12pt"><span style="width:252pt; font-family:'Lucida Console'; font-size:10pt; display:inline-block; -aw-font-family:'Times New Roman'; -aw-tabstop-align:right; -aw-tabstop-leader:line; -aw-tabstop-pos:468pt">_________________________________________</span></p><p style="margin-top:0pt; margin-left:216pt; margin-bottom:0pt; font-size:12pt"><span style="font-family:'Times New Roman'">(</span><span style="font-family:'Times New Roman'">signature</span><span style="font-family:'Times New Roman'">)</span></p><p style="margin-top:12pt; margin-left:216pt; margin-bottom:24pt; font-size:12pt"><span style="font-family:'Times New Roman'">Date of Signature:</span><span style="font-family:'Times New Roman'"> </span><span style="width:161.03pt; font-family:'Lucida Console'; font-size:10pt; display:inline-block; -aw-font-family:'Times New Roman'; -aw-tabstop-align:right; -aw-tabstop-leader:line; -aw-tabstop-pos:468pt">__________________________</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><br style="page-break-before:always; clear:both" /><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">EXHIBIT A</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">CERtiFICATE OF INCORPORATION</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><br style="page-break-before:always; clear:both" /><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">EXHIBIT B</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">BYLAWS</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><br style="page-break-before:always; clear:both" /><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline">EXHIBIT C</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">YEAR</span><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase"> Stock plan</span></p></div><br style="page-break-before:always; clear:both; mso-break-type:section-break" /><div><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-decoration:underline; text-transform:uppercase">exhibit d</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase">FORM OF INDEMNIFICATION AGREEMENT</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:12pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase; -aw-import:ignore">&#xa0;</span></p><p style="margin-top:0pt; margin-bottom:12pt; text-align:center; page-break-inside:avoid; page-break-after:avoid; font-size:8pt"><span style="font-family:'Times New Roman'; font-weight:bold; text-transform:uppercase; -aw-import:ignore">&#xa0;</span></p></div></body></html>

Here, html code that I get after parse my .docx file. The html code contain the following structures “margin-top:0pt; margin-bottom:12pt;” or “margin:0pt;” or “margin:0pt 36pt 12pt;” or “margin-top:0pt; margin-left:36pt; margin-bottom:12pt;” or “margin-top:0pt; margin-left:216pt; margin-bottom:0pt;” and anothers. I would like how does the structure choice depend on the style parameters in .docx file?

BR,
Anatoliy

@Anatoliy,

Thanks for your feedback. But I am afraid you have not shared your input docx files. As requested earlier, please share your input word documents those return different margins (10pts and 0pt) in resultant HTML. After checking the structure of the documents, we can guide you exactly.

SLSForm - Organizational Stockholders Consent.docx - input docx file

@Anatoliy

I am afraid I am unable to find any document. Please double check and share the document. Please note you can zip the Word documents and attach here.

SLSForm - Organizational Stockholders Consent.zip (23.4 KB)

Here input docx file

@Anatoliy

Thanks for sharing the sample document. We are looking into your query and will update you shortly.

@Anatoliy,

Please note while converting DOCX to HTML default value of ExportPageMargins property is false and API does not preserve the page margins. If you want to preserve page margins in resultant HTML, you need to use SaveAs API with detailed HtmlSaveOptions as following. Hopefully it will help you to accomplish the task.

curl -X PUT "https://api.aspose.cloud/v4.0/words/SLSForm%20-%20Organizational%20Stockholders%20Consent.docx/saveAs"
-H "accept: application/json"
-H "authorization: Bearer [Access_Token]"
-H "Content-Type: application/json"
-d "{ "SaveFormat":"html", "FileName":"TestHtml_Margins.html", "ExportPageMargins": true}"

Thank you for you answer. But my question not about it. I want to know how your api generate html with different margins. In what case we get as result margin with 4 values or 3 values, when we get as result margin with 2 values or 1 values, when we get ‘margin-left, margin-right, margin-top and margin-bottom values’ and not margin with different count of values?

BR,
Anatoliy

@Anatoliy,

Thanks for additional information. I am looking into the requirement and will share the details shortly.

@Anatoliy

I am afraid there is no simple rule. Aspose.Words calculates "margin-xxx" values of each element. Then removes styles that duplicate values applied from other sources (the default stylesheet or the stylesheet generated by Aspose.Words itself). Then tries to combine individual "margin-xxx" declarations to shorthand "margin" declarations. And then writes the result to the document.

In most cases "margin-left" and "margin-right" are exported from ParagraphFormat.LeftIndentLeftIndent and ParagraphFormat.RightIndentRightIndent. But they may be adjusted if HtmlSaveOptions.AllowNegativeIndent=false (which is the default) in order to prevent paragraph text from overflowing the browser window and being clipped.

Also, we adjust these values for list item paragraphs that are being exported to native HTML list items (<li> elements). This is required because HTML list items have their own default margins and paddings that affect positioning of list item text.

Please check some margin examples below, how Aspose.Words calculates the margins and write in HTML.

margin:72pt: all four margins are same because page margin is 1 inch for each side and exported because of the "ExportPageMargins=true" option.

margin:0pt 36pt 12pt: marign top=0, left=right=36 and bottom=12, margins of of the corresponding paragraph.

margin-top:0pt; margin-bottom:12pt: ParagraphFormat.LeftIndentLeftIndent and ParagraphFormat.RightIndent values are zero. Aspose.Words didn’t write “margin-left:0” and “margin-right:0” because it had calculated that these are applied to this <p> element by default. We try to avoid writing CSS that would duplicate styles from other sources (for example, from the default CSS stylesheet used by browsers)

margin:0pt: <ol> is needed to zero vertical margins of this element. By default, <ol> elements have 1em top and bottom margins. "margin-top:0; margin-bottom:0" would do here, too. But we write "margin:0pt" for historical reasons.

However, can you please tell us why you need the margin calculation? So we can guide you exactly.

Thank you for your answer.
I try selected different styles for different paragraphs (these data I get from aspose - format by each paragraph) and match them with styles that I get from aspose in html, but I receive fail in most cases because the margins that I take from the paragraph formats do not match the margins that come in html.
For example:

fragment html:

<p style="margin:0pt 36pt 12pt; text-align:justify; line-height:12pt"><span style="font-family:'Times New Roman'; font-size:12pt; font-weight:bold; text-decoration:underline">RESOLVED</span><span style="font-family:'Times New Roman'; font-size:12pt; font-weight:bold">:</span><span style="font-family:'Times New Roman'; font-size:12pt; -aw-import:spaces">&#xa0; </span><span style="font-family:'Times New Roman'; font-size:12pt">That a copy of the Certificate of Incorporation of the Company as filed with the Delaware Secretary of State and bearing the file stamp and certification of the Delaware Secretary of State, and attached hereto as </span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">Exhibit</span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">&#xa0;</span><span style="font-family:'Times New Roman'; font-size:12pt; text-decoration:underline">A</span><span style="font-family:'Times New Roman'; font-size:12pt">, is hereby accepted and ratified.</span></p>```

fragment json describing paragraph format

{
“id”: 1468,
“paragraph_id”: 1273,
“add_space_between_far_east_and_alpha”: true,
“add_space_between_far_east_and_digit”: true,
“alignment”: “Justify”,
“bidi”: false,
“drop_cap_position”: “None”,
“first_line_indent”: 0,
“keep_together”: false,
“keep_with_next”: false,
“left_indent”: 36,
“line_spacing”: 12,
“line_spacing_rule”: “AtLeast”,
“lines_to_drop”: 0,
“no_space_between_paragraphs_of_same_style”: false,
“outline_level”: “BodyText”,
“page_break_before”: false,
“right_indent”: 36,
“space_after”: 12,
“space_after_auto”: false,
“space_before”: 0,
“space_before_auto”: false,
“style_identifier”: “User”,
“style_name”: “Resolution”,
“suppress_auto_hyphens”: false,
“suppress_line_numbers”: false,
“Widow_control”: true,
“created_at”: “2019-08-23T06:45:19.556Z”,
“updated_at”: “2019-08-23T06:45:19.556Z”
}```

I usually build such mapping:
right_indent -> margin-right,
left_indent -> margin-left,
space_before -> margin-top,
space_after -> margin-bottom

In result I get margin-right: 36pt;margin-left: 36pt;margin-top: 0pt; margin-bottom: 0pt; and it not equal margin:0pt 36pt 12pt;

@Anatoliy

Can you please confirm how you are getting margin-bottom. As I see it is 12 pt in HTML, Word document and paragraph format as well.

Sorry, I made typo, here I don’t have question, but my question why one margin (and not 4 margins: margin-right: 36pt;margin-left: 36pt;margin-top: 0pt; margin-bottom: 12pt; ), I get fail because different strings.

BR,
Anatoliy

@Anatoliy

Thanks for the additional details. You know margin is a shorthand property of margin-top, margin-right, margin-bottom and margin-left. So where possible, we are using it to shorten the code. For example margin:72t and margin:0pt 36pt 12pt.

I understood, but you have algorithm that set margin short or margins with specify side. I’d like to use like algorithm for my tasks.

BR,
Anatoliy

@Anatoliy,

As already stated above, Aspose.Words calculates all “margin-xxx” values, but writes only those that don’t duplicate values inherited from other sources. If some of the written values are same and can be represented with the shorthand property “margin”, Aspose.Words uses the shorthand. Otherwise, it writes individual properties.

Since individual calculated margin values depend on the structure of the document, there is no simple rule like “always write shorthand for lists” or “don’t write horizontal margins for paragraphs”.

Furthermore, in general you cannot match the CSS and Paragraph formatting. Because there is no 1-to-1 mapping between paragraph formatting and CSS styles. We have to adjust the CSS in certain cases in order to preserve the look of the document and compensate for differences between HTML and MS Word rendering rules.