Beispiel #1
0
        public static void Run()
        {
            string storagefile = "doc-sample.doc";
            string inputfile1  = "doc-sample1.doc";
            string inputfile2  = "doc-sample2.doc";

            // Upload input files from local directory to Cloud Storage
            Common.UploadFile(storagefile, string.Empty);
            Common.UploadFile(inputfile1, string.Empty);
            Common.UploadFile(inputfile2, string.Empty);

            // Append a List of Word Documents
            WordDocumentEntryRequest wordDocumentEntryRequest = new WordDocumentEntryRequest();

            wordDocumentEntryRequest.DocumentEntries.Add(new WordDocumentEntry(inputfile1, WordImportFormatMode.KeepSourceFormatting));
            wordDocumentEntryRequest.DocumentEntries.Add(new WordDocumentEntry(inputfile2, WordImportFormatMode.KeepSourceFormatting));
            Common.WordsService.SplitDocument(storagefile, SplitDocumentFormat.Jpeg, 1, 2, Common.FOLDER);

            /// <summary>
            /// Append Documents to Original Document.
            /// </summary>
            /// <param name="name">file name</param>
            /// <param name="wordDocumentEntryRequest">List of Word documents.</param>
            /// <param name="filename">Path to save result. Must be a Cloud storage path e.g. MyFolder\out.doc</param>
            /// <param name="folder">Folder name on Cloud storage e.g. MyFolder. Empty means files will be uploaded on Default Cloud storage</param>
            WordsDocumentResponse wordsDocumentResponse = Common.WordsService.AppendDocumentsToOriginalDocument(storagefile, wordDocumentEntryRequest, Common.GetOutputFilePath(storagefile, true), Common.FOLDER);

            // Download appended document file from cloud storage and save it to local directory
            string dataDir = Common.DownloadFile(storagefile, string.Empty);

            Console.WriteLine("\nDocuments appended successfully.\nFile saved at " + dataDir);
        }
