コード例 #1
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 + "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();
        }
コード例 #2
0
        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
        }
コード例 #3
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
        }
コード例 #4
0
        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
            
        }
コード例 #5
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();
 
        }
コード例 #6
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();
        }
コード例 #7
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
        }
コード例 #8
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();
        }
コード例 #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 + "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();
 
        }
コード例 #10
0
        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
            
        }
コード例 #11
0
        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
        }
コード例 #12
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();
        }
コード例 #13
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");

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

            //save updated PDF file
            fileStamp.Close();
        }
コード例 #14
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();
        }
コード例 #15
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");

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

            //save updated PDF file
            fileStamp.Close();
        }
コード例 #16
0
        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                      
        }
コード例 #17
0
        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
        }
コード例 #18
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();
        }
コード例 #19
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();
        }
コード例 #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 + "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();
        }
コード例 #21
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 header
            fileStamp.AddHeader(formattedText, 10);

            //save updated PDF file
            fileStamp.Close();
        }
コード例 #22
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 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();
        }
コード例 #23
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 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();
        }
コード例 #24
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();
        }
コード例 #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();
        }
コード例 #26
0
        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();
        }
コード例 #27
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 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();
        }
コード例 #28
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 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();
        }
コード例 #29
0
        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();
        }
コード例 #30
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
        }
コード例 #31
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
            
        }
コード例 #32
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
        }
コード例 #33
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
        }
コード例 #34
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
                });
            }
        }