I have a word document with multiple paragraphs. I’d like to insert a field code at the begining of the first paragraph.
$paragraph_index = 0;
$wordsApi->insertField(
new InsertFieldRequest(
$filename, // The filename of the input document.
new FieldInsert([
"field_code" => "{ TC \"Text Entry\" }",
]), // \Aspose\Words\Model\FieldInsert $field Field data.
"sections/0/paragraphs/$paragraph_index", // The path to the node in the document tree.
$folder, // Original document folder.
$storage, // Original document storage.
insert_before_node: $paragraph_index // The index of the node. A new field will be inserted before the node with the specified node Id.
));
When I try this I get the following error:
“Error: InsertField. Exception: Value cannot be null. (Parameter ‘node’).”
If I exclude the insert_before_node
parameter it works - but the field is inserted at the end of the paragraph (which is not what I want).
What value shoudl I be using for insert_before_node ?