Document.PageCount is incorrect for Chinese DOC using Java

I already use doc.updatefield.but doc.getPagenum()<my doc pagenum.when words is full for row,these words were 1 row in the toc of aspose.words.however,it is 2 row in my microsoft doc.I use 20.4 aspose.words,and I have a license.Can you help me ?

I use doc.getPageCount() , docInstance.getBuiltInDocumentProperties().getPages(),whatevert.It always different in Toc between my doc and aspose.

String ss[]={//word实际页数,getpagecount的页数=pdf页数
                "8.18一 一一一一一一一一 一一一:一一一一一一一一一一(苹果)",//92,92
                "g一一一一一一一 一一一一一 一一一一一一一一一一一一一一(一一)",//92,85
                "88888888888888888888888888888888888888888888888888888888888888",//91,91
//                "8.18一 一一一一一一一一 一一一:一一一一一一一一一一(苹果)",
                "8.18一 一一一一一一一一 一一一:一一一一一一一一一一(一一)",//92,85
                "8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)",//91,85
                "8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)",//92,92
                "8.18一 一一一一一一一一 一一一一一一一一一一一一一一(一一)",//92,92
                "8.18一 一一一一一一一一 一一一,,一一一一一一一一一一(一一)"};//92,92
        for(int i=0;i<ss.length;i++){
            byte[] bytes=ss[i].getBytes();
            com.aspose.words.Document test1=new com.aspose.words.Document(String.format("../新建文件夹/test%d.doc",i+1));
            System.out.println((i+1)+" "+test1.getPageCount()+" "+bytes.length+" "+ss[i].length()+" "+ss[i]);//输出=pdf92,实际92,pdf92

        }
//        1 92 91 33 8.18一 一一一一一一一一 一一一:一一一一一一一一一一(苹果)
//        2 85 93 33 g一一一一一一一 一一一一一 一一一一一一一一一一一一一一(一一)
//        3 91 62 62 88888888888888888888888888888888888888888888888888888888888888
//        4 85 91 33 8.18一 一一一一一一一一 一一一:一一一一一一一一一一(一一)
//        5 85 89 33 8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)
//        6 85 91 33 8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)
//        7 91 91 33 8.18一 一一一一一一一一 一一一一一一一一一一一一一一(一一)
//        8 91 90 34 8.18一 一一一一一一一一 一一一,,一一一一一一一一一一(一一)

新建文件夹.zip (1.3 MB)

页码有点错

String ss[]={
                "8.18一 一一一一一一一一 一一一:一一一一一一一一一一(苹果)",//92,92
                "g一一一一一一一 一一一一一 一一一一一一一一一一一一一一(一一)",//92,85
                "88888888888888888888888888888888888888888888888888888888888888",//91,91
//                "8.18一 一一一一一一一一 一一一:一一一一一一一一一一(苹果)",
                "8.18一 一一一一一一一一 一一一:一一一一一一一一一一(一一)",//92,85
                "8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)",//91,85
                "8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)",//92,92
                "8.18一 一一一一一一一一 一一一一一一一一一一一一一一(一一)",//92,91
                "8.18一 一一一一一一一一 一一一,,一一一一一一一一一一(一一)"};//92,91
        for(int i=0;i<ss.length;i++){
            byte[] bytes=ss[i].getBytes();
            com.aspose.words.Document test1=new com.aspose.words.Document(String.format("../新建文件夹/test%d.doc",i+1));
            System.out.println((i+1)+" "+test1.getPageCount()+" "+bytes.length+" "+ss[i].length()+" "+ss[i]);//输出=pdf92,实际92,pdf92

        }
