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

            // Create two file streams to read pdf files
            FileStream fs1 = new FileStream(dataDir + "inFile.pdf", FileMode.Open, FileAccess.Read);
            FileStream fs2 = new FileStream(dataDir + "inFile2.pdf", FileMode.Open, FileAccess.Read);

            // Create byte arrays to keep the contents of PDF files
            byte[] buffer1 = new byte[Convert.ToInt32(fs1.Length)];
            byte[] buffer2 = new byte[Convert.ToInt32(fs2.Length)];


            int i = 0;
            // Read PDF file contents into byte arrays
            i = fs1.Read(buffer1, 0, Convert.ToInt32(fs1.Length));
            i = fs2.Read(buffer2, 0, Convert.ToInt32(fs2.Length));

            // Now, first convert byte arrays into MemoryStreams and then concatenate those streams
            using (MemoryStream pdfStream = new MemoryStream())
            {
                using (MemoryStream fileStream1 = new MemoryStream(buffer1))
                {
                    using (MemoryStream fileStream2 = new MemoryStream(buffer2))
                    {
                        // Create instance of PdfFileEditor class to concatenate streams
                        PdfFileEditor pdfEditor = new PdfFileEditor();
                        // Concatenate both input MemoryStreams and save to putput MemoryStream
                        pdfEditor.Concatenate(fileStream1, fileStream2, pdfStream);
                        // Convert MemoryStream back to byte array
                        byte[] data = pdfStream.ToArray();
                        // Create a FileStream to save the output PDF file
                        FileStream output = new FileStream(dataDir + "merged_out.pdf", FileMode.Create,
                        FileAccess.Write);
                        // Write byte array contents in the output file stream
                        output.Write(data, 0, data.Length);
                        // Close output file
                        output.Close();
                    }
                }
            }
            // Close input files
            fs1.Close();
            fs2.Close();
            // ExEnd:ConcatenateMultiplePDFUsingMemoryStream                      
        }
        public static void Run()
        {
            // ExStart:ConcatenateArrayOfPdfUsingStreams
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();
            // Output stream
            FileStream outputStream = new FileStream(dataDir + "ConcatenateArrayOfPdfUsingStreams_out.pdf", FileMode.Create);
            // Array of streams
            FileStream[] inputStreams = new FileStream[2];
            inputStreams[0] = new FileStream(dataDir + "input.pdf", FileMode.Open);
            inputStreams[1] = new FileStream(dataDir + "input2.pdf", FileMode.Open);
            // Concatenate file
            pdfEditor.Concatenate(inputStreams, outputStream);
            // ExEnd:ConcatenateArrayOfPdfUsingStreams
        }
예제 #3
0
        public ActionResult <Response> UploadFile([FromBody] Request request)
        {
            try
            {
                //System.IO.Directory.CreateDirectory(outputConcDir);

                PdfFileEditor pdfEditor = new PdfFileEditor();

                Byte[] bitmapData = Convert.FromBase64String(request.filecontent.Split(",").Last());
                System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData);

                System.IO.FileStream outputPDF = new System.IO.FileStream(serverDirectory + request.filename, System.IO.FileMode.Create);

                pdfEditor.Concatenate(new System.IO.MemoryStream[] { streamBitmap }, outputPDF);
                outputPDF.Close();

                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = string.Empty,
                    Message = "File Uploaded successfully",
                    Success = true
                });
            }
            catch (Exception ex)
            {
                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = "",
                    Message = "Could not upload file. " + ex.Message,
                    Success = false
                });
            }
        }
 public static void Run()
 {
     // ExStart:ConcatenateUsingPath
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
     // Create PdfFileEditor object
     PdfFileEditor pdfEditor = new PdfFileEditor();
     // Concatenate files
     pdfEditor.Concatenate(dataDir + "input.pdf", dataDir + "input2.pdf", dataDir + "ConcatenateUsingPath_out.pdf");
     // ExEnd:ConcatenateUsingPath
 }
예제 #5
0
        private static TimeSpan PDFConcatenateUsingPDFFacades(string[] files)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            PdfFileEditor pfe = new PdfFileEditor();

            pfe.CopyOutlines = false;
            pfe.Concatenate(files, dataDir + "\\Facades\\CopyOutline_out.pdf");
            stopwatch.Stop();
            return(stopwatch.Elapsed);
        }
        public static void Run()
        {
            // ExStart:ConcatenateUsingPath
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Concatenate files
            pdfEditor.Concatenate(dataDir + "input.pdf", dataDir + "input2.pdf", dataDir + "ConcatenateUsingPath_out_.pdf");
            // ExEnd:ConcatenateUsingPath
        }
        public static void Run()
        {
            // ExStart:ConcatenatePdfFilesAndCreateTOC
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();
            // Save concatenated output file
            pdfEditor.Concatenate(new FileStream(dataDir + "input1.pdf", FileMode.Open), new FileStream(dataDir + "input2.pdf", FileMode.Open), new FileStream(dataDir + "ConcatenatePdfFilesAndCreateTOC_out.pdf", FileMode.Create));
            // ExEnd:ConcatenatePdfFilesAndCreateTOC                      
        }
