Free Support Forum - aspose.cloud

Aspose Cloud for Word

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.

@amitmoralwar,

Thank you for contacting Aspose Support.

In order start using our API Services you need to upload your files to the Aspose Cloud. You can do this in multiple ways such as the Cloud UI, via a cURL command or using the multiple SDKs available on Github. To learn more about uploading files to the cloud storage, check out the Methods to Work with Cloud Storage section of our developer guide.

To learn more about replacing text within a Word Document, you can read up on Find and Replace section of our developer guide. The cURL command for replacin text looks like

curl -v "http://api.aspose.cloud/v1.1/words/Assignment.doc/replaceText?appSid=1c7a12ca-XXX-YYY-b83d-234d9d5e2309&signature=tWvaBXBBBBBB1O7LnQu389mA" -X POST -d '{"OldValue": "hello","NewValue": "helloyou","IsMatchCase": true,"IsMatchWholeWord": true,"IsOldValueRegex": true}' -H "Content-Type: application/json" -H "Accept: application/json"

Currently, Aspose Words does not support replacing mutiple vlaues. However, OldValue text can be entered using a regex statememt, that will allow you to replace mutiple words that match a single regex expression.

If you need any more help, do let me know.

Kind Regards,
Mateen Sajjad

Is it applicable to excel and slide also or not?? and also I don’t have much idea about regular expression.
Can you guide me little bit regarding how can I create regular expression for search and replace???
I also have one question regarding aspose slides,I am trying to embed unicode font in my slide and I am using Hindi Language but It does not appearing while I am displaying the slide data on cloud,I don’t know why this is happening because Hindi Language is supported for aspose cloud word and aspose cloud excel

@amitmoralwar

The find and replace functionality is for Aspose.Words for Cloud. What is your desired use case for replacing text in a word document. Let me know and i can guide you with a working example.

For the slides query, please log a separate thread in the Aspose.Slides forum.
Kind Regards,
Muhammad Mateen