//        1 92 91 33 8.18一 一一一一一一一一 一一一:一一一一一一一一一一(苹果)
//        2 85 93 33 g一一一一一一一 一一一一一 一一一一一一一一一一一一一一(一一)
//        3 91 62 62 88888888888888888888888888888888888888888888888888888888888888
//        4 85 91 33 8.18一 一一一一一一一一 一一一:一一一一一一一一一一(一一)
//        5 85 89 33 8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)
//        6 85 91 33 8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)
//        7 91 91 33 8.18一 一一一一一一一一 一一一一一一一一一一一一一一(一一)
//        8 91 90 34 8.18一 一一一一一一一一 一一一,,一一一一一一一一一一(一一)

@xl1

Please note that Aspose.Words requires TrueType fonts when rendering document to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you are converting documents to PDF. Please refer to the following articles:
Using TrueType Fonts
Manipulating and Substitution TrueType Fonts

Moreover, you are using old version of Aspose.Words for Java. We suggest you please upgrade to the latest version of Aspose.Words for Java 21.1.

If you still face problem, please ZIP and attach the fonts used in your documents here for testing. We will investigate the issue and provide you more information on it.

I don’t want to covert word to PDF.But I think that my doc in aspose is same with pdf.I hope that my doc in aspose is same with word.But not.my word’s pagenum is different with doc.getpagecount().
my fonts is ok.but I think that Some of the symbols have been shrunk.maybe?I test it in different machine.Error is same.

Morever,I want to know whether I can get word’s style gallery or not.like this picture.I want to use style gallery’s style.
image.png (7.3 KB)

I already test 21.1,but result is same.second col is getpagecount(). my doc is built by my template in my computer.So,my fonts may be ok.新建文件夹.zip (1.3 MB)
this is my test doc.my fonts is in cloud.
链接:https://pan.baidu.com/s/1u12cg9fxv5uixmln5g2zkq
提取码:awzz
复制这段内容后打开百度网盘手机App,操作更方便哦
1 92 91 33 | 33 8.18一 一一一一一一一一 一一一:一一一一一一一一一一(苹果)
2 85 93 33 | 33 g一一一一一一一 一一一一一 一一一一一一一一一一一一一一(一一)
3 91 62 62 | 62 88888888888888888888888888888888888888888888888888888888888888
4 85 91 33 | 33 8.18一 一一一一一一一一 一一一:一一一一一一一一一一(一一)
5 85 89 33 | 33 8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)
6 85 91 33 | 33 8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)
7 91 91 33 | 33 8.18一 一一一一一一一一 一一一一一一一一一一一一一一(一一)
8 91 90 34 | 34 8.18一 一一一一一一一一 一一一,一一一一一一一一一一(一一)

@xl1

Please note that getting the PageCount property invoked the document’s page layout to calculate the value. So, it requires fonts for correct page layout.

The Document.Styles property returns a collection of styles defined in the document. If you want to check either it is in the Quick Style gallery or not, you can use Style.IsQuickStyle property

Following code example shows how to access a document’s style collection.

Document doc = new Document();

// A blank document comes with 4 styles by default
Assert.assertEquals(4, doc.getStyles().getCount());

Iterator<Style> stylesEnum = doc.getStyles().iterator();
while (stylesEnum.hasNext()) {
    Style curStyle = stylesEnum.next();
    System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
    System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
    System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
    System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
}

We have tested the scenario using the latest version of Aspose.Words for Java 21.1 and have not found the shared issue for documents Test1.doc, Test2.doc, and Test3.doc. We have noticed the page count issue with Test4.doc and have logged this problem in our issue tracking system as WORDSNET-21692. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

We are testing the same issue for other documents and will get back to you soon.

@xl1

For documents Test5.doc, Test6.doc, and Test7.doc, we have logged issues as WORDSNET-21693, WORDSNET-21694, and WORDSNET-21695. You will be notified via this forum thread once these issues are resolved.

After I turned it off to adjust word spacing and compress Chinese, the page number difference disappeared.I think it’s the way you and Office handle free word spacing when rendering.
In the picture are the options that I changed.
image.png (6.5 KB)

image.png (43.0 KB)

@xl1

Thanks for sharing the detail. We have logged it in our issue tracking system. We will inform you via this forum thread once your issues are resolved.