打印预览里的表格和文档里的不一样

我用代码生成表格,发现在打印预览显示和实际的不一样
预览中的表格:微信截图_20200617221850.png (8.2 KB)
实际的表格:2.png (6.6 KB)
生成的文档:temp.zip (15.9 KB)
ASPOSE.WORDS版本是20.1.0.0
我用的代码如下:

Table table = builder.StartTable();
builder.InsertCell();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Distributed;
builder.ParagraphFormat.LineSpacing = 35;
builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly;
builder.Font.Size = 32;
builder.Font.Name = “方正小标宋简体”;
builder.Font.Color = Color.Red;
builder.CellFormat.SetPaddings(0, 0, 0, 0);
builder.CellFormat.Borders.LineStyle = LineStyle.None;
builder.Write(“深圳市科限公司\n”);
builder.Write(“龙岗区有限公司”);
builder.InsertCell();
builder.CellFormat.LeftPadding = 5;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Write(“文件”);
builder.EndRow();
builder.EndTable();
table.AutoFit(AutoFitBehavior.AutoFitToContents);
table.Alignment = TableAlignment.Center;

@sijile,

我们已经使用了最新的20.6版本的Aspose.Words for .NET,并使用以下代码生成了输出DOCX文件。 使用MS Word 2019的``打印布局’'查看此文档时,它看起来不错(请参见屏幕截图):

C# .NET Code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();
builder.InsertCell();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Distributed;
builder.ParagraphFormat.LineSpacing = 35;
builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly;
builder.Font.Size = 32;
builder.Font.Name = "方正小标宋简体";
builder.Font.Color = Color.Red;
builder.CellFormat.SetPaddings(0, 0, 0, 0);
builder.CellFormat.Borders.LineStyle = LineStyle.None;
builder.Write("深圳市科限公司\n");
builder.Write("龙岗区有限公司");
builder.InsertCell();
builder.CellFormat.LeftPadding = 5;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Write("文件");
builder.EndRow();
builder.EndTable();
table.AutoFit(AutoFitBehavior.AutoFitToContents);
table.Alignment = TableAlignment.Center;

doc.Save("E:\\Temp\\20.6.docx");

因此,我们建议您升级到.NET的最新版本的Aspose.Words。 希望这可以帮助。

我用了最新版的aspose.words,用下面的方法预览我最开始给你们的temp.docx,显示还是和实际的不一样

Document doc = new Document("temp.docx");
AsposeWordsPrintDocument printDocument = new AsposeWordsPrintDocument(doc);
printPreviewControl1.Rows = doc.PageCount;
printPreviewControl1.Zoom = 1;
printPreviewControl1.Document = printDocument;

I found out that when the docx is in compatibility mode, the print preview is correct. But when the docx is not in compatibility mode, the print preview is wrong. You can create a new docx by MS Word 2019, and then use the code to create a table in it, you will see that the print preview is wrong.

@sijile,

I am afraid, we are still unable to reproduce this issue on our end. Please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Aspose.Words for .NET 20.6 generated output DOCX file showing the undesired behavior
  • Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.
  • Please also list the complete steps that we can perform on our end to be able to observe this undesired behavior. For example, what steps did you perform in MS Word 2019 to preview Aspose.Words generated document etc.

As soon as you get these pieces of information ready, we will start further investigation into your scenario and provide you more information. Thanks for your cooperation.

Hi, I create a simple winform application that can show the print preview of the docx.
The steps is that:

  1. Run the application, click the button ‘EditDocx’.
    2.The application open the manual.docx and do mail merge operation to create a table.
    3.Save the doc as edited.docx, and preview the doc.

sample.zip (80.3 KB)

@sijile,

I have converted (using the Save As command) the edited.docx to PDF format by using MS Word 2019 and attached it here for your reference. Please tell if such an output (character spacing, shapes of characters etc) is acceptable for you?

We also managed to observe the difference in PrintPreviewControl and logged it in our issue tracking system with ID WORDSNET-20657. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for your inconvenience.

The PDF is correct.

@sijile,

Please also ZIP and attach the following Font file here for further testing:

  • 方正小标宋简体

FZXBSJW.zip (1.8 MB)

@sijile,

Thanks for the additional information. We will further look into the details of this problem and will keep you updated on the status of linked issue.

你好,请问这个问题解决了吗?
在哪里可以看到这个问题的进展呢

@typeof,

我们目前正在对此问题进行分析,以确定根本原因。 我们会在此问题尽快得到解决后通知您。 很抱歉给您带来不便。

你好,我想问一下这个问题解决了吗,2年了

@sijile, 不幸的是,该问题已被推迟,尚未解决。