当前位置: 首页>>代码示例>>C#>>正文


C# Document.Save方法代码示例

本文整理汇总了C#中Document.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Save方法的具体用法?C# Document.Save怎么用?C# Document.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document的用法示例。


在下文中一共展示了Document.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            // Sample infrastructure.
            string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar;
            string dataDir = new Uri(new Uri(exeDir), @"../../Data/").LocalPath;

            // Open the document.
            Document doc = new Document(dataDir + "SaveAsMutiPageTiff.doc");

            //ExStart
            //ExId:SaveAsMultipageTiff_save
            //ExSummary:Convert document to TIFF.
            // Save the document as multipage TIFF.
            doc.Save(dataDir + "SaveAsMutiPageTiff Out.tiff");
            //ExEnd

            //ExStart
            //ExId:SaveAsMultipageTiff_SaveWithOptions
            //ExSummary:Convert to TIFF using customized options        
            //Create an ImageSaveOptions object to pass to the Save method
            ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);
            options.PageIndex = 0;
            options.PageCount = doc.PageCount;
            options.TiffCompression = TiffCompression.Ccitt4;
            options.Resolution = 160;

            doc.Save(dataDir + "TiffFileWithOptions Out.tiff", options);
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:29,代码来源:Program.cs

示例2: Run

        public static void Run()
        {
            // ExStart:SaveAsMultipageTiff
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); 

            // Open the document.
            Document doc = new Document(dataDir + "TestFile Multipage TIFF.doc");

            // ExStart:SaveAsTIFF
            // Save the document as multipage TIFF.
            doc.Save(dataDir + "TestFile Multipage TIFF_out.tiff");
            // ExEnd:SaveAsTIFF
            // ExStart:SaveAsTIFFUsingImageSaveOptions
            // Create an ImageSaveOptions object to pass to the Save method
            ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);
            options.PageIndex = 0;
            options.PageCount = 2;
            options.TiffCompression = TiffCompression.Ccitt4;
            options.Resolution = 160;
            dataDir = dataDir + "TestFileWithOptions_out.tiff";
            doc.Save(dataDir, options);
            // ExEnd:SaveAsTIFFUsingImageSaveOptions
            // ExEnd:SaveAsMultipageTiff
            Console.WriteLine("\nDocument saved as multi-page TIFF successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:26,代码来源:SaveAsMultipageTiff.cs

示例3: Main

        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Open the document.
            Document doc = new Document(dataDir + "TestFile.doc");

            //ExStart
            //ExId:SaveAsMultipageTiff_save
            //ExSummary:Convert document to TIFF.
            // Save the document as multipage TIFF.
            doc.Save(dataDir + "TestFile Out.tiff");
            //ExEnd

            //ExStart
            //ExId:SaveAsMultipageTiff_SaveWithOptions
            //ExSummary:Convert to TIFF using customized options
            //Create an ImageSaveOptions object to pass to the Save method
            ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);
            options.PageIndex = 0;
            options.PageCount = 2;
            options.TiffCompression = TiffCompression.Ccitt4;
            options.Resolution = 160;

            doc.Save(dataDir + "TestFileWithOptions Out.tiff", options);
            //ExEnd
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:28,代码来源:Program.cs

示例4: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();

            //open the source PDF document
            Document pdfDocument = new Document(dataDir + "PDFToDOC.pdf");

            // 1.
            // saving using direct method
            // save the file into MS document format
            pdfDocument.Save(dataDir + "simpleOutput.doc", SaveFormat.Doc);

            // 2.
            // save using save options
            // create DocSaveOptions object
            DocSaveOptions saveOptions = new DocSaveOptions();

            // set the recognition mode as Flow
            saveOptions.Mode = DocSaveOptions.RecognitionMode.Flow;
            
            // set the Horizontal proximity as 2.5
            saveOptions.RelativeHorizontalProximity = 2.5f;
            
            // enable the value to recognize bullets during conversion process
            saveOptions.RecognizeBullets = true;
            
            // save the resultant DOC file
            pdfDocument.Save(dataDir + "saveOptionsOutput.doc", saveOptions);
        }
开发者ID:joyang1,项目名称:Aspose_Pdf_NET,代码行数:30,代码来源:PDFToDOC.cs

示例5: Main

 static void Main(string[] args)
 {
     Document wordDocument = new Document("data/Convert Word Doc to Other Formats.doc");
     wordDocument.Save("data/Convert Word Doc to Other Formatsblank.docx", SaveFormat.Docx);
     wordDocument.Save("data/Convert Word Doc to Other Formatsblank.bmp", SaveFormat.Bmp);
     wordDocument.Save("data/Convert Word Doc to Other Formatsblank.html", SaveFormat.Html);
     wordDocument.Save("data/Convert Word Doc to Other Formatsblank.pdf", SaveFormat.Pdf);
     wordDocument.Save("data/Convert Word Doc to Other Formatsblank.text", SaveFormat.Text);
 }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:9,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            string MyDir = @"Files\";
            Document doc = new Document(MyDir + "Find and Replace.doc");
            ReplaceOneWordWithAnother(doc);
            doc.Save(MyDir + "Range.ReplaceOneWordWithAnother Out.doc");
            ReplaceTwoSimilarWords(doc);
            doc.Save(MyDir + "Range.ReplaceTwoSimilarWords Out.doc");

        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:10,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            Document doc = new Document("../../data/document.doc");

            // If the default font defined here cannot be found during rendering then the closest font on the machine is used instead.
            FontSettings.DefaultFontName = "Arial Unicode MS";

            // Now the set default font is used in place of any missing fonts during any rendering calls.
            doc.Save("Rendering.SetDefaultFont_Out.pdf");
            doc.Save("Rendering.SetDefaultFont_Out.xps");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:11,代码来源:Program.cs

