I am considering your Words/Java product for a project. Wanted to see if I could get some questions answered up front.
Can I do a global search and replace operation on an existing MS Word document where the search is based on a regular expression?
Will such a search work across style boundaries, e.g., if I want to search on “some_string” and in the document the letters “some” are in bold but “_string” is not bolded?
Assuming regular expression searches are allowed, can such a search span multiple paragraphs and/or tables? For example, in a MS Word document, if I have a hard coded string “<<>>”, followed by several paragraphs of text and a table or two, followed by “<<>>”, can I search and replace that in a straightforward way?
Within an existing table, can I append a row that is an exact copy of the current last row?
Can I append an entire MS Word doc to an existing MS Word doc? And if so, can the content of the 2nd doc start on the last page of the 1st doc (that is, no page break between 1st and 2nd doc)?
Can anyone point to an example that can perform the task in the 3rd bullet from my original question? Or maybe just write out a little pseudo-code? I naively tried this (very dumb test) on attached testIn.doc, but got UnsupportedOperationException:
public class AsposeWordsTest
{
static int mMatchNumber = 0;
public static void main(String[] args)
{
try
{
Document doc = new Document("testIn.doc");
mMatchNumber = 0;
doc.getRange().replace(Pattern.compile("(?s)<<>>.*<<</MARKER>>>"),
new ReplaceEvaluator()
{
public int replace(Object object, ReplaceEvaluatorArgs e) throws Exception
{
e.setReplacement(e.getMatch().toString() + mMatchNumber);
mMatchNumber++;
System.err.println("mMatchNumber=" + mMatchNumber);
return ReplaceAction.REPLACE;
}
},
true);
doc.save("testOut.doc");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
I have another question. According to this link digital signatures are not supported for a (complete) MS Word document. Is that feature on your technical roadmap? If so, when do you expect it to be released?
There is no simple way to remove/replace content between placeholders. However, you can try using the technique suggested in the following forum thread: https://forum.aspose.com/t/range-replace-regex/67656
Code is in VB, please let me know if you have problems with translation to Java.
You are right, currently Aspose.Words does not support Digital Signatures. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is available.
Hi Eric,
Thanks for your inquiry. The verification of a digital signature on a DOC/DOCX document is planned to be supported sometime around August. The functionality of digitally signing a document however has not been planned yet. It will be avaliable sometime in the future, we will inform you about any developments.
Thanks,
Alexey, thanks for the update but I’m a bit confused … my original inquiry is specifically for Aspose/Words for Java, but the link you provided is for the .NET. Did you perhaps put the wrong link?
Hi Eric,
Thanks for your inquiry.
You’re right, the verification of digital signatures has been released for the .NET version but not for Java yet. As you may know we are working on a porting system which will automatically port all .NET code to Java. This means nearly all functionality that is avaliable in the .NET platform will be avaliable in Java.
This functionality will be released for Java in due time although not with the first release of the newest Java version. This is because currently the code behind digital signatures uses .NET cryptography and more time is needed to make it platform independent. We will keep you informed when this feature is avaliable for Java.
Thanks,