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

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddPageNumber.pdf");
            
            // Get total number of pages
            int totalPages = new PdfFileInfo(dataDir + "AddPageNumber.pdf").NumberOfPages;

            // Create formatted text for page number
            FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            // Set starting number for first page; you might want to start from 2 or more
            fileStamp.StartingNumber = 1;

            // Add page number
            fileStamp.AddPageNumber(formattedText, 0);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddPageNumber_out.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddPageNumber
            
        }
        public static void Run()
        {
            // ExStart:AddHeader
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddHeader.pdf");
         
            // Create formatted text for page number
            FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            // Add header
            fileStamp.AddHeader(formattedText, 10);
           
            // Save updated PDF file
            fileStamp.Save(dataDir + "AddHeader_out.pdf");
            
            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddHeader
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            //Open Document
            fileStamp.BindPdf(dataDir + "AddImageStamp-Page.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindImage(dataDir + "aspose-logo.jpg");
            stamp.SetOrigin(200, 200);
            stamp.Rotation     = 90.0F;
            stamp.IsBackground = true;

            //set particular pages
            stamp.Pages = new int[] { 1 };

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Save(dataDir + "AddImageStamp-Page_out.pdf");

            //close fileStamp
            fileStamp.Close();
        }
Beispiel #4
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            //Open Document
            fileStamp.BindPdf(dataDir + "Input_new.pdf");

            //get total number of pages
            int totalPages = new PdfFileInfo(dataDir + "Input_new.pdf").NumberOfPages;

            //create formatted text for page number
            FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            //set starting number for first page; you might want to start from 2 or more
            fileStamp.StartingNumber = 1;

            //add page number
            fileStamp.AddPageNumber(formattedText, 0);

            //save updated PDF file
            fileStamp.Save(dataDir + "AddPageNumber_out.pdf");

            //close fileStamp
            fileStamp.Close();
        }
Beispiel #5
0
        public static void Run()
        {
            // ExStart:AddPageStampPage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddPageStamp-Page.pdf");

            // Create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindPdf(dataDir + "temp.pdf", 1);
            stamp.SetOrigin(200, 200);
            stamp.Rotation     = 90.0F;
            stamp.IsBackground = true;

            // Set particular pages
            stamp.Pages = new int[] { 2 };

            // Add stamp to PDF file
            fileStamp.AddStamp(stamp);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddPageStamp-Page_out_.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddPageStampPage
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            //Open Document
            fileStamp.BindPdf(dataDir + "AddPageStamp-Page.pdf");
 
            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindPdf(dataDir+ "temp.pdf", 1);
            stamp.SetOrigin(200, 200);
            stamp.Rotation = 90.0F;
            stamp.IsBackground = true;

            //set particular pages
            stamp.Pages = new int[] { 2 };

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Save(dataDir + "AddPageStamp-Page_out.pdf");

            //close fileStamp
            fileStamp.Close();
 
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            //Open Document
            fileStamp.BindPdf(dataDir + "AddTextStampAll.pdf"); 
           
            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindLogo(new FormattedText("Hello World!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 14));
            stamp.SetOrigin(200, 200);
            stamp.Rotation = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Save(dataDir + "AddTextStampAll_out.pdf");

            //close fileStamp
            fileStamp.Close();
 
        }
Beispiel #8
0
        public static void Run()
        {
            // ExStart:AddImageStampAll
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddImageStampAll.pdf");

            // Create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindImage(dataDir + "aspose-logo.jpg");
            stamp.SetOrigin(200, 200);
            stamp.Rotation     = 90.0F;
            stamp.IsBackground = true;

            // Add stamp to PDF file
            fileStamp.AddStamp(stamp);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddImageStampAll_out_.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddImageStampAll
        }
Beispiel #9
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            //Open Document
            fileStamp.BindPdf(dataDir + "AddTextStampAll.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindLogo(new FormattedText("Hello World!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 14));
            stamp.SetOrigin(200, 200);
            stamp.Rotation     = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Save(dataDir + "AddTextStampAll_out.pdf");

            //close fileStamp
            fileStamp.Close();
        }
        public static void Run()
        {
            // ExStart:AddFooter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddFooter.pdf");

            // Create formatted text for page number
            FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            // Add footer
            fileStamp.AddFooter(formattedText, 10);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddFooter_out.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddFooter
        }
        public static void Run()
        {
            // ExStart:AddPageStampAll
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddPageStampAll.pdf"); 

            // Create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindPdf(dataDir+ "temp.pdf", 1);
            stamp.SetOrigin(200, 200);
            stamp.Rotation = 90.0F;
            stamp.IsBackground = true;

            // Add stamp to PDF file
            fileStamp.AddStamp(stamp);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddPageStampAll_out.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddPageStampAll
            
        }