예제 #8
0
        public static void Run()
        {
            // ExStart:ConcatenatePdfFilesAndCreateTOC
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Save concatenated output file
            pdfEditor.Concatenate(new FileStream(dataDir + "input1.pdf", FileMode.Open), new FileStream(dataDir + "input2.pdf", FileMode.Open), new FileStream(dataDir + "ConcatenatePdfFilesAndCreateTOC_out_.pdf", FileMode.Create));
            // ExEnd:ConcatenatePdfFilesAndCreateTOC
        }
        public static void CopyOutline()
        {
            // ExStart:CopyOutline
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            PdfFileEditor pfe = new PdfFileEditor();

            string[] files = Directory.GetFiles(dataDir);
            pfe.CopyOutlines = false;
            pfe.Concatenate(files, dataDir + "CopyOutline_out_.pdf");
            // ExEnd:CopyOutline
        }
        public static void CopyOutline()
        {
            // ExStart:CopyOutline
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            PdfFileEditor pfe = new PdfFileEditor();
            string[] files = Directory.GetFiles(dataDir);
            pfe.CopyOutlines = false;
            pfe.Concatenate(files, dataDir + "CopyOutline_out.pdf");
            // ExEnd:CopyOutline
 
        }
        public static void Run()
        {
            // ExStart:ConcatenateMultiplePDFUsingMemoryStream
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create two file streams to read pdf files
            FileStream fs1 = new FileStream(dataDir + "inFile.pdf", FileMode.Open, FileAccess.Read);
            FileStream fs2 = new FileStream(dataDir + "inFile2.pdf", FileMode.Open, FileAccess.Read);

            // Create byte arrays to keep the contents of PDF files
            byte[] buffer1 = new byte[Convert.ToInt32(fs1.Length)];
            byte[] buffer2 = new byte[Convert.ToInt32(fs2.Length)];


            int i = 0;

            // Read PDF file contents into byte arrays
            i = fs1.Read(buffer1, 0, Convert.ToInt32(fs1.Length));
            i = fs2.Read(buffer2, 0, Convert.ToInt32(fs2.Length));

            // Now, first convert byte arrays into MemoryStreams and then concatenate those streams
            using (MemoryStream pdfStream = new MemoryStream())
            {
                using (MemoryStream fileStream1 = new MemoryStream(buffer1))
                {
                    using (MemoryStream fileStream2 = new MemoryStream(buffer2))
                    {
                        // Create instance of PdfFileEditor class to concatenate streams
                        PdfFileEditor pdfEditor = new PdfFileEditor();
                        // Concatenate both input MemoryStreams and save to putput MemoryStream
                        pdfEditor.Concatenate(fileStream1, fileStream2, pdfStream);
                        // Convert MemoryStream back to byte array
                        byte[] data = pdfStream.ToArray();
                        // Create a FileStream to save the output PDF file
                        FileStream output = new FileStream(dataDir + "merged_out_.pdf", FileMode.Create,
                                                           FileAccess.Write);
                        // Write byte array contents in the output file stream
                        output.Write(data, 0, data.Length);
                        // Close output file
                        output.Close();
                    }
                }
            }
            // Close input files
            fs1.Close();
            fs2.Close();
            // ExEnd:ConcatenateMultiplePDFUsingMemoryStream
        }
    public static void RenderInBrowser()
    {
        // ExStart:RenderInBrowser
        // The path to the documents directory.
        string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
 
        // Array of files
        string[] filesArray = new string[2];
        filesArray[0] = dataDir + "input.pdf";
        filesArray[1] = dataDir + "input2.pdf";
        // Create PdfFileEditor object
        PdfFileEditor pdfEditor = new PdfFileEditor();
        // Display the resultant concatenated PDF file in 
        pdfEditor.Concatenate(filesArray, dataDir + "RenderInBrowser_out.pdf");
        // ExEnd:RenderInBrowser
    }
        public static void Run()
        {
            // ExStart:ConcatenateArrayOfFilesWithPath
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();
            // Array of files
            string[] filesArray = new string[2];
            filesArray[0] =  dataDir + "input.pdf";
            filesArray[1] = dataDir + "input2.pdf";
            // Concatenate files
            pdfEditor.Concatenate(filesArray, dataDir + "ConcatenateArrayOfFilesWithPath_out.pdf");
            // ExEnd:ConcatenateArrayOfFilesWithPath
        }
예제 #14
0
 /// <summary>
 /// Takes an array of <see cref="Stream"/>s and returns a <see cref="byte"/>[] array.
 /// </summary>
 /// <param name="streamList">streamList</param>
 /// <returns>merged pdfs</returns>
 private static byte[] ReturnStreamListAsByteArray(Stream[] streamList)
 {
     using (var memoryStream = new MemoryStream())
     {
         var pfe = new PdfFileEditor();
         pfe.Concatenate(streamList, memoryStream);
         // Now manually dispose memory streams (we're done using them).
         // We need to do this otherwise the list of streams will be
         // unreadable which will cause an exception.
         foreach (var doc in streamList)
         {
             doc.Dispose();
         }
         return memoryStream.ToArray();
     }
 }
