I already downloaded aspose sdk for word and develop one program for search and replace which search and replace whole words in the document at a time with new words.
//////////////////////////////////
step 1: Getting doc file
Document doc = null;
try {
doc = new Document("d:\\test.docx");
} catch (Exception e1) {
e1.printStackTrace();
}
//////////////////////
//////////////////////
Step 2:Getting text file which contain some definition with the help of which I am replacing text
Reader reader =
null;
try {
reader = new InputStreamReader(
new FileInputStream("d:\\table.txt","Unicode");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
BufferedReader bufferedReader = new BufferedReader(reader);
List<String> lines = new ArrayList<String>();
String line = null;
try {
while ((line = bufferedReader.readLine()) != null)
{
lines.add(line);
}
} catch (IOException e1) {
e1.printStackTrace();
}
//////////////////////////////////////////////////////
//step 3 :for choosing output file
JFileChooser SaveFileChooser = new JFileChooser();
SaveFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int resultSaveFile = SaveFileChooser.showSaveDialog(frame);
if (resultSaveFile == JFileChooser.APPROVE_OPTION) {
}
////////////////////////////////////////////////
for(int i=0;i<lines.size();i++){
String[] splitting = lines.get(i).split("\t");
try {
doc.getRange().replace(splitting[0],splitting[1],false,false);
} catch (Exception e1) {
e1.printStackTrace();
}
}
try {
doc.save(String.format(SaveFileChooser.getSelectedFile().getAbsolutePath().concat(".docx")));
} catch (Exception e1) {
e1.printStackTrace();
}
try {
bufferedReader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
JOptionPane.showMessageDialog(null,"Successfully Replaced","Done",JOptionPane.INFORMATION_MESSAGE);
}
});
//////////////////////////////////
As I develop this code offline with the help of aspose library.Now I want this thing to be run on aspose cloud but i don’t have any idea about how to integrate our code with Aspose cloud. I already created account on Aspose cloud and I have my appSID and key . I got one link of aspose cloud in that we have to upload our document and do things which we want,I tried searh and replace over there also and they provide search and replace for only one word at a time but I want whole search and replace at a time like I created offline but I am not getting any clue. It would be nice if anybody could help me.