@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.
The difference between them is the origin of the coordinates. Word has the upper left corner as the origin, while PDF has the lower left corner as the origin.
@supeiwei Yes, the coordinates returned by LayoutEnumerator
have upper left corner as the origin. But knowing page size you can easily convert them to lower left corner as the origin.
Will the page size change after converting word to pdf?
@supeiwei No, page size will not be changed. After rendering to PDF page size remains the same as in the original MS Word document.
But when I use the rectangular coordinates obtained by parsing word to draw on PDF, the display is wrong.
@supeiwei It is hard to tall what might cause the problem on your side. If you generate PDF using Aspose.Words and calculate coordinates in the same environment, there should not be any problems.