コード例 #1
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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Insert document page numbers.	
        /// </summary>
        /// <param name="name">The file name.</param>
        /// <param name="filename">Result name of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document</param>
        /// <param name="folder">The document folder.</param>
        /// <param name="storage">The document storage.</param>
        public void InsertDocumentPageNumbers(string name, string filename, string folder, PageNumberSettings pageNumberSettings, string storage = "")
        {
            // POST 	words/{name}/insertPageNumbers?appSid={appSid}&filename={filename}&storage={storage}&folder={folder} 

            string apiUrl = string.Format(@"words/{0}/insertPageNumbers?filename={1}&storage={2}&folder={3}",
                                                name, filename, storage, folder);

            ServiceController.Post(apiUrl, AppSid, AppKey, JsonConvert.SerializeObject(pageNumberSettings));
        }