예제 #15
0
 /// <summary>
 /// Takes an array of <see cref="Stream"/>s and returns a <see cref="byte"/>[] array.
 /// </summary>
 /// <param name="streamList">streamList</param>
 /// <returns>merged pdfs</returns>
 private static byte[] ReturnStreamListAsByteArray(Stream[] streamList)
 {
     using (var memoryStream = new MemoryStream())
     {
         var pfe = new PdfFileEditor();
         pfe.Concatenate(streamList, memoryStream);
         // Now manually dispose memory streams (we're done using them).
         // We need to do this otherwise the list of streams will be
         // unreadable which will cause an exception.
         foreach (var doc in streamList)
         {
             doc.Dispose();
         }
         return(memoryStream.ToArray());
     }
 }
        public static void RenderInBrowser()
        {
            // ExStart:RenderInBrowser
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Array of files
            string[] filesArray = new string[2];
            filesArray[0] = dataDir + "input.pdf";
            filesArray[1] = dataDir + "input2.pdf";
            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Display the resultant concatenated PDF file in
            pdfEditor.Concatenate(filesArray, dataDir + "RenderInBrowser_out_.pdf");
            // ExEnd:RenderInBrowser
        }
        public static void Run()
        {
            // ExStart:ConcatenateBlankPdfUsingStreams
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();
            // Create streams
            FileStream inputStream1 = new FileStream( dataDir + "input.pdf", FileMode.Open);
            FileStream inputStream2 = new FileStream( dataDir + "input2.pdf", FileMode.Open);
            FileStream blankStream = new FileStream(dataDir + "blank.pdf", FileMode.Open);
            FileStream outputStream = new FileStream(dataDir + "ConcatenateBlankPdfUsingStreams_out.pdf", FileMode.Create);
            // Concatenate file
            pdfEditor.Concatenate(inputStream1, inputStream2, blankStream, outputStream);
            // ExEnd:ConcatenateBlankPdfUsingStreams
        }
        public static void Run()
        {
            // ExStart:ConcatenateArrayOfFilesWithPath
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Array of files
            string[] filesArray = new string[2];
            filesArray[0] = dataDir + "input.pdf";
            filesArray[1] = dataDir + "input2.pdf";
            // Concatenate files
            pdfEditor.Concatenate(filesArray, dataDir + "ConcatenateArrayOfFilesWithPath_out_.pdf");
            // ExEnd:ConcatenateArrayOfFilesWithPath
        }
        public static void Run()
        {
            // ExStart:ConcatenateUsingStreams
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();
            // Output stream
            FileStream outputStream = new FileStream(dataDir + "ConcatenateUsingStreams_out_.pdf", FileMode.Create);
            // Input streams
            FileStream inputStream1 = new FileStream(dataDir + "input.pdf", FileMode.Open);
            FileStream inputStream2 = new FileStream(dataDir + "input2.pdf", FileMode.Open);

            // Concatenate file
            pdfEditor.Concatenate(inputStream1, inputStream2, outputStream);
            // ExEnd:ConcatenateUsingStreams
        }
        public static void ConcatenateTaggedFiles()
        {
            // ExStart:ConcatenateTaggedFiles
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            FileStream fileInputStream1 = new FileStream(dataDir + "input.pdf", FileMode.Open, FileAccess.Read);
            FileStream fileInputStream2 = new FileStream(dataDir + "input2.pdf", FileMode.Open, FileAccess.Read);
            FileStream fileOutputStream = new FileStream(dataDir + "ConcatenateTaggedFiles_out.pdf" , FileMode.Create, FileAccess.Write);
            // Concatenate files
            PdfFileEditor editor = new PdfFileEditor();
            editor.CopyLogicalStructure = true;
            bool success = editor.Concatenate(fileInputStream1, fileInputStream2, fileOutputStream);
            Console.Out.WriteLine("Successful... " + success);
            // Close the streams
            fileOutputStream.Close();
            fileInputStream1.Close();
            fileInputStream2.Close();

            // ExEnd:ConcatenateTaggedFiles
 
        }
        public static void Run()
        {
            // ExStart:ConcatenatePDFForms
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Set input and output file paths
            string inputFile1 = dataDir + "inFile1.pdf";
            string inputFile2 = dataDir + "inFile2.pdf";
            string outFile = dataDir + "ConcatenatePDFForms_out.pdf";

            // Instantiate PdfFileEditor Object
            PdfFileEditor fileEditor = new PdfFileEditor();
            // To keep unique field Id for all the fields 
            fileEditor.KeepFieldsUnique = true;
            // Format of the suffix which is added to field name to make it unique when forms are concatenated.
            fileEditor.UniqueSuffix = "_%NUM%";

            // Concatenate the files into a resultant Pdf file
            fileEditor.Concatenate(inputFile1, inputFile2, outFile); 
            // ExEnd:ConcatenatePDFForms                      
        }
예제 #22
0
        //FUNCTION FOR MERGING MULTIPLE PDF FILES

        public void Merge(string files)
        {
            try
            {
                // create PdfFileEditor object
                PdfFileEditor pdfEditor = new PdfFileEditor();


                //splitting from pipe to get files
                string[] filelist = files.Split("|");
                foreach (string data in filelist)
                {
                    Console.WriteLine(data);
                }
                //splitting to extract the location and first file name
                string[] firstfileoperation = filelist[0].Split(@"\");

                var l = firstfileoperation.Length;
                // revoming last 4 i.e .pdf
                string a = firstfileoperation[l - 1].Remove(firstfileoperation[l - 1].Length - 4);
                // getting the dir
                string locationdir = "";
                for (int i = 0; i < firstfileoperation.Length - 1; i++)
                {
                    locationdir = locationdir + firstfileoperation[i] + @"\";
                }
                // final file name
                string resultfilename = a + "_treated.pdf";
                Console.WriteLine(locationdir + resultfilename);
                pdfEditor.Concatenate(filelist, locationdir + resultfilename);
                Console.WriteLine("Merge Done");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("MERGE FAILED!   Run Again With Proper Input");
            }
        }
        public static void ConcatenateTaggedFiles()
        {
            // ExStart:ConcatenateTaggedFiles
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();

            FileStream fileInputStream1 = new FileStream(dataDir + "input.pdf", FileMode.Open, FileAccess.Read);
            FileStream fileInputStream2 = new FileStream(dataDir + "input2.pdf", FileMode.Open, FileAccess.Read);
            FileStream fileOutputStream = new FileStream(dataDir + "ConcatenateTaggedFiles_out_.pdf", FileMode.Create, FileAccess.Write);
            // Concatenate files
            PdfFileEditor editor = new PdfFileEditor();

            editor.CopyLogicalStructure = true;
            bool success = editor.Concatenate(fileInputStream1, fileInputStream2, fileOutputStream);

            Console.Out.WriteLine("Successful... " + success);
            // Close the streams
            fileOutputStream.Close();
            fileInputStream1.Close();
            fileInputStream2.Close();

            // ExEnd:ConcatenateTaggedFiles
        }
        public static void Run()
        {
            // ExStart:ConcatenatePDFForms
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Set input and output file paths
            string inputFile1 = dataDir + "inFile1.pdf";
            string inputFile2 = dataDir + "inFile2.pdf";
            string outFile    = dataDir + "ConcatenatePDFForms_out.pdf";

            // Instantiate PdfFileEditor Object
            PdfFileEditor fileEditor = new PdfFileEditor();

            // To keep unique field Id for all the fields
            fileEditor.KeepFieldsUnique = true;
            // Format of the suffix which is added to field name to make it unique when forms are concatenated.
            fileEditor.UniqueSuffix = "_%NUM%";

            // Concatenate the files into a resultant Pdf file
            fileEditor.Concatenate(inputFile1, inputFile2, outFile);
            // ExEnd:ConcatenatePDFForms
        }
예제 #25
0
        public static void Run()
        {
            // ExStart:ConcatenatingAllPdfFiles
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Retrieve names of all the Pdf files in a particular Directory
            string[] fileEntries = Directory.GetFiles(dataDir, "*.pdf");

            // Get the current System date and set its format
            string date = DateTime.Now.ToString("MM-dd-yyyy");
            // Get the current System time and set its format
            string hoursSeconds = DateTime.Now.ToString("hh-mm");
            // Set the value for the final Resultant Pdf document
            string masterFileName = date + "_" + hoursSeconds + "_out_.pdf";

            // Instantiate PdfFileEditor object
            Aspose.Pdf.Facades.PdfFileEditor pdfEditor = new PdfFileEditor();

            //Call Concatenate method of PdfFileEditor object to concatenate all input files
            //into a single output file
            pdfEditor.Concatenate(fileEntries, dataDir + masterFileName);
            // ExEnd:ConcatenatingAllPdfFiles
        }
예제 #26
0
        protected void BindInvoiceBatchReport()
        {
            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            byte[] bSummary;
            byte[] bDetail;

            string FirmID          = _FirmID;
            string Caption         = _Caption;
            string ClaimNo         = _ClaimNo;
            string InvoiceNO       = _InvoiceNO;
            string AttyID          = _AttyID;
            string SoldAttyName    = _SoldAttyName;
            string FromDate        = _FromDate;
            string ToDate          = _ToDate;
            bool?  Invoice         = _Invoice;
            bool?  Statement       = _Statement;
            bool?  OpenInvoiceOnly = _OpenInvoiceOnly;
            string CompanyNo       = _CompanyNo;

            if (String.IsNullOrEmpty(FromDate))
            {
                FromDate = DateTime.Now.ToString("MM/dd/yyyy");
            }
            if (String.IsNullOrEmpty(ToDate))
            {
                ToDate = DateTime.Now.ToString("MM/dd/yyyy");
            }

            try
            {
                if (_OnlyFilterByInvoice == true)
                {
                    dsCustomers = GetCustomersReport_Invoice(FirmID, Caption, ClaimNo, InvoiceNO, AttyID, SoldAttyName, FromDate, ToDate, Invoice, Statement, OpenInvoiceOnly, OnlyFilterByInvoice: true, CompanyNo: CompanyNo);
                    this.ReportViewer1.PageCountMode = PageCountMode.Actual;
                    ReportViewer1.Width                  = Unit.Percentage(100);
                    ReportViewer1.ProcessingMode         = 0;
                    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/InvoiceNew.rdlc");
                    ReportDataSource datasource = new ReportDataSource("dsInvoice", dsCustomers.Tables["DtInvoice"]);
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.DataSources.Add(datasource);
                    ReportViewer1.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing;
                    ReportViewer1.LocalReport.Refresh();
                }
                else if (_Invoice.Value && _Statement.Value)
                {
                    DsInvoice dsCustomers = GetCustomersReport_Statement(FirmID, Caption, ClaimNo, InvoiceNO, AttyID, SoldAttyName, FromDate, ToDate, Invoice, Statement, OpenInvoiceOnly, CompanyNo: CompanyNo);

                    ReportViewer1.Width = Unit.Percentage(100);
                    //ReportViewer1.Height = Unit.Percentage(100);
                    ReportViewer1.ProcessingMode         = 0;
                    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/SummaryNew.rdlc");
                    ReportDataSource datasource1 = new ReportDataSource("dsInvoice", dsCustomers.Tables["DtInvoice"]);
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.DataSources.Add(datasource1);

                    bSummary = ReportViewer1.LocalReport.Render(
                        "PDF", null, out mimeType, out encoding, out filenameExtension,
                        out streamids, out warnings);

                    this.ReportViewer1.PageCountMode = PageCountMode.Actual;

                    ReportViewer1.ProcessingMode         = 0;
                    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/InvoiceNew.rdlc");
                    dsCustomers = GetCustomersReport_Invoice(FirmID, Caption, ClaimNo, InvoiceNO, AttyID, SoldAttyName, FromDate, ToDate, Invoice, Statement, OpenInvoiceOnly, CompanyNo: CompanyNo);
                    ReportDataSource datasource2 = new ReportDataSource("dsInvoice", dsCustomers.Tables["DtInvoice"]);
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.DataSources.Add(datasource2);

                    ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
                    ReportViewer1.LocalReport.Refresh();

                    bDetail = ReportViewer1.LocalReport.Render(
                        "PDF", null, out mimeType, out encoding, out filenameExtension,
                        out streamids, out warnings);

                    MemoryStream   msSummary = new MemoryStream(bSummary);
                    MemoryStream   msDetail  = new MemoryStream(bDetail);
                    MemoryStream[] msMain    = new MemoryStream[2];
                    msMain[0] = msSummary;
                    msMain[1] = msDetail;

                    Aspose.Pdf.License license = new Aspose.Pdf.License();
                    license.SetLicense("Aspose.Pdf.lic");

                    MemoryStream  pdfStream = new MemoryStream();
                    PdfFileEditor pdfEditor = new PdfFileEditor();
                    pdfEditor.Concatenate(msMain, pdfStream);

                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-disposition", "inline; filename=" + "output.pdf");
                    Response.BinaryWrite(pdfStream.ToArray());
                    pdfStream.Close();
                    Response.End();
                }

                else if (_Invoice.Value)
                {
                    dsCustomers = GetCustomersReport_Invoice(FirmID, Caption, ClaimNo, InvoiceNO, AttyID, SoldAttyName, FromDate, ToDate, Invoice, Statement, OpenInvoiceOnly, CompanyNo: CompanyNo);
                    this.ReportViewer1.PageCountMode = PageCountMode.Actual;
                    ReportViewer1.Width                  = Unit.Percentage(100);
                    ReportViewer1.ProcessingMode         = 0;
                    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/InvoiceNew.rdlc");
                    ReportDataSource datasource = new ReportDataSource("dsInvoice", dsCustomers.Tables["DtInvoice"]);
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.DataSources.Add(datasource);
                    ReportViewer1.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing;
                    ReportViewer1.LocalReport.Refresh();
                }
                else if (_Statement.Value)
                {
                    DsInvoice dsCustomers = GetCustomersReport_Statement(FirmID, Caption, ClaimNo, InvoiceNO, AttyID, SoldAttyName, FromDate, ToDate, Invoice, Statement, OpenInvoiceOnly, CompanyNo: CompanyNo);
                    ReportViewer1.Width = Unit.Percentage(100);
                    this.ReportViewer1.PageCountMode     = PageCountMode.Actual;
                    ReportViewer1.ProcessingMode         = 0;
                    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/SummaryNew.rdlc");
                    ReportDataSource datasource = new ReportDataSource("dsInvoice", dsCustomers.Tables["DtInvoice"]);
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.DataSources.Add(datasource);
                    ReportViewer1.LocalReport.Refresh();
                }
            }
            catch (Exception ex)
            {
            }
        }
        private static void CreateLetterToPutInFrontOfNote(FaxTelephoneNumber faxTelephoneNumber, SignedDocument document)
        {
            Correspondence letter = new Correspondence();
            letter.TodaysDate = DateTime.Now.ToLongDateString();
            letter.MessageFrom = "A patient communications update from the office of " + document.CareProviderName;

            if (string.IsNullOrEmpty(faxTelephoneNumber.AddressLine1))
            {
                faxTelephoneNumber.AddressLine1 = string.Empty;
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.AddressLine2))
            {
                faxTelephoneNumber.AddressLine2 = string.Empty;
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.City))
            {
                faxTelephoneNumber.City = string.Empty;
            }
            else
            {
                faxTelephoneNumber.City = faxTelephoneNumber.City + ", ";
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.State))
            {
                faxTelephoneNumber.State = string.Empty;
            }
            else
            {
                faxTelephoneNumber.State = faxTelephoneNumber.State + " ";
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.PostalCode))
            {
                faxTelephoneNumber.PostalCode = string.Empty;
            }

            if (faxTelephoneNumber.AddressLine2.Length > 0)
            {
                letter.HeaderText = faxTelephoneNumber.Name + Environment.NewLine
                    + faxTelephoneNumber.AddressLine1 + Environment.NewLine
                    + faxTelephoneNumber.AddressLine2 + Environment.NewLine
                    + faxTelephoneNumber.City
                    + faxTelephoneNumber.State + faxTelephoneNumber.PostalCode;
            }
            else
            {
                string[] credential = faxTelephoneNumber.FullName.Split(' ');
                faxTelephoneNumber.Name = credential[1] + " " + credential[0] + " " + credential[credential.Length - 1];

                letter.HeaderText = credential[1] + " " + credential[0] + " " + credential[credential.Length - 1] + Environment.NewLine
                     + faxTelephoneNumber.AddressLine1 + Environment.NewLine
                     + faxTelephoneNumber.City
                     + faxTelephoneNumber.State + faxTelephoneNumber.PostalCode;
            }

            letter.BodyText = "I saw your patient " + document.PatientName
                + " at your request in consultation regarding the patient’s  orthopedic problem.  "
                + " Thank you for your kind referral." + Environment.NewLine + Environment.NewLine
                + "I’ve enclosed a copy of our office notes which includes "
                + "the diagnosis and treatment plan.  I will continue to keep you updated in the future with "
                + "regard to our patient’s progress .  Please let me know if I can answer any further questions "
                + "regarding our patient’s care." + Environment.NewLine + Environment.NewLine + Environment.NewLine
                + "All the Best,"
                + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine
                + document.CareProviderName
                + Environment.NewLine + Environment.NewLine
                + "Enclosure"
            ;

            AutomatedFaxReports.Letter report1 = new AutomatedFaxReports.Letter(letter);
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
            instanceReportSource.ReportDocument = report1;
            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
            using (var pdfStream = new MemoryStream(result.DocumentBytes))
            using (var reportFile = new FileStream(ConfigurationValues.CorrespondensePath, FileMode.Create))
            {
                pdfStream.CopyTo(reportFile);
            }

            PdfFileEditor pdfEditor = new PdfFileEditor();

            //    try
            //    {
            //        File.Delete(ConfigurationValues.FinalFaxPath);
            //    }
            //    catch { }

            ConfigurationValues.FinalFaxPath = System.Configuration.ConfigurationManager.AppSettings["finalFaxPath"] + Guid.NewGuid().ToString() + ".pdf";
            pdfEditor.Concatenate(ConfigurationValues.CorrespondensePath, ConfigurationValues.CreatePdfPath, ConfigurationValues.FinalFaxPath);

        }
예제 #28
0
        public static void CompletedCode()
        {
            // ExStart:CompletedCode
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Create a MemoryStream object to hold the resultant PDf file
            using (MemoryStream Concatenated_Stream = new MemoryStream())
            {
                // Save concatenated output file
                pdfEditor.Concatenate(new FileStream(dataDir + "input1.pdf", FileMode.Open), new FileStream(dataDir + "input2.pdf", FileMode.Open), Concatenated_Stream);
                // Insert a blank page at the begining of concatenated file to display Table of Contents
                Aspose.Pdf.Document concatenated_pdfDocument = new Aspose.Pdf.Document(Concatenated_Stream);
                // Insert a empty page in a PDF
                concatenated_pdfDocument.Pages.Insert(1);

                // Hold the resultnat file with empty page added
                using (MemoryStream Document_With_BlankPage = new MemoryStream())
                {
                    // Save output file
                    concatenated_pdfDocument.Save(Document_With_BlankPage);

                    using (var Document_with_TOC_Heading = new MemoryStream())
                    {
                        // Add Table Of Contents logo as stamp to PDF file
                        PdfFileStamp fileStamp = new PdfFileStamp();
                        // Find the input file
                        fileStamp.BindPdf(Document_With_BlankPage);

                        // Set Text Stamp to display string Table Of Contents
                        Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
                        stamp.BindLogo(new FormattedText("Table Of Contents", System.Drawing.Color.Maroon, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 18));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        stamp.SetOrigin((new PdfFileInfo(Document_With_BlankPage).GetPageWidth(1) / 3), 700);
                        // Set particular pages
                        stamp.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(stamp);

                        // Create stamp text for first item in Table Of Contents
                        var Document1_Link = new Aspose.Pdf.Facades.Stamp();
                        Document1_Link.BindLogo(new FormattedText("1 - Link to Document 1", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        Document1_Link.SetOrigin(150, 650);
                        // Set particular pages on which stamp should be displayed
                        Document1_Link.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(Document1_Link);

                        // Create stamp text for second item in Table Of Contents
                        var Document2_Link = new Aspose.Pdf.Facades.Stamp();
                        Document2_Link.BindLogo(new FormattedText("2 - Link to Document 2", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        Document2_Link.SetOrigin(150, 620);
                        // Set particular pages on which stamp should be displayed
                        Document2_Link.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(Document2_Link);

                        // Save updated PDF file
                        fileStamp.Save(Document_with_TOC_Heading);
                        fileStamp.Close();

                        // Now we need to add Heading for Table Of Contents and links for documents
                        PdfContentEditor contentEditor = new PdfContentEditor();
                        // Bind the PDF file in which we added the blank page
                        contentEditor.BindPdf(Document_with_TOC_Heading);
                        // Create link for first document
                        contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650, 100, 20), 2, 1, System.Drawing.Color.Transparent);
                        // Create link for Second document
                        // We have used   new PdfFileInfo("d:/pdftest/Input1.pdf").NumberOfPages + 2   as PdfFileInfo.NumberOfPages(..) returns the page count for first document
                        // and 2 is because, second document will start at Input1+1 and 1 for the page containing Table Of Contents.
                        contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 620, 100, 20), new PdfFileInfo(dataDir + "Input1.pdf").NumberOfPages + 2, 1, System.Drawing.Color.Transparent);

                        // Save updated PDF
                        contentEditor.Save(dataDir + "Concatenated_Table_Of_Contents.pdf");
                    }
                }
            }
            // ExEnd:CompletedCode
        }
        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                      
        }