Beispiel #12
0
        public MemoryStream WatermarkFile(MemoryStream s, string sUserName, DateTime dtCurrentDate, string sCompany)
        {
            Aspose.Pdf.License l2 = new Aspose.Pdf.License();
            l2.SetLicense("ASPOSE-DE-CCO-121128--140416092055-DE-SCO-157407.txt");
            l2.Embedded = true;
            Document pdfDocument = new Document(s);

            Document     pdfDocumentNoStamps = pdfDocument; //RemoveExistingWatermarks(pdfDocument);
            PdfFileStamp pdfStamp            = new PdfFileStamp(pdfDocumentNoStamps);

            return(AddWatermarkToFile(pdfDocumentNoStamps, ref pdfStamp, sUserName, dtCurrentDate, sCompany));
        }
Beispiel #13
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "AddImage-Footer.pdf", dataDir + "AddImage-Footer_out.pdf");

            //add footer
            fileStamp.AddFooter(new FileStream(dataDir + "aspose-logo.jpg", FileMode.Open), 10);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "AddImage-Footer.pdf", dataDir+ "AddImage-Footer_out.pdf");

            //add footer
            fileStamp.AddFooter(new FileStream(dataDir+ "aspose-logo.jpg", FileMode.Open), 10);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "input.pdf", dataDir+ "output.pdf");

            //add header
            fileStamp.AddHeader(new FileStream(dataDir+ "aspose-logo.jpg", FileMode.Open), 10);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "input.pdf", dataDir + "output.pdf");

            //add footer
            fileStamp.AddFooter(new FileStream(dataDir + "aspose-logo.jpg", FileMode.Open), 10);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Run()
        {
            // ExStart:RotatingStamp
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Set path of the image to be set as watermark
            string imageFile = dataDir + "aspose-logo.jpg";

            // Set input file path
            string inFile = dataDir + "inFile.pdf";

            // Set output file path
            string outFile = dataDir + "RotatingStamp_out.pdf";

            // Create PdfFileInfo object to get height and width of the pages
            PdfFileInfo fileInfo = new PdfFileInfo(inFile);

            // Create Stamp object
            Aspose.Pdf.Facades.Stamp aStamp = new Aspose.Pdf.Facades.Stamp();

            // Bind image file with the Stamp object
            aStamp.BindImage(imageFile);

            // Specify whether the stamp will be added as a background or not
            aStamp.IsBackground = false;

            // Specifies at which pages to add the watermark
            aStamp.Pages = new int[] { 1 };

            // Specifies the watermark rotation - rotate at 90 degrees the stamp is rotated about the center point of the stamp object
            aStamp.Rotation = 90;

            // Specifies the position of stamp - lower left corner of the stamp
            aStamp.SetOrigin(fileInfo.GetPageWidth(1) / 2, fileInfo.GetPageHeight(1) / 2);

            // Set the size of the watermark
            aStamp.SetImageSize(100, 100);

            Document doc = new Document(inFile);
            // Create PdfFileStamp class to bind input and output files
            PdfFileStamp stamper = new PdfFileStamp(doc);

            // Add the stamp in the PDF file
            stamper.AddStamp(aStamp);

            // Close the PdfFileStamp object
            stamper.Close();
            // ExEnd:RotatingStamp                      
        }
        public static void Run()
        {
            // ExStart:RotatingStamp
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Set path of the image to be set as watermark
            string imageFile = dataDir + "aspose-logo.jpg";

            // Set input file path
            string inFile = dataDir + "inFile.pdf";

            // Set output file path
            string outFile = dataDir + "RotatingStamp_out.pdf";

            // Create PdfFileInfo object to get height and width of the pages
            PdfFileInfo fileInfo = new PdfFileInfo(inFile);

            // Create Stamp object
            Aspose.Pdf.Facades.Stamp aStamp = new Aspose.Pdf.Facades.Stamp();

            // Bind image file with the Stamp object
            aStamp.BindImage(imageFile);

            // Specify whether the stamp will be added as a background or not
            aStamp.IsBackground = false;

            // Specifies at which pages to add the watermark
            aStamp.Pages = new int[] { 1 };

            // Specifies the watermark rotation - rotate at 90 degrees the stamp is rotated about the center point of the stamp object
            aStamp.Rotation = 90;

            // Specifies the position of stamp - lower left corner of the stamp
            aStamp.SetOrigin(fileInfo.GetPageWidth(1) / 2, fileInfo.GetPageHeight(1) / 2);

            // Set the size of the watermark
            aStamp.SetImageSize(100, 100);

            Document doc = new Document(inFile);
            // Create PdfFileStamp class to bind input and output files
            PdfFileStamp stamper = new PdfFileStamp(doc);

            // Add the stamp in the PDF file
            stamper.AddStamp(aStamp);

            // Close the PdfFileStamp object
            stamper.Close();
            // ExEnd:RotatingStamp
        }
