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


C# Document.UpdatePageLayout方法代码示例

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


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

示例1: Run

        public static void Run()
        {
            // ExStart:UpdatePageLayout
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_JoiningAndAppending();
            string fileName = "TestFile.Destination.doc";

            Document dstDoc = new Document(dataDir + fileName);
            Document srcDoc = new Document(dataDir + "TestFile.Source.doc");

            // If the destination document is rendered to PDF, image etc or UpdatePageLayout is called before the source document 
            // Is appended then any changes made after will not be reflected in the rendered output.
            dstDoc.UpdatePageLayout();

            // Join the documents.
            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

            // For the changes to be updated to rendered output, UpdatePageLayout must be called again.
            // If not called again the appended document will not appear in the output of the next rendering.
            dstDoc.UpdatePageLayout();

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            // Save the joined document to PDF.
            dstDoc.Save(dataDir);
            // ExEnd:UpdatePageLayout
            Console.WriteLine("\nDocument appended successfully with updated page layout after appending the document.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:27,代码来源:UpdatePageLayout.cs

示例2: Run

        public static void Run()
        {
            // ExStart:ConvertNumPageFields
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_JoiningAndAppending();
            string fileName = "TestFile.Destination.doc";

            Document dstDoc = new Document(dataDir + fileName);
            Document srcDoc = new Document(dataDir + "TestFile.Source.doc");

            // Restart the page numbering on the start of the source document.
            srcDoc.FirstSection.PageSetup.RestartPageNumbering = true;
            srcDoc.FirstSection.PageSetup.PageStartingNumber = 1;

            // Append the source document to the end of the destination document.
            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

            // After joining the documents the NUMPAGE fields will now display the total number of pages which 
            // Is undesired behavior. Call this method to fix them by replacing them with PAGEREF fields.
            ConvertNumPageFieldsToPageRef(dstDoc);

            // This needs to be called in order to update the new fields with page numbers.
            dstDoc.UpdatePageLayout();

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            dstDoc.Save(dataDir);
            // ExEnd:ConvertNumPageFields
            Console.WriteLine("\nDocument appended successfully with conversion of NUMPAGE fields with PAGEREF fields.\nFile saved at " + dataDir);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:29,代码来源:ConvertNumPageFields.cs

示例3: Main

        public static void Main()
        {
            string dataDir = Path.GetFullPath("../../../Data/");

            Document doc = new Document(dataDir + "TestFile.docx");

            // Create and attach collector before the document before page layout is built.
            LayoutCollector layoutCollector = new LayoutCollector(doc);

            // This will build layout model and collect necessary information.
            doc.UpdatePageLayout();

            // Print the details of each document node including the page numbers.
            foreach (Node node in doc.FirstSection.Body.GetChildNodes(NodeType.Any, true))
            {
                Console.WriteLine(" --------- ");
                Console.WriteLine("NodeType:   " + Node.NodeTypeToString(node.NodeType));
                Console.WriteLine("Text:       \"" + node.ToString(SaveFormat.Text).Trim() + "\"");
                Console.WriteLine("Page Start: " + layoutCollector.GetStartPageIndex(node));
                Console.WriteLine("Page End:   " + layoutCollector.GetEndPageIndex(node));
                Console.WriteLine(" --------- ");
                Console.WriteLine();
            }

            // Detatch the collector from the document.
            layoutCollector.Document = null;

            Console.ReadLine();
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:29,代码来源:Program.cs

示例4: SplitDocumentToPages

        public static void SplitDocumentToPages(string docName)
        {
            string folderName = Path.GetDirectoryName(docName);
            string fileName = Path.GetFileNameWithoutExtension(docName);
            string extensionName = Path.GetExtension(docName);
            string outFolder = Path.Combine(folderName, "Out");

            Console.WriteLine("Processing document: " + fileName + extensionName);

            Document doc = new Document(docName);

            // Create and attach collector to the document before page layout is built.
            LayoutCollector layoutCollector = new LayoutCollector(doc);

            // This will build layout model and collect necessary information.
            doc.UpdatePageLayout();

            // Split nodes in the document into separate pages.
            DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);

            // Save each page to the disk as a separate document.
            for (int page = 1; page <= doc.PageCount; page++)
            {
                Document pageDoc = splitter.GetDocumentOfPage(page);
                pageDoc.Save(Path.Combine(outFolder, string.Format("{0} - page{1} Out{2}", fileName, page, extensionName)));
            }

            // Detach the collector from the document.
            layoutCollector.Document = null;
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:30,代码来源:Program.cs

示例5: Run

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

            Document doc = new Document(dataDir + "TestFile.docx");

            // Create and attach collector before the document before page layout is built.
            LayoutCollector layoutCollector = new LayoutCollector(doc);

            // This will build layout model and collect necessary information.
            doc.UpdatePageLayout();

            // Print the details of each document node including the page numbers. 
            foreach (Node node in doc.FirstSection.Body.GetChildNodes(NodeType.Any, true))
            {
                Console.WriteLine(" --------- ");
                Console.WriteLine("NodeType:   " + Node.NodeTypeToString(node.NodeType));
                Console.WriteLine("Text:       \"" + node.ToString(SaveFormat.Text).Trim() + "\"");
                Console.WriteLine("Page Start: " + layoutCollector.GetStartPageIndex(node));
                Console.WriteLine("Page End:   " + layoutCollector.GetEndPageIndex(node));
                Console.WriteLine(" --------- ");
                Console.WriteLine();
            }

            // Detatch the collector from the document.
            layoutCollector.Document = null;

            Console.WriteLine("\nFound the page numbers of all nodes successfully.");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:30,代码来源:PageNumbersOfNodes.cs

示例6: ReceiveWarningNotification

        private static void ReceiveWarningNotification(Document doc, string dataDir)
        {
            // ExStart:ReceiveWarningNotification 
            // When you call UpdatePageLayout the document is rendered in memory. Any warnings that occured during rendering
            // Are stored until the document save and then sent to the appropriate WarningCallback.
            doc.UpdatePageLayout();

            // Create a new class implementing IWarningCallback and assign it to the PdfSaveOptions class.
            HandleDocumentWarnings callback = new HandleDocumentWarnings();

            doc.WarningCallback = callback;
            dataDir = dataDir + "Rendering.FontsNotificationUpdatePageLayout_out.pdf";
            // Even though the document was rendered previously, any save warnings are notified to the user during document save.
            doc.Save(dataDir);
            // ExEnd:ReceiveWarningNotification  
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:16,代码来源:ReceiveNotificationsOfFont+.cs

示例7: AppendDocument_ConvertNumPageFields

        //ExStart
        //ExId:AppendDocument_ConvertNumPageFields
        //ExSummary:Shows how to change the NUMPAGE fields in a document to display the number of pages only within a sub document.
        public static void AppendDocument_ConvertNumPageFields()
        {
            Document dstDoc = new Document(gDataDir + "TestFile.Destination.doc");
            Document srcDoc =  new Document(gDataDir + "TestFile.Source.doc");

            // Restart the page numbering on the start of the source document.
            srcDoc.FirstSection.PageSetup.RestartPageNumbering = true;
            srcDoc.FirstSection.PageSetup.PageStartingNumber = 1;

            // Append the source document to the end of the destination document.
            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

            // After joining the documents the NUMPAGE fields will now display the total number of pages which
            // is undesired behavior. Call this method to fix them by replacing them with PAGEREF fields.
            ConvertNumPageFieldsToPageRef(dstDoc);

            // This needs to be called in order to update the new fields with page numbers.
            dstDoc.UpdatePageLayout();

            dstDoc.Save(gDataDir + "TestFile.ConvertNumPageFields Out.doc");
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:24,代码来源:Program.cs

示例8: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithImages();
            string fileName = "TestFile.doc";
            // This a document that we want to add an image and custom text for each page without using the header or footer.
            Document doc = new Document(dataDir + fileName);

            // Create and attach collector before the document before page layout is built.
            LayoutCollector layoutCollector = new LayoutCollector(doc);

            // Images in a document are added to paragraphs, so to add an image to every page we need to find at any paragraph 
            // belonging to each page.
            IEnumerator enumerator = doc.SelectNodes("//Body/Paragraph").GetEnumerator();

            // Loop through each document page.
            for (int page = 1; page <= doc.PageCount; page++)
            {
                while (enumerator.MoveNext())
                {
                    // Check if the current paragraph belongs to the target page.
                    Paragraph paragraph = (Paragraph)enumerator.Current;
                    if (layoutCollector.GetStartPageIndex(paragraph) == page)
                    {
                        AddImageToPage(paragraph, page, dataDir);
                        break;
                    }
                }
            }

            // Call UpdatePageLayout() method if file is to be saved as PDF or image format
            doc.UpdatePageLayout();

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            doc.Save(dataDir);

            Console.WriteLine("\nInserted images on each page of the document successfully.\nFile saved at " + dataDir);
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:38,代码来源:AddImageToEachPage.cs

示例9: AppendDocument_UpdatePageLayout

        public static void AppendDocument_UpdatePageLayout()
        {
            //ExStart
            //ExId:AppendDocument_UpdatePageLayout
            //ExSummary:Shows how to rebuild the document layout after appending further content.
            Document dstDoc = new Document(gDataDir + "TestFile.Destination.doc");
            Document srcDoc = new Document(gDataDir + "TestFile.Source.doc");

            // If the destination document is rendered to PDF, image etc or UpdatePageLayout is called before the source document
            // is appended then any changes made after will not be reflected in the rendered output.
            dstDoc.UpdatePageLayout();

            // Join the documents.
            dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

            // For the changes to be updated to rendered output, UpdatePageLayout must be called again.
            // If not called again the appended document will not appear in the output of the next rendering.
            dstDoc.UpdatePageLayout();

            // Save the joined document to PDF.
            dstDoc.Save(gDataDir + "TestFile.UpdatePageLayout Out.pdf");
            //ExEnd
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:23,代码来源:Program.cs


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