Exemple #1
0
        private static string[] ExtractFiles(string sourceOddFileName, string sourceEvenFileName)
        {
            var oddFile      = new PDFFile(sourceOddFileName);
            var oddPageCount = oddFile.GetPageCount();

            var evenFile      = new PDFFile(sourceEvenFileName);
            var evenPageCount = evenFile.GetPageCount();

            var filenames = new string[oddPageCount + evenPageCount];

            // Extract each page to an individual PDF file
            for (var i = 1; i <= oddPageCount; i++)
            {
                var pageNum = (i * 2) - 1;
                filenames[pageNum - 1] = $"temp-page-{pageNum}.pdf";
                oddFile.ExtractPages(i, i, filenames[pageNum - 1]);
            }
            for (var i = 1; i <= evenPageCount; i++)
            {
                var pageNum = (i * 2);
                filenames[pageNum - 1] = $"temp-page-{pageNum}.pdf";
                evenFile.ExtractPages(i, i, filenames[pageNum - 1]);
            }

            return(filenames);
        }