docx转PDF后,生僻字不显示

版本:23.8
编程语言:java

问题截图:

源文件:
金顶宝-20年-单签-2024V1.0 (1) (1).docx (33.6 KB)

@ZhonghaoSun

Cause

The issue of rare characters not displaying correctly in the PDF after converting from DOCX is likely due to font embedding settings. If the fonts used in the DOCX file are not embedded in the PDF, the PDF viewer may not have access to those fonts, resulting in missing characters.

Solution

To ensure that all characters, including rare ones, are displayed correctly in the PDF, you must embed the fonts when saving the document. This can be achieved by configuring the PdfSaveOptions to embed all fonts.

Code

Here’s a sample code snippet to help you embed fonts while converting a DOCX document to PDF using Aspose.Words for Java:

import com.aspose.words.Document;
import com.aspose.words.PdfSaveOptions;

public class ConvertDocxToPdf {
    public static void main(String[] args) {
        try {
            // Load the DOCX document
            Document doc = new Document("path/to/your/document.docx");

            // Create PdfSaveOptions and set to embed all fonts
            PdfSaveOptions options = new PdfSaveOptions();
            options.setEmbedFullFonts(true); // Embed all fonts

            // Save the document as PDF
            doc.save("path/to/your/output.pdf", options);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Next Steps

  1. Replace "path/to/your/document.docx" and "path/to/your/output.pdf" with the actual file paths.
  2. Run the code to convert your DOCX file to PDF with embedded fonts.
  3. Check the output PDF to confirm that the rare characters are displayed correctly.

If you have any further questions or need additional assistance, please feel free to ask!

@ZhonghaoSun I’ve checked the document with and without revisions, but I can’t reproduce the problem. Here is the information from my side about the revision with the problematic character.

This could be a problem with a font missing on the computer. Could you please check the revision information for this symbol and provide a similar screenshot along with the output PDF file?

Here is an output document:

output.pdf (173.7 KB)

金顶宝-20年-单签-2024V1.0 (宋体) (1).pdf.zip (203.2 KB)

这个是我们用aspose转换出来的PDF,麻烦帮看下呢

@ZhonghaoSun 我看到的文件之间的唯一区别是,我这边也使用了 "Microsoft YaHei "字体。 请尝试在您的文档中安装和使用它: