Hi,
I saw that there is a method for extracting content in a field: extractContent()
(for example : https://docs.aspose.com/words/java/extract-selected-content-between-nodes/ ).
However, I don’t understand how to code/define this function… Can you help me?
Thanks,
Regards,
Hi Hu,
Thanks for your inquiry. The definition of ‘extractContent’ method which extracts blocks of content from a document between specified nodes can be found here:
https://docs.aspose.com/words/java/extract-selected-content-between-nodes/
Best regards,
Hi,
Thanks for your answer.
I have another question: in the FieldType Class, there are different value for the field.
(https://reference.aspose.com/words/java/com.aspose.words/FieldType)
I would like some precision:
- 26: FIELD_NUM_PAGES.
Is it possible to use this find for filtering the number of pages?
Actutally, I am working on a DOM structure and I would like to filter the number of pages. Currently, I have:
[13] PAGE [14]122 [15] /[13] NUMPAGES [14] 600 [15].
And I would like to ba able to say: if the field contain the number of pages, system.out.println(“the field concerns pages, don’t care”);
Can you help me?
Thanks,
Hi Hu,
Thanks for your inquiry. The FieldNumPages class represents NUMPAGES field in Word document. We have PAGE field and NUMPAGES field in Word document. PAGE field represents number of current page while NUMPAGES represents the number of pages in document. You can make use of IF field to filter page e.g.
{ IF "{ PAGE }" = "{ NUMPAGES }" "true part" "false part" }
I hope, this helps.
Best regards,
Hi,
Thanks for your answer. However I didn’t understand it. I understood the differences between NUMPAGE and PAGE fields.
But, I am working with a DOM structure, and I would like to filter the NUMPAGE field. That is to say, in my DOM output, I just want to read the PAGE field (and the other nodes) and I don’t want to read the NUMPAGE field…
Hi Hu,
Thanks for your inquiry. You can use the following code to filter NUMPAGES fields in your document:
for(Field field : (Iterable<Field>) doc.getRange().getFields()){
if(field.getType() == FieldType.FIELD_NUM_PAGES) {
// Skip NUMPAGES field
}
else{
// Do something useful
}
}
I hope, this helps.
Best regards,