Beispiel #19
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "input.pdf", dataDir + "output.pdf");

            //create formatted text for page number
            FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            //add footer
            fileStamp.AddFooter(formattedText, 10);

            //save updated PDF file
            fileStamp.Close();
        }
Beispiel #20
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "AddFooter.pdf", dataDir+ "AddFooter_out.pdf");

            //create formatted text for page number
            FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            //add footer
            fileStamp.AddFooter(formattedText, 10);

            //save updated PDF file
            fileStamp.Close();
        }
Beispiel #21
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "AddHeader.pdf", dataDir + "AddHeader_out.pdf");

            //create formatted text for page number
            FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            //add header
            fileStamp.AddHeader(formattedText, 10);

            //save updated PDF file
            fileStamp.Close();
        }
 public static void CustomNumberStyle()
 {
     // ExStart:CustomNumberStyle
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
     // Create PdfFileStamp object
     PdfFileStamp fileStamp = new PdfFileStamp();
     // Open Document
     fileStamp.BindPdf(dataDir + "AddPageNumber.pdf");
     // Specify numbering style as Numerals Roman UpperCase
     fileStamp.NumberingStyle = NumberingStyle.NumeralsRomanUppercase;
     // Add page number stamp at Bottom-Center of page
     fileStamp.AddPageNumber("#");
     // Save updated PDF file
     fileStamp.Save(dataDir + "CustomNumberStyle_out.pdf");
     // ExEnd:CustomNumberStyle
 }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "input.pdf", dataDir+ "output.pdf");

            //create formatted text for page number
            FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            //add header
            fileStamp.AddHeader(formattedText, 10);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void CustomNumberStyle()
        {
            // ExStart:CustomNumberStyle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddPageNumber.pdf");
            // Specify numbering style as Numerals Roman UpperCase
            fileStamp.NumberingStyle = NumberingStyle.NumeralsRomanUppercase;
            // Add page number stamp at Bottom-Center of page
            fileStamp.AddPageNumber("#");
            // Save updated PDF file
            fileStamp.Save(dataDir + "CustomNumberStyle_out_.pdf");
            // ExEnd:CustomNumberStyle
        }
