///<Summary>
        /// Split method to split pdf document
        ///</Summary>

        public Response Splitter(DocumentInfo[] docs, string sourceFolder)
        {
            if (docs == null)
            {
                return(BadDocumentResponse);
            }
            if (docs.Length <= 0 || docs.Length > MaximumUploadFiles)
            {
                return(MaximumFileLimitsResponse);
            }

            SetDefaultOptions(docs, "");
            Opts.AppName     = "Splitter";
            Opts.MethodName  = "Splitter";
            Opts.FolderName  = sourceFolder;
            Opts.CreateZip   = true;
            Opts.ZipFileName = "Splitted document";

            return(Process((inFilePath, outPath, zipOutFolder) =>
            {
                foreach (var doc in docs)
                {
                    PdfFileEditor pdfEditor = new PdfFileEditor();
                    pdfEditor.SplitToPages(doc.FileName, $"{zipOutFolder}\\{Path.GetFileNameWithoutExtension(doc.FileName)}_%NUM%.pdf");
                }
            }));
        }
        public static void Run()
        {
            // ExStart:SplitToIndividualPagesUsingPaths
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();
            int fileNumber = 1;
            // Split to pages
            MemoryStream[] outBuffer = pdfEditor.SplitToPages(dataDir + "input.pdf");
            // Save individual files
            foreach (MemoryStream aStream in outBuffer)
            {
                FileStream outStream = new FileStream(dataDir + "File_" + fileNumber.ToString() + "_out.pdf", FileMode.Create);
                aStream.WriteTo(outStream);
                outStream.Close();
                fileNumber++;
            }
            // ExEnd:SplitToIndividualPagesUsingPaths
        }
Ejemplo n.º 3
0
        public static void Run()
        {
            // ExStart:SplitToIndividualPagesUsingPaths
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor  = new PdfFileEditor();
            int           fileNumber = 1;

            // Split to pages
            MemoryStream[] outBuffer = pdfEditor.SplitToPages(dataDir + "input.pdf");
            // Save individual files
            foreach (MemoryStream aStream in outBuffer)
            {
                FileStream outStream = new FileStream(dataDir + "File_" + fileNumber.ToString() + "_out.pdf", FileMode.Create);
                aStream.WriteTo(outStream);
                outStream.Close();
                fileNumber++;
            }
            // ExEnd:SplitToIndividualPagesUsingPaths
        }
