In Aspose.Words for Java, calling the toString
method on a paragraph can obtain an ID like Paragraph 4.0.0
, but Aspose.Words for .NET cannot retrieve this ID.
In Aspose.Words for .NET, the ability to retrieve a paragraph ID similar to the toString
method in Aspose.Words for Java is not available. Specifically, Aspose.Words does not expose an attribute for paragraph IDs, as these values are dynamic and can change during document processing.
If your goal is to identify inserted paragraphs while generating a document, you might consider using the CustomNodeId
property. However, it’s important to note that the value assigned to this property is not saved in the output file and only exists during the lifetime of the node.
If you need further assistance or have a specific scenario in mind, please provide more details so that I can help you better.
I am currently using these IDs to insert translated text when translating documents. Is there any way to achieve this? For example, Paragraph 4.0.0 has the text ‘你好’, which is translated into English as ‘hello world’, and Paragraph 4.0.1 has the text ‘不错’, which is translated as ‘good’. This way, I can quickly locate this segment.
@purekael Could you please attach your input document, code that will allow us to test your scenario and provide your current and expected outputs? We will check the issue and provide you more information.
Certainly! Here’s the English translation of your provided text:
"This issue is not related to a specific document. For example, my Java code is as follows:
- Iterate through the paragraphs in the document.
- Iterate through the runs in each paragraph.
- Store each run in a list, where
id = run.toString()
obtains an ID like"Run 1.0.1"
. - Save the list to a JSON file.
- Translate this JSON file.
- Iterate through the paragraphs and runs again, and by using
run.toString()
, find the corresponding run in the JSON file by ID and set the translated text withrun.setText(translated_text)
. - Finally,
doc.save()
.
The JSON structure is as follows:
[
{
"id": "Run 1.0.1",
"text": "你好",
"translation": "hello"
},
{
"id": "Run 1.0.2",
"text": "美国",
"translation": "america"
}
]
I want to convert this code to a Python version, but the Python version cannot obtain the value from toString()
. What should I do?"
If you need further assistance with translating or adapting the code to Python, feel free to ask!
@purekael
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-27569
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 reply and follow-up