Beispiel #25
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "AddImageStampAll.pdf", dataDir + "AddImageStampAll_out.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindImage(dataDir + "aspose-logo.jpg");
            stamp.SetOrigin(200, 200);
            stamp.Rotation     = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "input.pdf", dataDir+ "output.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindPdf(dataDir+ "temp.pdf", 1);
            stamp.SetOrigin(200, 200);
            stamp.Rotation = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "AddImageStampAll.pdf", dataDir+ "AddImageStampAll_out.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindImage(dataDir+ "aspose-logo.jpg");
            stamp.SetOrigin(200, 200);
            stamp.Rotation = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "input.pdf", dataDir + "output.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindImage(dataDir + "aspose-logo.jpg");
            stamp.SetOrigin(200, 200);
            stamp.Rotation     = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "Input_new.pdf", dataDir+ "output.pdf");

            //get total number of pages

            int totalPages = new PdfFileInfo(dataDir+ "Input_new.pdf").NumberOfPages;
            //create formatted text for page number
            FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            //set starting number for first page; you might want to start from 2 or more
            fileStamp.StartingNumber = 1;
            //add page number
            fileStamp.AddPageNumber(formattedText, 0);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir+ "input.pdf", dataDir+  "output.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindLogo(new FormattedText("Hello World!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 14));
            stamp.SetOrigin(200, 200);
            stamp.Rotation = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "Input_new.pdf", dataDir + "output.pdf");

            //get total number of pages

            int totalPages = new PdfFileInfo(dataDir + "Input_new.pdf").NumberOfPages;
            //create formatted text for page number
            FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);

            //set starting number for first page; you might want to start from 2 or more
            fileStamp.StartingNumber = 1;
            //add page number
            fileStamp.AddPageNumber(formattedText, 0);

            //save updated PDF file
            fileStamp.Close();
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //open document
            PdfFileStamp fileStamp = new PdfFileStamp(dataDir + "input.pdf", dataDir + "output.pdf");

            //create stamp
            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
            stamp.BindLogo(new FormattedText("Hello World!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 14));
            stamp.SetOrigin(200, 200);
            stamp.Rotation     = 90.0F;
            stamp.IsBackground = true;

            //add stamp to PDF file
            fileStamp.AddStamp(stamp);

            //save updated PDF file
            fileStamp.Close();
        }
Beispiel #33
0
        public static void Run()
        {
            // ExStart:AddImageFooter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddImage-Footer.pdf");

            // Add footer
            fileStamp.AddFooter(new FileStream(dataDir + "aspose-logo.jpg", FileMode.Open), 10);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddImage-Footer_out.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddImageFooter
        }
Beispiel #34
0
        private MemoryStream AddWatermarkToFile(Document pdfDocument, ref PdfFileStamp pdfStamp, string sUserName, DateTime dtCurrentDate, string sCompany)
        {
            string sTextDate = dtCurrentDate.ToString("dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            FormattedText wtext = new FormattedText("Confidential", new FontColor(220, 20, 60), new FontColor(255, 255, 255),
                                                    Aspose.Pdf.Facades.FontStyle.HelveticaBold,
                                                    EncodingType.Winansi, true, 35);

            wtext.AddNewLineText(sUserName, 5);
            wtext.AddNewLineText(sTextDate, 5);

            int nPageCount = 1;

            foreach (Aspose.Pdf.Page pg in pdfDocument.Pages)
            {
                //get the page size position for each page
                Aspose.Pdf.Rectangle rtPage = pg.TrimBox;
                AddWatermarkToPage(rtPage.Width, rtPage.Height, pg, sUserName, sTextDate);

                nPageCount++;
            }

            MemoryStream outStream = new MemoryStream();
            //save updated PDF file
            DocumentPrivilege pv = null;

            pv = DocumentPrivilege.AllowAll;

            pv.ChangeAllowLevel = 0;
            pv.CopyAllowLevel   = 1;
            pv.PrintAllowLevel  = 2;

            pdfStamp.Document.Encrypt("", new Guid().ToString(), pv, CryptoAlgorithm.RC4x128, false);

            pdfStamp.Save(outStream);

            return(outStream);
        }
        public static void Run()
        {
            // ExStart:AddImageFooter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            // Create PdfFileStamp object
            PdfFileStamp fileStamp = new PdfFileStamp();

            // Open Document
            fileStamp.BindPdf(dataDir + "AddImage-Footer.pdf");

            // Add footer
            fileStamp.AddFooter(new FileStream(dataDir+ "aspose-logo.jpg", FileMode.Open), 10);

            // Save updated PDF file
            fileStamp.Save(dataDir + "AddImage-Footer_out.pdf");

            // Close fileStamp
            fileStamp.Close();
            // ExEnd:AddImageFooter
            
        }
Beispiel #36
0
        /// <summary>
        /// adds the header and footer details to the given pathTotempPdf, and creates the offical pdf location.
        /// </summary>
        public void AddHeaderAndFooter(string pathToTempPdfFile)
        {
            PdfFileStamp fileStamp = null;

            try
            {
                fileStamp = new PdfFileStamp();
                fileStamp.BindPdf(pathToTempPdfFile);
                FormattedText        ftSubjectID = null;
                FormattedText        ftMedrioID  = null;
                System.Drawing.Color fontColor   = System.Drawing.Color.Black;

                if (CustomSubjectID)
                {
                    ftSubjectID = new FormattedText(string.Format("Subject Identifier: {0}", SubjectIdentifier)
                                                    , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                if (IsMedrioIDShown)
                {
                    ftMedrioID = new FormattedText(string.Format("Medrio ID: {0}", Subject.FormatMedrioSubjectID(MedrioSubjectID))
                                                   , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                FormattedText ftSite = new FormattedText(HeaderItemText("Site: ", SiteName, HEADER_LABELWIDTH)
                                                         , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftVisit = new FormattedText(HeaderItemText(Study.VisitLabelSingular + ": ", VisitName, HEADER_LABELWIDTH)
                                                          , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftGroup = new FormattedText(HeaderItemText("Group: ", GroupName, HEADER_LABELWIDTH)
                                                          , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftForm = new FormattedText(HeaderItemText("Form: ", FormName, HEADER_LABELWIDTH)
                                                         , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftStudy = new FormattedText(string.Format("{0}", StudyTitle)
                                                          , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                //add header
                int medrioIdTopMargin = 20;
                if (null != ftSubjectID)
                {
                    fileStamp.AddHeader(ftSubjectID, 20, 25, 0);
                    medrioIdTopMargin = 30;
                }
                if (null != ftMedrioID)
                {
                    fileStamp.AddHeader(ftMedrioID, medrioIdTopMargin, 25, 0);
                }
                fileStamp.AddHeader(ftSite, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftVisit, 30, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftGroup, 20, 0, 50);
                fileStamp.AddHeader(ftForm, 30, 0, 50);

                TimeZoneInfo tzi = null;
                try
                {
                    tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneFormatForCurrentUser);
                }
                catch
                {
                    tzi = TimeZoneInfo.Local;
                }

                DateTime dt = TimeZoneInfo.ConvertTime(DateTime.UtcNow, tzi);

                FormattedText ftDatetime = new FormattedText(string.Format("{0} {1:HH:mm} ({2})", dt.ToString(ExportDateFormat), dt, TimeZoneFormatForCurrentUser)
                                                             , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                // add footer
                fileStamp.AddFooter(ftStudy, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddFooter(ftDatetime, 20, 25, 0);
                fileStamp.Save(PathToPdf);
            }
            finally
            {
                if (fileStamp != null)
                {
                    //close
                    fileStamp.Dispose();
                }
            }
        }
        /// <summary>
        /// adds the header and footer details to the given pathTotempPdf, and creates the offical pdf location.
        /// </summary>
        public void AddHeaderAndFooter(string pathToTempPdfFile)
        {
            PdfFileStamp fileStamp = null;
            try
            {
                fileStamp = new PdfFileStamp();
                fileStamp.BindPdf(pathToTempPdfFile);
                FormattedText ftSubjectID = null;
                FormattedText ftMedrioID = null;
                System.Drawing.Color fontColor = System.Drawing.Color.Black;

                if (CustomSubjectID)
                {
                    ftSubjectID = new FormattedText(string.Format("Subject Identifier: {0}", SubjectIdentifier)
                                                    , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                if (IsMedrioIDShown)
                {
                    ftMedrioID = new FormattedText(string.Format("Medrio ID: {0}", Subject.FormatMedrioSubjectID(MedrioSubjectID))
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                FormattedText ftSite = new FormattedText(HeaderItemText("Site: ", SiteName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftVisit = new FormattedText(HeaderItemText(Study.VisitLabelSingular + ": ", VisitName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftGroup = new FormattedText(HeaderItemText("Group: ", GroupName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftForm = new FormattedText(HeaderItemText("Form: ", FormName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftStudy = new FormattedText(string.Format("{0}", StudyTitle)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                //add header
                int medrioIdTopMargin = 20;
                if (null != ftSubjectID)
                {
                    fileStamp.AddHeader(ftSubjectID, 20, 25, 0);
                    medrioIdTopMargin = 30;
                }
                if (null != ftMedrioID)
                {
                    fileStamp.AddHeader(ftMedrioID, medrioIdTopMargin, 25, 0);
                }
                fileStamp.AddHeader(ftSite, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftVisit, 30, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftGroup, 20, 0, 50);
                fileStamp.AddHeader(ftForm, 30, 0, 50);

                TimeZoneInfo tzi = null;
                try
                {
                    tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneFormatForCurrentUser);
                }
                catch
                {
                    tzi = TimeZoneInfo.Local;
                }

                DateTime dt = TimeZoneInfo.ConvertTime(DateTime.UtcNow, tzi);

                FormattedText ftDatetime = new FormattedText(string.Format("{0} {1:HH:mm} ({2})", dt.ToString(ExportDateFormat), dt, TimeZoneFormatForCurrentUser)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                // add footer
                fileStamp.AddFooter(ftStudy, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddFooter(ftDatetime, 20, 25, 0);
                fileStamp.Save(PathToPdf);
            }
            finally
            {
                if (fileStamp != null)
                {
                    //close
                    fileStamp.Dispose();
                }
            }
        }
Beispiel #38
0
        private MemoryStream AddFooterToFile(Document pdfDocument, ref PdfFileStamp pdfStamp, string sUserName, DateTime dtCurrentDate, string sCompany)
        {
            //create footer
            List <TextStamp> ltFooterStamp = new List <TextStamp>();
            TextStamp        footerStamp   = null;


            //footerStamp = new TextStamp("Document ID: ");
            ////set properties of the stamp
            //footerStamp.BottomMargin = 10;
            //footerStamp.XIndent = 20;
            ////footerStamp.HorizontalAlignment = HorizontalAlignment.Left;
            //footerStamp.VerticalAlignment = VerticalAlignment.Bottom;
            //footerStamp.TextState.FontStyle = FontStyles.Bold;

            //ltFooterStamp.Add(footerStamp);


            //footerStamp = new TextStamp(documentGuid.ToString());
            ////set properties of the stamp
            //footerStamp.BottomMargin = 10;
            //footerStamp.XIndent = 130;
            ////footerStamp.HorizontalAlignment = HorizontalAlignment.Left;
            //footerStamp.VerticalAlignment = VerticalAlignment.Bottom;
            //footerStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

            //ltFooterStamp.Add(footerStamp);


            string sTextDate = dtCurrentDate.ToString("dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            FormattedText wtext = new FormattedText("Confidential", new FontColor(220, 20, 60), new FontColor(255, 255, 255),
                                                    Aspose.Pdf.Facades.FontStyle.HelveticaBold,
                                                    EncodingType.Winansi, true, 17);

            wtext.AddNewLineText(sUserName, 5);
            wtext.AddNewLineText(sTextDate, 5);
            footerStamp = new TextStamp(wtext);
            ltFooterStamp.Add(footerStamp);


            float fWidth = wtext.TextWidth;


            Dictionary <Tuple <double, double>, List <int> > dictMeasurements = new Dictionary <Tuple <double, double>, List <int> >();
            int nPageCount = 1;

            foreach (Aspose.Pdf.Page pg in pdfDocument.Pages)
            {
                foreach (TextStamp ts in ltFooterStamp)
                {
                    pg.AddStamp(ts);
                }



                nPageCount++;
            }


            MemoryStream outStream = new MemoryStream();

            //save updated PDF file
            pdfStamp.Save(outStream);

            return(outStream);
        }
Beispiel #39
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
        }
Beispiel #40
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
        }