测试的最新版25.6,有如下两个问题想咨询。
1、请帮忙测试一下附件里word里面的标题和数据转换pdf之后字体样式就变了,另外就是非中国字体转换完后并不正确。
2、表格转换后表格的样式就会挤压 ,我们原来的方式是按照百分比配置的表格宽度,后面因为转换pdf挤压,最后才调整为厘米(固定列)
demo.docx (54.9 KB)
Cause
The issues you’re experiencing with the Word to PDF conversion in Aspose.Words could be due to several factors, including font compatibility and table formatting settings. When converting documents, certain fonts may not render correctly if they are not available on the system or if they are not embedded properly. Additionally, table width settings can affect how tables are displayed in the PDF output.
Solution
-
Font Issues: Ensure that the fonts used in your Word document are available on the system where the conversion is taking place. You can also try embedding the fonts in the PDF by setting the
EmbedFullFonts
property totrue
in thePdfSaveOptions
. -
Table Formatting: If tables are being compressed or not displaying correctly, consider adjusting the table width settings. Instead of using percentage-based widths, set fixed widths in centimeters to maintain consistency in the PDF output.
Code
Here’s a sample code snippet to help you set the necessary options for PDF conversion:
Document doc = new Document("path/to/your/document.docx");
// Create PdfSaveOptions and set properties
PdfSaveOptions options = new PdfSaveOptions();
options.setEmbedFullFonts(true); // Embed all fonts
options.setTextCompression(PdfTextCompression.FLATE); // Optional: set text compression
// Save the document as PDF
doc.save("path/to/output/document.pdf", options);
For table formatting, you can set the widths like this:
Table table = (Table) doc.getChild(NodeType.TABLE, 0, true);
table.setPreferredWidth(PreferredWidth.fromPoints(500)); // Set fixed width in points
Next Steps
- Test the conversion with the updated settings to see if the font and table issues are resolved.
- If the problem persists, check the specific fonts used in your document and whether they are supported by Aspose.Words.
- If you have further questions or need additional assistance, please reach out for support.
I am confident that these steps will help resolve your issues.
- I don’t see any problems with the font styles, except for the non-Chinese characters. Here’s the conclusion:
output.pdf (55.5 KB)
- Could you please provide the code to help us reproduce the cm to % table problem. If you are using
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
table.PreferredWidth = PreferredWidth.FromPercent(100);
It is properly configured for the table. But in your document I don’t see any problem with the table.
Also, please clarify which product you are using, Aspose.Words or Aspose.Pdf?
我现在按照以上的方法设置了相关属性,现在是生成的PDF文档前面部分的字体是正确的,后面字体就错了。我们文档是中英混合的,英文字体一直是正确的,中文后面字体就错了,这个可能是什么原因呢?
附件是DEMO,解压密码:hh123
DEMO.zip (7.2 MB)
就是我们英文字体Arial一直是正常的,中文是黑体,那么转PDF就有问题,会用宋体替代,如果强制指定字体目录,且这个目录没有宋体,就会显示不出来.
dll版本用的最新的25.6.
这个word不能用office保存,一保存再用程序转pdf就复现不出问题了。
代码如下:
@Angela_xu 感谢您报告此问题。 我们已经在我们的内部问题跟踪系统中打开了以下新工单,并将根据 免费支持政策 中提到的条款提供它们的修复:
Issue ID(s): WORDSNET-28435
如果您需要优先支持以及直接联系我们的付费支持管理团队,您可以获得 付费支持服务 。
The issues you have found earlier (filed as WORDSNET-28435) have been fixed in this Aspose.Words for .NET 25.8 update also available on NuGet.