Beispiel #2
0
        public void Words_Tests()
        {
            try
            {
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/doc-sample.doc", Utils.CloudStorage_Output_Folder + "/doc-sample.doc");

                WordDocumentResponse wordDocumentResponse = wordsService.ReadDocumentCommonInfo("doc-sample.doc", Utils.CloudStorage_Output_Folder);
                wordsService.ConvertDocument("doc-sample.doc", WordOutputFormat.Pdf, Utils.CloudStorage_Output_Folder, Utils.CloudStorage_Output_Folder + "/doc-out-pdf.pdf");
                wordsService.ConvertDocument("doc-sample.doc", WordOutputFormat.Pdf, Utils.CloudStorage_Output_Folder, Utils.Local_Output_Path + "\\doc-out-pdf.pdf");
                wordsService.ConvertDocument("doc-sample.doc", WordOutputFormat.Html, Utils.CloudStorage_Output_Folder, Utils.Local_Output_Path + "\\doc-out-html.html");
                wordsService.ConvertDocument(WordOutputFormat.Tiff, Utils.CloudStorage_Output_Folder + "/doc-out-tiff.tiff", Utils.Local_Input_Path + "doc-sample.doc");

                PageNumberSettings pageNumberSettings = new PageNumberSettings("{PAGE} of {NUMPAGES}", "right", true, true);
                wordsService.InsertDocumentPageNumbers("doc-sample.doc", string.Empty, Utils.CloudStorage_Output_Folder, pageNumberSettings);

                wordsService.InsertDocumentWatermarkImage("doc-sample.doc", string.Empty, 45.0, Utils.CloudStorage_Input_Folder + "/signature.jpg", Utils.CloudStorage_Output_Folder);
                wordsService.InsertDocumentWatermarkImage("doc-sample.doc", string.Empty, 135.0, Utils.Local_Input_Path + "signature.jpg", Utils.CloudStorage_Output_Folder);
                wordsService.InsertDocumentWatermarkText("doc-sample.doc", "Watermarked by Aspose", 45.0, string.Empty, Utils.CloudStorage_Output_Folder);



                //                string jSon = @"<?xml version=\""1.0\"" encoding=\""utf-8\""?>
                //                            <Orders>
                //                              <Order>
                //                                <Number>23</Number>
                //                                <Address>Nelson Street</Address>
                //                                <Suburb>Howick</Suburb>
                //                                <City>Auckland</City>
                //                                <Phonenumber>543 1234</Phonenumber>
                //                                <Date>03/01/2010</Date>
                //                                <Total>14.00</Total>
                //                                <Item>
                //                                  <Name>BBQ Chicken Pizza</Name>
                //                                  <Price>6.00</Price>
                //                                  <Quantity>1</Quantity>
                //                                  <ItemTotal>6.00</ItemTotal>
                //                                </Item>
                //                                <Item>
                //                                  <Name>1.5 Litre Coke</Name>
                //                                  <Price>4.00</Price>
                //                                  <Quantity>2</Quantity>
                //                                  <ItemTotal>8.00</ItemTotal>
                //                                </Item>
                //                              </Order>
                //                              <Order>
                //                                <Number>10</Number>
                //                                <Address>Parkville Avenue</Address>
                //                                <Suburb>Pakuranga</Suburb>
                //                                <City>Auckland</City>
                //                                <Phonenumber>548 7342</Phonenumber>
                //                                <Date>05/03/2010</Date>
                //                                <Total>6.00</Total>
                //                                <Item>
                //                                  <Name>Hawaiian Pizza</Name>
                //                                  <Price>4.00</Price>
                //                                  <Quantity>1</Quantity>
                //                                  <ItemTotal>4.00</ItemTotal>
                //                                </Item>
                //                                <Item>
                //                                  <Name>Fries</Name>
                //                                  <Price>1.00</Price>
                //                                  <Quantity>2</Quantity>
                //                                  <ItemTotal>2.00</ItemTotal>
                //                                </Item>
                //                              </Order>
                //                            </Orders>";

                //wordsService.PopulateDocumentTemplateWithData("doc-sample2.doc", WordCleanupOptions.ContainingFields, string.Empty, Utils.CloudStorage_Output_Folder, jSon);


                WordDocumentEntryRequest wordDocumentEntryRequest = new WordDocumentEntryRequest();
                wordDocumentEntryRequest.DocumentEntries.Add(new WordDocumentEntry(Utils.CloudStorage_Input_Folder + "/doc-sample.doc", WordImportFormatMode.KeepSourceFormatting));
                wordDocumentEntryRequest.DocumentEntries.Add(new WordDocumentEntry(Utils.CloudStorage_Input_Folder + "/doc-sample.doc", WordImportFormatMode.KeepSourceFormatting));
                wordsService.SplitDocument("doc-sample.doc", SplitDocumentFormat.Jpeg, 1, 2, Utils.CloudStorage_Output_Folder);
                WordsDocumentResponse wordsDocumentResponse = wordsService.AppendDocumentsToOriginalDocument("doc-sample.doc", wordDocumentEntryRequest, string.Empty, Utils.CloudStorage_Output_Folder);

                WordsSplitResultResponse wordsSplitResultResponse = wordsService.SplitDocument("doc-sample.doc", SplitDocumentFormat.Jpeg, 1, 2, Utils.CloudStorage_Output_Folder);

                // Please check http://www.aspose.com/docs/display/wordscloud/loadWebDocument+%28Controller+resource%29 for details
                //string requestData = @"<?xml version=""\1.0""\ encoding=""\utf-16""\?>
                //                    <LoadWebDocumentData xmlns:xsd=""\http://www.w3.org/2001/XMLSchema""\ xmlns:xsi=""\http://www.w3.org/2001/XMLSchema-instance""\>
                //                        <LoadingDocumentUrl>http://www.aspose.com</LoadingDocumentUrl>
                //                        <DocSaveOptionsData>
                //                        <SaveFormat>doc</SaveFormat>
                //                        <FileName>google.doc</FileName>
                //                        <SaveRoutingSlip>true</SaveRoutingSlip>
                //                        </DocSaveOptionsData>
                //                    </LoadWebDocumentData>";

                //WordsSaveResultResponse wordsSaveResultResponse = wordsService.LoadNewDocumentFromWebIntoFile(requestData);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }