@supeiwei Unfortunately, without the problematic document it is impossible to analyze the problem. I will move your messages to a separate topic. It is safe to attach documents in the forum, only topic starter and Aspose staff can access the attachments.
I found the reason. It is because of the page margin settings, which may be different from the default page margins of Aspose. Can you tell me how to adjust the page margins to suit my own files?
@supeiwei Aspose.Words uses page margins specified in the source file. It does not uses default margins.
test.docx (14.1 KB)
Like this file, the rectangular frame obtained by the first paragraph does not match the actual one. Its rectangular height is higher than the actual one.
@supeiwei Thank you for additional information. As I can see paragraph rectangles are detected properly:
out.docx (11.8 KB)
No, the paragraph rectangle is not detected correctly. The height of the rectangle of paragraph (a) is obviously too high and does not correctly frame paragraph (a). Can you help me solve this problem?
@supeiwei The frame is correct since it also includes the paragraph’s spacings. If you select the paragraph’s content in MS Word you will see this:
@supeiwei What app do you use to open the document? here is the output produced on my side in PDF format:
out.pdf (7.4 KB)
It looks like fonts used in your document are not available on the machine where you are viewing the document.
I opened the file using Microsoft Word
I have the font, but my document margins are all set to 2.54cm
@supeiwei the problem is that default editing language is set to Chinese on your side. MS Word applies different layout rules when different editing languages are used. Please see the difference:
ms_chinese.pdf (7.6 KB)
ms_english.pdf (7.3 KB)
Usually the problem can be resolved by specifying default editing language in the document load options, like this:
LoadOptions opt = new LoadOptions();
opt.getLanguagePreferences().setDefaultEditingLanguage(EditingLanguage.CHINESE_PRC);
Document doc = new Document("C:\\Temp\\in.docx", opt);
But in your case this does not work.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-27563
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Thank you for your answer. It can’t be solved yet, right?
@supeiwei No, unfortunately, there is no solution for this document yet. You should wait until the issue is resolved.
Thank you, I have another question. The cross-page paragraph rectangular frame I obtained through the method you gave before is not accurate.
If I extract the coordinates from Word, then convert the file to PDF. If I use the extracted coordinates to draw on the PDF, will it correspond to the paragraph?
@supeiwei Yes, Aspose.Words uses the same document layout engine for calculating node’s coordinates and for rendering to PDF.
But their coordinate reference systems are different. How can I convert the rectangle obtained by word into the rectangle of pdf?
@supeiwei Coordinates returned by LayoutEnumerator
are in points. You can convert the units using ConvertUtil
to units you need.