예제 #30
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
        }
예제 #31
0
        public ActionResult <Response> ConcatenateWithContents([FromBody] Request request)
        {
            try
            {
                Stopwatch stopwatch1 = new Stopwatch();
                stopwatch1.Start();

                PdfFileEditor pdfEditor = new PdfFileEditor();

                using (MemoryStream Concatenated_Stream = new MemoryStream())
                {
                    string concFilename = "Concatenated_Table_Of_Contents.pdf";

                    List <System.IO.Stream> pdfStreams = new List <System.IO.Stream>();
                    string[] files = System.IO.Directory.GetFiles(serverDirectory);
                    foreach (string file in files)
                    {
                        if (file.ToLower().Contains(concFilename.ToLower()))
                        {
                            continue;
                        }
                        if (!Path.GetExtension(file).Equals(".pdf"))
                        {
                            continue;
                        }
                        System.IO.FileStream stream = new System.IO.FileStream(file, System.IO.FileMode.Open);
                        pdfStreams.Add(stream);
                    }

                    //System.IO.FileStream outputPDF = new System.IO.FileStream(serverDirectory + request.filename + ".pdf", System.IO.FileMode.Create);
                    Stopwatch stopwatch2 = new Stopwatch();
                    stopwatch2.Start();

                    pdfEditor.Concatenate(pdfStreams.ToArray(), Concatenated_Stream);

                    stopwatch2.Stop();
                    Console.WriteLine("PdfEditor.Concatenate Action: " + stopwatch2.ElapsedMilliseconds.ToString());

                    // Insert a blank page at the begining of concatenated file to display Table of Contents
                    Aspose.Pdf.Document concatenated_pdfDocument = new Aspose.Pdf.Document(Concatenated_Stream);
                    // Insert a empty page in a PDF
                    concatenated_pdfDocument.Pages.Insert(1);

                    using (MemoryStream Document_With_BlankPage = new MemoryStream())
                    {
                        // Save output file

                        stopwatch2.Reset();
                        stopwatch2.Start();
                        concatenated_pdfDocument.Save(Document_With_BlankPage);

                        stopwatch2.Stop();
                        Console.WriteLine("Concatenated_pdfDocument.Save Action: " + stopwatch2.ElapsedMilliseconds.ToString());

                        using (var Document_with_TOC_Heading = new MemoryStream())
                        {
                            // Add Table Of Contents logo as stamp to PDF file
                            PdfFileStamp fileStamp = new PdfFileStamp();
                            // Find the input file
                            fileStamp.BindPdf(Document_With_BlankPage);

                            // Set Text Stamp to display string Table Of Contents
                            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
                            stamp.BindLogo(new FormattedText("Table Of Contents", System.Drawing.Color.Maroon, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 18));
                            // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                            stamp.SetOrigin((new PdfFileInfo(Document_With_BlankPage).GetPageWidth(1) / 3), 700);
                            // Set particular pages
                            stamp.Pages = new int[] { 1 };
                            // Add stamp to PDF file

                            stopwatch2.Reset();
                            stopwatch2.Start();
                            fileStamp.AddStamp(stamp);

                            stopwatch2.Stop();
                            Console.WriteLine("FileStamp.AddStamp Action: " + stopwatch2.ElapsedMilliseconds.ToString());

                            int counter = 1;
                            int diff    = 0;
                            foreach (System.IO.Stream stream in pdfStreams)
                            {
                                var Document_Link = new Aspose.Pdf.Facades.Stamp();
                                Document_Link.BindLogo(new FormattedText(counter + " - Link to Document " + counter, System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                                Document_Link.SetOrigin(150, 650 - diff);
                                Document_Link.Pages = new int[] { 1 };
                                fileStamp.AddStamp(Document_Link);
                                counter++;
                                diff += 40;
                            }

                            stopwatch2.Reset();
                            stopwatch2.Start();
                            fileStamp.Save(Document_with_TOC_Heading);
                            stopwatch2.Stop();
                            Console.WriteLine("FileStamp.Save Action: " + stopwatch2.ElapsedMilliseconds.ToString());


                            fileStamp.Close();

                            PdfContentEditor contentEditor = new PdfContentEditor();
                            // Bind the PDF file in which we added the blank page
                            contentEditor.BindPdf(Document_with_TOC_Heading);

                            counter = 1;
                            diff    = 0;
                            int numberOfpagesOfPreviousFile = 0;
                            foreach (System.IO.Stream stream in pdfStreams)
                            {
                                if (counter == 1)
                                {
                                    contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650 - diff, 100, 20), counter + 1, 1, System.Drawing.Color.Transparent);
                                }
                                else
                                {
                                    //Replace counter with numberOfpagesOfPreviousFile of the following line to fix Link page number
                                    contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650 - diff, 100, 20), counter + 1, 1, System.Drawing.Color.Transparent);
                                }
                                counter++;
                                numberOfpagesOfPreviousFile = new PdfFileInfo(stream).NumberOfPages;
                                diff += 40;
                            }

                            if (System.IO.File.Exists(serverDirectory + concFilename))
                            {
                                System.IO.File.Delete(serverDirectory + concFilename);
                            }

                            stopwatch2.Reset();
                            stopwatch2.Start();

                            contentEditor.Save(serverDirectory + concFilename);

                            stopwatch2.Stop();
                            Console.WriteLine("FileStamp.Save Action: " + stopwatch2.ElapsedMilliseconds.ToString());
                        }
                    }
                }

                stopwatch1.Stop();
                Console.WriteLine("Total Time: " + stopwatch1.ElapsedMilliseconds.ToString());

                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = "Concatenated_Table_Of_Contents.pdf",
                    Message = "Files Concatenated successfully to: Concatenated_Table_Of_Contents.pdf file",
                    Success = true
                });
            }
            catch (Exception ex)
            {
                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = "",
                    Message = "Could not concatenate files. " + ex.Message,
                    Success = false
                });
            }
        }
        public static void CompletedCode()
        {
            // ExStart:CompletedCode
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();
            // Create a MemoryStream object to hold the resultant PDf file
            using (MemoryStream Concatenated_Stream = new MemoryStream())
            {
                // Save concatenated output file
                pdfEditor.Concatenate(new FileStream(dataDir + "input1.pdf", FileMode.Open), new FileStream(dataDir + "input2.pdf", FileMode.Open), Concatenated_Stream);
                // Insert a blank page at the begining of concatenated file to display Table of Contents
                Aspose.Pdf.Document concatenated_pdfDocument = new Aspose.Pdf.Document(Concatenated_Stream);
                // Insert a empty page in a PDF
                concatenated_pdfDocument.Pages.Insert(1);

                // Hold the resultnat file with empty page added
                using (MemoryStream Document_With_BlankPage = new MemoryStream())
                {
                    // Save output file
                    concatenated_pdfDocument.Save(Document_With_BlankPage);

                    using (var Document_with_TOC_Heading = new MemoryStream())
                    {
                        // Add Table Of Contents logo as stamp to PDF file
                        PdfFileStamp fileStamp = new PdfFileStamp();
                        // Find the input file
                        fileStamp.BindPdf(Document_With_BlankPage);

                        // Set Text Stamp to display string Table Of Contents
                        Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
                        stamp.BindLogo(new FormattedText("Table Of Contents", System.Drawing.Color.Maroon, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 18));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        stamp.SetOrigin((new PdfFileInfo(Document_With_BlankPage).GetPageWidth(1) / 3), 700);
                        // Set particular pages
                        stamp.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(stamp);

                        // Create stamp text for first item in Table Of Contents
                        var Document1_Link = new Aspose.Pdf.Facades.Stamp();
                        Document1_Link.BindLogo(new FormattedText("1 - Link to Document 1", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        Document1_Link.SetOrigin(150, 650);
                        // Set particular pages on which stamp should be displayed
                        Document1_Link.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(Document1_Link);

                        // Create stamp text for second item in Table Of Contents
                        var Document2_Link = new Aspose.Pdf.Facades.Stamp();
                        Document2_Link.BindLogo(new FormattedText("2 - Link to Document 2", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        Document2_Link.SetOrigin(150, 620);
                        // Set particular pages on which stamp should be displayed
                        Document2_Link.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(Document2_Link);

                        // Save updated PDF file
                        fileStamp.Save(Document_with_TOC_Heading);
                        fileStamp.Close();

                        // Now we need to add Heading for Table Of Contents and links for documents
                        PdfContentEditor contentEditor = new PdfContentEditor();
                        // Bind the PDF file in which we added the blank page
                        contentEditor.BindPdf(Document_with_TOC_Heading);
                        // Create link for first document
                        contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650, 100, 20), 2, 1, System.Drawing.Color.Transparent);
                        // Create link for Second document
                        // We have used   new PdfFileInfo("d:/pdftest/Input1.pdf").NumberOfPages + 2   as PdfFileInfo.NumberOfPages(..) returns the page count for first document
                        // And 2 is because, second document will start at Input1+1 and 1 for the page containing Table Of Contents.
                        contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 620, 100, 20), new PdfFileInfo(dataDir + "Input1.pdf").NumberOfPages + 2, 1, System.Drawing.Color.Transparent);

                        // Save updated PDF
                        contentEditor.Save( dataDir + "Concatenated_Table_Of_Contents.pdf");
                    }
                }
            }
            // ExEnd:CompletedCode
        }