We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to remove content from specified text to end of line

Hi

I need to remove the content from specified text to end of the line. I am finding the specified text($HDR) using replace method and tried to remove the content from text to end of line, I tried with ControlChar.LF and LINE_FEED but this chars are not find in that text. if i use Shift + Enter in document then ControlChar.LINE_BREAK working as i expected but i don’t want to use Shift + Enter in document . please suggest me.
I tried with following code:
document.getRange().replace(Pattern.compile(Pattern.quote("$HDR")), new ReplaceEvaluatorFindAndHighlight(), true);

public class ReplaceEvaluatorFindAndHighlight implements IReplacingCallback{
public int replacing(ReplacingArgs e) throws Exception{
Node currentNode = e.getMatchNode();
Document doc = (Document) currentNode.getDocument();
if(currentNode.getParentNode() != null){
Node nextNode = currentNode.getParentNode();
do{
Node RunNode = null;
RunNode = currentNode.getNextSibling();
if(((Run)currentNode).getText().contains(ControlChar.LINE_BREAK)){ currentNode.remove();
break;
}else{
currentNode.remove();
}</div>
currentNode = RunNode;
}while((currentNode != null) && (currentNode.getNodeType() == NodeType.RUN)));
}
return ReplaceAction.SKIP;
}
}

Thanks,
-kapil

Hi Kapil,

Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi Tahir,

Thanks for your response. I am attaching the input document and expected output document for your reference. In input.rtf I want to remove the content form the specified String ($HDR) to end of the line.

Thanks
-kapil

Hi Kapil,

Thanks for your inquiry.
Please note that MS Word document is flow document and does not contain
any information about its layout into lines and pages. Therefore,
technically there is no “Page” concept in Word document. Pages are
created by Microsoft Word on the fly.

Aspose.Words uses our own Rendering Engine to layout documents into pages. The Aspose.Words.Layout namespace provides
classes that allow to access information such as on what page and where
on a page particular document elements are positioned, when the document
is formatted into pages. Please read about LayoutCollector and
LayoutEnumerator from here:
http://www.aspose.com/docs/display/wordsjava/LayoutCollector+class
http://www.aspose.com/docs/display/wordsjava/LayoutEnumerator+class

We are working over your query and will update you asap.

Hi Kapil,

Thanks for your patience. In your case, you need to get the text of line where the specific text ($HDR) exists and remove the text from the specific text to the end of line. To get the text where the line ends, the DocumentLayoutHelper sample fit in this case.

Please check “DocumentLayoutHelper” example project in Aspose.Words for .NET examples repository at GitHub. This sample demonstrates how to easily work with the layout elements of a document and access the pages, lines, spans etc. Note that this sample application is in .NET.

The DocumentLayoutHelper’s code for
Java is not available at the moment. We have already logged a new task
for this in our issue tracking system as WORDSJAVA-740. Your request has
been linked to this Task. We will update you via this forum thread once
the code sample of DocumentLayoutHelper is available. We apologize for
your inconvenience.

Hi Tahir,

Thanks for your response. please update me after completion of this task.

Thanks
-kapil

Hi Kapil,

Sure, we will update you via this forum thread once DocumentLayoutHelper’s code for
Java is available. Thanks for your patience.

The issues you have found earlier (filed as WORDSJAVA-740) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)