コード例 #1
0
        /// <summary>
        /// Loads a document and split it by separate pages. Saves the each page into PDF format.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/split-docx-document-by-pages-in-pdf-format-net-csharp-vb.php
        /// </remarks>
        static void SplitDocumentByPages()
        {
            string            filePath   = @"..\..\example.docx";
            DocumentCore      dc         = DocumentCore.Load(filePath);
            string            folderPath = Path.GetFullPath(@"Result-files");
            DocumentPaginator dp         = dc.GetPaginator();

            for (int i = 0; i < dp.Pages.Count; i++)
            {
                DocumentPage page = dp.Pages[i];
                Directory.CreateDirectory(folderPath);

                // Save the each page to PDF format.
                page.Save(folderPath + @"\Page - " + i.ToString() + ".pdf", SaveOptions.PdfDefault);
            }
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(folderPath)
            {
                UseShellExecute = true
            });
        }
コード例 #2
0
        public void SplitDocumentByPages()
        {
            string       filePath = @"C:\Users\sodrk\Desktop\net\doc.rtf";
            DocumentCore dc       = DocumentCore.Load(filePath);

            DocumentPaginator dp = dc.GetPaginator();

            for (int i = 0; i < dp.Pages.Count; i++)
            {
                DocumentPage page = dp.Pages[i];
                Directory.CreateDirectory(folderPath);

                page.Save(folderPath + @"\Page - " + (i + 1).ToString() + ".pdf", SautinSoft.Document.SaveOptions.PdfDefault);
            }
            LoadPages(dp.Pages.Count);
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(folderPath)
            {
                UseShellExecute = true
            });
        }