Update of fields in a frame displaces text when using 'IncludeText'

Hello,

it seems that there is problem when ‘IncludeText’ is used in a frame and updateFields is called.
I have a document template that includes text from another document (using IncludeText).
IncludeText is used both in a text box and in a text frame. After calling updateFields result of IncludeText is different.
Update of IncludeText in text box works fine.
Update of IncludeText in frame is not ok. Line of IncludeText is now located under the frame.

In Aspose.Word.Java version 13.5 update of IncludeText in frames worked fine. In latest version 18.4 it fails.

I have added some files to reproduce the problem:

  • Frame.dotx (document template using IncludeText in text box and frame
  • IncludeTextFile.docx (Document that contains the text for including)
  • TestIncludeTextWithinFrame.java (simple java file for updating fields and save as new document)
  • Frame Result.docx (Created document after calling TestIncludeTextWithinFrame.java)
    IncludeText.zip (58.5 KB)

Thanks a lot.

Best regards,
Matthias Schlosser

Hello,

i will have another question if there is no workaround for this problem.
Is it posssible to convert a frame into text box using Aspose? Do you have an example?
Our Custumer has more than 150 document templates based on frames instead of text box. Manual replace of frame into text box takes too much time. Thanks a lot.

Best regards
Matthias

@curmas,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16780. You will be notified via this forum thread once this issue is resolved.

Unfortunately, there is no workaround available for this issue. We apologize for your inconvenience.

Hello,

thanks for your answer.
I think it should be posssible to convert a frame into text box using Aspose.
Therefore i would like to assign the content of the frame to a newly created text box. Afterwards frame should be deleted. Do you have an example or a hint for that? Thanks a lot.

Best regards
Matthias

@curmas,

Thanks for your inquiry. Please use following workaround for your issue. Hope this helps you.

Document doc = new Document(MyDir + "Frame.dotx");
Shape textbox = new Shape(doc, ShapeType.TEXT_BOX);
Paragraph para = new Paragraph(doc);
para.appendChild(textbox);
Boolean blnFirst = true;
 
NodeCollection paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Node  node : paragraphs.toArray())
{
    Paragraph  paragraph = (Paragraph)node;
    if(paragraph.getFrameFormat().isFrame() && blnFirst)
    {
        paragraph.getParentNode().insertBefore(para, paragraph);
        blnFirst = false;
        textbox.setWidth(paragraph.getFrameFormat().getWidth());
        textbox.setHeight(paragraph.getFrameFormat().getHeight()); 
        textbox.appendChild(paragraph.deepClone(true));
        paragraph.remove();
    }
    else if(paragraph.getFrameFormat().isFrame())
    {
 
        textbox.appendChild(paragraph.deepClone(true));
        paragraph.remove();
    }
}
doc.updateFields();
doc.save(MyDir + "output.docx");

Thanks for the example.

Best regards
Matthias

The issues you have found earlier (filed as WORDSNET-16780) have been fixed in this Aspose.Words for .NET 18.8 update and this Aspose.Words for Java 18.8 update.