示例8: Main

        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string FileName = FilePath + "Find and Replace.docx";
            
            Document doc = new Document(FileName);
            ReplaceOneWordWithAnother(doc);
            doc.Save(FileName);
            ReplaceTwoSimilarWords(doc);
            doc.Save(FileName);

        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:12,代码来源:Program.cs

示例9: Run

        public static void Run()
        {
            // ExStart:ApplyCustomLogicToEmptyRegions
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_MailMergeAndReporting(); 

            string fileName = "TestFile.doc";
            // Open the document.
            Document doc = new Document(dataDir + fileName);

            // Create a data source which has some data missing.
            // This will result in some regions that are merged and some that remain after executing mail merge.
            DataSet data = GetDataSource();

            // Make sure that we have not set the removal of any unused regions as we will handle them manually.
            // We achieve this by removing the RemoveUnusedRegions flag from the cleanup options by using the AND and NOT bitwise operators.
            doc.MailMerge.CleanupOptions = doc.MailMerge.CleanupOptions & ~MailMergeCleanupOptions.RemoveUnusedRegions;

            // Execute mail merge. Some regions will be merged with data, others left unmerged.
            doc.MailMerge.ExecuteWithRegions(data);

            // The regions which contained data now would of been merged. Any regions which had no data and were
            // Not merged will still remain in the document.
            Document mergedDoc = doc.Clone(); // ExSkip
            // Apply logic to each unused region left in the document using the logic set out in the handler.
            // The handler class must implement the IFieldMergingCallback interface.
            ExecuteCustomLogicOnEmptyRegions(doc, new EmptyRegionsHandler());

            // Save the output document to disk.
            doc.Save(dataDir + "TestFile.CustomLogicEmptyRegions1_out.doc");
            
            // Reload the original merged document.
            doc = mergedDoc.Clone();

            // Apply different logic to unused regions this time.
            ExecuteCustomLogicOnEmptyRegions(doc, new EmptyRegionsHandler_MergeTable());

            doc.Save(dataDir + "TestFile.CustomLogicEmptyRegions2_out.doc");
            // ExEnd:ApplyCustomLogicToEmptyRegions
            // Reload the original merged document.
            doc = mergedDoc.Clone();
            // ExStart:ContactDetails 
            // Only handle the ContactDetails region in our handler.
            ArrayList regions = new ArrayList();
            regions.Add("ContactDetails");
            ExecuteCustomLogicOnEmptyRegions(doc, new EmptyRegionsHandler(), regions);
            // ExEnd:ContactDetails 
            dataDir = dataDir + "TestFile.CustomLogicEmptyRegions3_out.doc";
            doc.Save(dataDir );

            Console.WriteLine("\nMail merge performed successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:52,代码来源:ApplyCustomLogicToEmptyRegions.cs

示例10: Main

        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Note.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            Dictionary<string, string> replacements = new Dictionary<string, string>();
            replacements.Add("Some task here", "New Text Here");

            // Load the document into Aspose.Note.
            Document oneFile = new Document(dataDir + "Aspose.one");

            IList<Node> pageNodes = oneFile.GetChildNodes(NodeType.Page);
            CompositeNode<Page> compositeNode = (CompositeNode<Page>)pageNodes[0];

            // Get all RichText nodes
            IList<Node> textNodes = compositeNode.GetChildNodes(NodeType.RichText);

            foreach (Node node in textNodes)
            {
                foreach (KeyValuePair<string, string> kvp in replacements)
                {
                    RichText richText = (RichText)node;
                    if (richText != null && richText.Text.Contains(kvp.Key))
                    {
                        // Replace text of a shape
                        richText.Text = richText.Text.Replace(kvp.Key, kvp.Value);
                    }
                }
            }

            // Save to any supported file format
            oneFile.Save(dataDir + "Output.pdf", SaveFormat.Pdf);
        }
开发者ID:saqibmasood,项目名称:Aspose_Note_NET,代码行数:33,代码来源:ReplaceTextOnParticularPage.cs

示例11: Run

        public static void Run()
        {
            // ExStart:GetXFAProperties
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

            // Load XFA form
            Document doc = new Document(dataDir + "GetXFAProperties.pdf");

            string[] names = doc.Form.XFA.FieldNames;

            // Set field values
            doc.Form.XFA[names[0]] = "Field 0";
            doc.Form.XFA[names[1]] = "Field 1";

            // Get field position
            Console.WriteLine(doc.Form.XFA.GetFieldTemplate(names[0]).Attributes["x"].Value);

            // Get field position
            Console.WriteLine(doc.Form.XFA.GetFieldTemplate(names[0]).Attributes["y"].Value);

            dataDir = dataDir + "Filled_XFA_out.pdf";
            // Save the updated document
            doc.Save(dataDir);
            // ExEnd:GetXFAProperties
            Console.WriteLine("\nXFA fields properties retrieved successfully.\nFile saved at " + dataDir);

        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:28,代码来源:GetXFAProperties.cs

示例12: Run

        public static void Run()
        {
            // ExStart:ConvertPageRegionToDOM         
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Images();

            // Open document
            Document document = new Document( dataDir + "AddImage.pdf");
            // Get rectangle of particular page region
            Aspose.Pdf.Rectangle pageRect = new Aspose.Pdf.Rectangle(20, 671, 693, 1125);
            // Set CropBox value as per rectangle of desired page region
            document.Pages[1].CropBox = pageRect;
            // Save cropped document into stream
            MemoryStream ms = new MemoryStream();
            document.Save(ms);
            // Open cropped PDF document and convert to image
            document = new Document(ms);
            // Create Resolution object
            Resolution resolution = new Resolution(300);
            // Create PNG device with specified attributes
            PngDevice pngDevice = new PngDevice(resolution);
            dataDir = dataDir + "ConvertPageRegionToDOM_out.png";
            // Convert a particular page and save the image to stream
            pngDevice.Process(document.Pages[1], dataDir);
            ms.Close();
            // ExEnd:ConvertPageRegionToDOM   
            Console.WriteLine("\nPage region converted to DOM successfully.\nFile saved at " + dataDir); 
        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:28,代码来源:ConvertPageRegionToDOM.cs

示例13: Run

        public static void Run()
        {
            // ExStart:ChangeTOCTabStops
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithStyles();

            string fileName = "Document.TableOfContents.doc";
            // Open the document.
            Document doc = new Document(dataDir + fileName);
        
            // Iterate through all paragraphs in the document
            foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
            {
                // Check if this paragraph is formatted using the TOC result based styles. This is any style between TOC and TOC9.
                if (para.ParagraphFormat.Style.StyleIdentifier >= StyleIdentifier.Toc1 && para.ParagraphFormat.Style.StyleIdentifier <= StyleIdentifier.Toc9)
                {
                    // Get the first tab used in this paragraph, this should be the tab used to align the page numbers.
                    TabStop tab = para.ParagraphFormat.TabStops[0];
                    // Remove the old tab from the collection.
                    para.ParagraphFormat.TabStops.RemoveByPosition(tab.Position);
                    // Insert a new tab using the same properties but at a modified position. 
                    // We could also change the separators used (dots) by passing a different Leader type
                    para.ParagraphFormat.TabStops.Add(tab.Position - 50, tab.Alignment, tab.Leader);
                }
            }

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            doc.Save(dataDir);            
            // ExEnd:ChangeTOCTabStops 
            Console.WriteLine("\nPosition of the right tab stop in TOC related paragraphs modified successfully.\nFile saved at " + dataDir);
        }        
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:31,代码来源:ChangeTOCTabStops.cs

示例14: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithComments();

            // Open the document.
            Document doc = new Document(dataDir + "TestFile.doc");

            // Extract the information about the comments of all the authors.
            foreach (string comment in ExtractComments(doc))
                Console.Write(comment);

            // Remove comments by the "pm" author.
            RemoveComments(doc, "pm");
            Console.WriteLine("Comments from \"pm\" are removed!");

            // Extract the information about the comments of the "ks" author.
            foreach (string comment in ExtractComments(doc, "ks"))
                Console.Write(comment);

            // Remove all comments.
            RemoveComments(doc);
            Console.WriteLine("All comments are removed!");

            // Save the document.
            doc.Save(dataDir + "Test File Out.doc");

            Console.WriteLine("\nComments extracted and removed successfully.\nFile saved at " + dataDir + "Test File Out.doc");
        }
开发者ID:robv8r,项目名称:Aspose_Words_NET,代码行数:29,代码来源:ProcessComments.cs

示例15: Run

        public static void Run()
        {
            // ExStart:InheritZoom
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Bookmarks();

            // Open document
            Document doc = new Document(dataDir + "input.pdf");

            // Get outlines/bookmarks collection of PDF file
            OutlineItemCollection item = new OutlineItemCollection(doc.Outlines);
            // Set zoom level as 0
            XYZExplicitDestination dest = new XYZExplicitDestination(2, 100, 100, 0);
            // Add XYZExplicitDestination as action to outlines collection of PDF
            item.Action = new GoToAction(dest);
            // Add item to outlines collection of PDF file
            doc.Outlines.Add(item);

            dataDir = dataDir + "InheritZoom_out.pdf";
            // Save output
            doc.Save(dataDir);
            // ExEnd:InheritZoom
            Console.WriteLine("\nBookmarks updated successfully.\nFile saved at " + dataDir);

        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:25,代码来源:InheritZoom.cs


注:本文中的Document.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。