Ejemplo n.º 4
0
        public static void Run()
        {
            // ExStart:PdfFileEditorFeatures
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create instance of PdfFileEditor class
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Append pages from input file to the port file and save in output file
            int start = 1;
            int end   = 3;

            pdfEditor.Append(dataDir + "inFile.pdf", dataDir + "portFile.pdf", start, end, dataDir + "outFile.pdf");

            // Concatenate two files and save in the third one
            pdfEditor.Concatenate(dataDir + "inFile1.pdf", dataDir + "inFile2.pdf", dataDir + "outFile.pdf");

            // Delete specified number of pages from the file
            int[] pages = new int[] { 1, 2, 4, 10 };
            pdfEditor.Delete(dataDir + "inFile.pdf", pages, dataDir + "outFile.pdf");

            // Extract any pages from the file
            start = 0;
            end   = 3;
            pdfEditor.OwnerPassword = "******";
            pdfEditor.Extract(dataDir + "inFile.pdf", start, end, dataDir + "outFile.pdf");

            // Insert pages from another file into the output file at a specified position
            start = 2;
            end   = 5;
            pdfEditor.Insert(dataDir + "inFile.pdf", 4, dataDir + "portFile.pdf", start, end, dataDir + "outFile.pdf");

            // Make booklet
            pdfEditor.MakeBooklet(dataDir + "inFile.Pdf", dataDir + "outFile.Pdf");

            // Make N-Ups
            pdfEditor.MakeNUp(dataDir + "inFile.pdf", dataDir + "nupOutFile.pdf", 3, 2);

            // Split the front part of the file
            pdfEditor.SplitFromFirst(dataDir + "inFile.pdf", 3, dataDir + "outFile.pdf");

            // Split the rear part of the file
            pdfEditor.SplitToEnd(dataDir + "inFile.pdf", 3, dataDir + "outFile.pdf");

            // Split to individual pages
            int fileNum = 1;

            MemoryStream[] outBuffer = pdfEditor.SplitToPages(dataDir + "inFile.pdf");
            foreach (MemoryStream aStream in outBuffer)
            {
                FileStream outStream = new FileStream("oneByone" + fileNum.ToString() + ".pdf",
                                                      FileMode.Create);
                aStream.WriteTo(outStream);
                outStream.Close();
                fileNum++;
            }

            // Split to several multi-page pdf documents
            fileNum = 1;
            int[][]        numberofpage = new int[][] { new int[] { 1, 4 } };
            MemoryStream[] outBuffer2   = pdfEditor.SplitToBulks(dataDir + "inFile.pdf", numberofpage);
            foreach (MemoryStream aStream in outBuffer2)
            {
                FileStream outStream = new FileStream("oneByone" + fileNum.ToString() + ".pdf",
                                                      FileMode.Create);
                aStream.WriteTo(outStream);
                outStream.Close();
                fileNum++;
            }
            // ExEnd:PdfFileEditorFeatures
        }
        public static void Run()
        {
            // ExStart:PdfFileEditorFeatures
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create instance of PdfFileEditor class
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Append pages from input file to the port file and save in output file
            int start = 1;
            int end = 3;
            pdfEditor.Append(dataDir + "inFile.pdf", dataDir + "portFile.pdf", start, end, dataDir + "outFile.pdf");

            // Concatenate two files and save in the third one
            pdfEditor.Concatenate(dataDir + "inFile1.pdf", dataDir + "inFile2.pdf", dataDir + "outFile.pdf");

            // Delete specified number of pages from the file
            int[] pages = new int[] { 1, 2, 4, 10 };
            pdfEditor.Delete(dataDir + "inFile.pdf", pages, dataDir + "outFile.pdf");

            // Extract any pages from the file
            start = 0;
            end = 3;
            pdfEditor.OwnerPassword = "******";
            pdfEditor.Extract(dataDir + "inFile.pdf", start, end, dataDir + "outFile.pdf");

            // Insert pages from another file into the output file at a specified position
            start = 2;
            end = 5;
            pdfEditor.Insert(dataDir + "inFile.pdf", 4, dataDir + "portFile.pdf", start, end, dataDir + "outFile.pdf");

            // Make booklet
            pdfEditor.MakeBooklet(dataDir + "inFile.Pdf", dataDir + "outFile.Pdf");

            // Make N-Ups
            pdfEditor.MakeNUp(dataDir + "inFile.pdf", dataDir + "nupOutFile.pdf", 3, 2);

            // Split the front part of the file
            pdfEditor.SplitFromFirst(dataDir + "inFile.pdf", 3, dataDir + "outFile.pdf");

            // Split the rear part of the file
            pdfEditor.SplitToEnd(dataDir + "inFile.pdf", 3, dataDir + "outFile.pdf");

            // Split to individual pages
            int fileNum = 1;
            MemoryStream[] outBuffer = pdfEditor.SplitToPages(dataDir + "inFile.pdf");
            foreach (MemoryStream aStream in outBuffer)
            {
                FileStream outStream = new FileStream("oneByone" + fileNum.ToString() + ".pdf",
                FileMode.Create);
                aStream.WriteTo(outStream);
                outStream.Close();
                fileNum++;
            }
            
            // Split to several multi-page pdf documents
            fileNum = 1;
            int[][] numberofpage = new int[][] { new int[] { 1, 4 }};
            MemoryStream[] outBuffer2 = pdfEditor.SplitToBulks(dataDir + "inFile.pdf", numberofpage);
            foreach (MemoryStream aStream in outBuffer2)
            {
                FileStream outStream = new FileStream("oneByone" + fileNum.ToString() + ".pdf",
                FileMode.Create);
                aStream.WriteTo(outStream);
                outStream.Close();
                fileNum++;
            }
            // ExEnd:PdfFileEditorFeatures                      
        }