HTML export word the image can't vertical center by Aspose.Words

647 views Asked by At

HTML code is as follows:

<div>1.下面各式中正确的是(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;).</div>
<table cellpadding="0" cellspacing="0">
  <tr>
    <td>A.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix126f0.png"></td>
  </tr><tr>
    <td>B.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix126f1.png"></td>
  </tr><tr>
    <td>C.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix126f2.png"></td>
  </tr><tr>
    <td>D.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix126f3.png"></td>
  </tr>
</table>
<div>2.若x
  <img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix1210k.png">=9,x
  <img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix1210l.png">=6,x
  <img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix1210m.png">=4,则x
  <img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix1210n.png">
  的值是(&nbsp;&nbsp;&nbsp; ).
</div>
<table cellpadding="0" cellspacing="0">
  <tr><td>A.24</td></tr>
  <tr><td>B.19</td></tr>
  <tr><td>C.18</td></tr>
  <tr><td>D.16</td></tr>
</table>
<div>3.下列运算正确的是(&nbsp;&nbsp;&nbsp; ).</div>
<table cellpadding="0" cellspacing="0">
  <tr><td>A.(a²b)³=a<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix120ec.png">b³</td></tr>
  <tr><td>B.a³·a²=a<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix120ed.png"></td></tr>
  <tr><td>C.a<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix120ee.png">÷a²=a</td></tr>
  <tr><td>D.a+a=a²</td></tr>
</table>
<div>4.若a>0,且a
  <sup>x</sup>=2,a<sup>y</sup>=3,则a<sup>x+y</sup>的值等于<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u>.
</div>
<div>5.(-a<sup>2</sup>b<sup>2</sup>)<sup>2</sup>·a=___________.</div>
<div>6.下列各式计算正确的是(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</div>
<table cellpadding="0" cellspacing="0">
  <tr><td>A.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix0b9qs.png"></td></tr>
  <tr><td>B.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix0b9qt.png"></td></tr>
  <tr><td>C.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/pix0b9qu.png"></td></tr>
  <tr><td>D.a<sup>4</sup>·a<sup>2</sup>=a<sup>8</sup></td></tr>
</table>
<div>7.下列各式:①a<sup>0</sup>=1;②a<sup>2</sup>•a<sup>3</sup>=a<sup>5</sup>;③2<sup>﹣2</sup>=﹣<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/piwzyrqs.png">;④﹣(3﹣5)+(﹣2)<sup>4</sup>÷8×(﹣1)=0;⑤x<sup>2</sup>+x<sup>2</sup>=2x<sup>2</sup>,其中正确的是(&nbsp;)</div>
<table cellpadding="0" cellspacing="0">
  <tr><td>A.①②③</td></tr>
  <tr><td>B.①③⑤</td></tr>
  <tr><td>C.②③④</td></tr>
  <tr><td>D.②④⑤</td></tr>
</table>
<div>8.下列运算正确的是(&nbsp;&nbsp;&nbsp;)</div>
<table cellpadding="0" cellspacing="0">
  <tr><td>A.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/piww8ars.png"></td></tr>
  <tr><td>B.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/piww8art.png"></td></tr>
  <tr><td>C.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/piww8aru.png"></td></tr>
  <tr><td>D.<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/piww8arv.png"></td></tr>
</table>
<div>9.下列运算正确的是(&nbsp;&nbsp;)</div>
<table cellpadding="0" cellspacing="0">
  <tr><td>A.x<sup>5</sup>+x<sup>5</sup>=x<sup>10</sup></td></tr>
  <tr><td>B.x<sup>5</sup>•x<sup>5</sup>=x<sup>10</sup></td></tr>
  <tr><td>C.(x<sup>5</sup>)<sup>5</sup>=x<sup>10</sup></td></tr>
  <tr><td>D.x<sup>20</sup>÷x<sup>2</sup>=x<sup>1</sup></td></tr>
</table>
<div>10.(1)若m<sup>x</sup>=4,m<sup>y</sup>=3,求m<sup>x+3y</sup>的值<br>(2)、先化简,再求值:<br>已知<img style="VERTICAL-ALIGN: middle" src="/JuniorMiddleSchool/Mat/piwt6hlw.png">,其中x=﹣2,y=﹣0.5.
</div>

The server code:

NodeCollection shapeCollection = _oDoc.GetChildNodes(NodeType.Shape, true);
  Node[] shapes = shapeCollection.ToArray();
  foreach (Shape shape in shapes)
  {
    if (shape.ShapeType.Equals(ShapeType.Image))
    {
      shape.WrapType = WrapType.None;
      shape.BehindText = true;
      shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
      shape.HorizontalAlignment = HorizontalAlignment.Center;
      shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
      shape.VerticalAlignment = VerticalAlignment.Center;
    }
  }

But there is no effect is set up like this.

2

There are 2 answers

0
Zeeshan Mahboob On

You can align Images vertically center with following piece of code:

var doc= new Document();
var vLineHeight=5;
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
   shape.Font.Position = -(shape.Height / 2 - vLineHeight);
}
0
Awais Hafeez On

You can manually get the desired results by doing the following steps:

  1. Open Aspose.Words generated document with MS Word 2013
  2. Click on the paragraph text containing the image
  3. Click the Paragraph dialog box launcher on the Home tab or on the Page Layout tab
  4. Click Asian Typography
  5. Choose Center from the Text Alignment drop down
  6. Click Ok

However, using Aspose.Words, currently it is not possible to vertically align the Shape/Image with the rest of the text in a Paragraph. I suggest you please report the issue in Aspose.Words forum with the html and server codes you mentioned above.

I work with Aspose as Developer Evangelist.