The table has been distortion when when I convert it to image

I use aspose.word for .net. The table has been distortion when I convert it to image.The following is my code:

private void DoSHBS(DocumentBuilder builder, string strSPJson)
{
//说明此文书有审批书签并且 还传入了审批的数据
//生成审批内容
//审批内容在此标签中增加表格

        DataSet ds_sp = JsonToDataTable.Json2Dtb(strSPJson);
        DataTable dt_sp = ds_sp.Tables[0];//有几行就说明有几个人审批生成的表格的行数就乘2

        builder.MoveToDocumentStart();//MoveToBookmark("PO_SHBS");
        builder.StartTable();//开始画Table    
        //Table table = builder.StartTable();
        //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
        builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; // RowAlignment.Center;    
        builder.RowFormat.Height = 20;

        //添加列头  
        int cellNum = dt_sp.Rows.Count * 2;//计算画单元格的总数量
        bool sfhb = false;//判断是否需要垂直合并单元格
        int dtRowNum = 0;
        for (int j = 1; j <= cellNum; j++)
        {
            if (j % 2 == 0)
            {

                sfhb = true;
            }
            else
            {
                sfhb = false;
            }
            int dtRow = (j - 1) % 2;

            if (dtRow == 0)
            {
                dtRowNum = (j - 1) / 2;
            }
            #region 第一个单元格***************************************************
            builder.InsertCell();
            //Table单元格边框线样式  
            builder.CellFormat.Borders.LineStyle = LineStyle.Single;
            builder.CellFormat.Borders[BorderType.Left].LineStyle = LineStyle.None;
            builder.CellFormat.FitText = true;//需要设置一下这个值
            //Table此单元格宽度  
            builder.CellFormat.Width = 40;
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);

            //此单元格中内容垂直对齐方式  
            builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
            //builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.None;
            //builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First;
            //字体大小  
            builder.Font.Size = 14;
            //是否加粗  
            //builder.Bold = true;
            if (sfhb)
            {
                //合并单元格
                builder.CellFormat.VerticalMerge = CellMerge.Previous;
            }
            else
            {
                builder.CellFormat.VerticalMerge = CellMerge.First;
                string splx = dt_sp.Rows[dtRowNum]["splx"].ToString();
                if (splx == "1")
                {
                    builder.Write("审核");
                }
                else if (splx == "2")
                {
                    builder.Write("审批");
                }
            }
            //向此单元格中添加内容  
            //builder.Write("ceshi");
            #endregion*************************************************************

            #region 第二个单元格***************************************************
            builder.InsertCell();
            //Table单元格边框线样式  
            builder.CellFormat.Borders.LineStyle = LineStyle.Single;
            //Table此单元格宽度  
            builder.CellFormat.Width = 180;
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(180);
            //此单元格中内容垂直对齐方式  
            builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Top;//垂直居中对齐
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//水平居中对齐
            //builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.None;
            //builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
            //字体大小  
            builder.Font.Size = 14;
            //是否加粗  
            //builder.Bold = true;
            if (sfhb)
            {
                //合并单元格
                builder.CellFormat.VerticalMerge = CellMerge.Previous;
            }
            else
            {
                builder.CellFormat.VerticalMerge = CellMerge.First;
                string spnr = dt_sp.Rows[dtRowNum]["spnr"].ToString();
                builder.Write(spnr);
            }
            //向此单元格中添加内容  
            //builder.Write("ceshi");
            #endregion*************************************************************

            #region 第三个单元格***************************************************
            builder.InsertCell();
            //Table单元格边框线样式  
            builder.CellFormat.Borders.LineStyle = LineStyle.Single;
            builder.CellFormat.Borders[BorderType.Right].LineStyle = LineStyle.None;
            //Table此单元格宽度  
            builder.CellFormat.Width = 45;
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(45);
            //此单元格中内容垂直对齐方式  
            builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
            // builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.None;
            builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
            //字体大小  
            builder.Font.Size = 14;
            //是否加粗  
            //builder.Bold = true;
            if (sfhb)
            {
                builder.RowFormat.Height = 20;
                builder.CellFormat.Borders[BorderType.Top].LineStyle = LineStyle.None;
                string spsj = dt_sp.Rows[dtRowNum]["spsj"].ToString();
                builder.Write(ConvertDateToString(spsj));
            }
            else
            {
                builder.RowFormat.Height = 40;
                builder.CellFormat.Borders[BorderType.Bottom].LineStyle = LineStyle.None;
                string sxqm = dt_sp.Rows[dtRowNum]["sxqm"].ToString();
                builder.Write(sxqm);
            }
            //向此单元格中添加内容  
            //builder.Write("ceshi");
            #endregion*************************************************************
            builder.EndRow();
        }
        builder.EndTable();
    }

下面代码是word转换成图片
public void WordToImage(string wordPath)
{
string url = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString());//获取程序根目录
string docPath = string.Empty;
docPath = url + “\LawBook\” + wordPath;
Document doc = new Document(docPath);
if (doc != null)
{
ImageSaveOptions iso = new ImageSaveOptions(SaveFormat.Jpeg);
iso.Resolution = 128;
iso.PrettyFormat = true;
string[] arr_path = wordPath.Split(’\’);
string path = string.Empty;
if (arr_path.Length > 1)
{
path = url + “\WordToImage\” + arr_path[0] + “\” + arr_path[1];
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}

            //NodeCollection nc = doc.GetChildNodes(NodeType.Table, true);//[0].Remove();
            //Table table = nc[0] as Aspose.Words.Tables.Table;
            //table.Rows[0].Cells[0].CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
            //table.Rows[0].Cells[1].CellFormat.PreferredWidth = PreferredWidth.FromPoints(180);
            //table.Rows[0].Cells[2].CellFormat.PreferredWidth = PreferredWidth.FromPoints(45);

            for (int i = 0; i < doc.PageCount; i++)
            {
                iso.PageIndex = i;
                doc.Save(path + "\\" + i + ".jpg", iso);
            }
        }
      
    }

Image.zip (112.1 KB)

@www.evget.com,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Please share the XML or JSON string that you are using in your code.
  • Please create a standalone console 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’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.